Skip to content

Commit 5116af9

Browse files
johannesodlandMs2ger
authored andcommitted
[testharness.js] Fix issue caused when path contains full stop characters (.)
#50693 The current implementation of `get_title()` assumes that the path does not contain a full stop character. If it does, `get_title()` would return parts of the path, in stead of the filename. The pathname `/a.path/filename.html` would cause `get_title()` to return `.path` instead of the expected `filename`. This change fixes the issue by trimming the path away before searching for the extension. It maintains the current behavior, where it only keeps the first part of the filename if the filename contains multiple full stop characters. `/path/filename.foo.html` still returns `filename`.
1 parent 43b2d7d commit 5116af9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: infrastructure/testharness/full.stop/full-stop.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE HTML>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script>
5+
test(function () {
6+
assert_equals(this.name, 'full-stop', 'Check that test name does not contain part of the path (.stop)');
7+
});
8+
</script>

Diff for: resources/testharness.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4788,7 +4788,8 @@
47884788
return META_TITLE;
47894789
}
47904790
if ('location' in global_scope && 'pathname' in location) {
4791-
return location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.indexOf('.'));
4791+
var filename = location.pathname.substring(location.pathname.lastIndexOf('/') + 1);
4792+
return filename.substring(0, filename.indexOf('.'));
47924793
}
47934794
return "Untitled";
47944795
}

0 commit comments

Comments
 (0)