-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wptrunner] Downgrade URL validation in content shell driver (#39036)
See the comment in `testharnessreport-content-shell.js`. URL mismatches will no longer be treated as a harness `ERROR`. For the URLs to match as much as possible, this change partially undoes #39007, which broke validation for final URLs with fragments. Instead, we use the standard `URL(...)` instead of `<a>` to parse the original `location.href`.
- Loading branch information
1 parent
286d2ea
commit 071134c
Showing
2 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 42 additions & 20 deletions
62
tools/wptrunner/wptrunner/testharnessreport-content-shell.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
var props = {output:%(output)d, debug: %(debug)s}; | ||
setup(props); | ||
(function() { | ||
var props = {output:%(output)d, debug: %(debug)s}; | ||
setup(props); | ||
|
||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
testRunner.setPopupBlockingEnabled(false); | ||
testRunner.setDumpJavaScriptDialogs(false); | ||
// Some tests navigate away from the original URL as part of the | ||
// functionality they exercise. In that case, `add_completion_callback(...)` | ||
// uses the final `window.location` to report the test ID, which may not be | ||
// correct [1]. | ||
// | ||
// Persisting the original `window.location` with standard web platform APIs | ||
// (e.g., `localStorage`) could interfere with the their tests, so this must | ||
// be avoided. Unfortunately, there doesn't appear to be anything in content | ||
// shell's protocol mode or Blink-specific `window.testRunner` or | ||
// `window.internals` [2] that could help with this. As such, the driver | ||
// simply downgrades a mismatched test ID to a logged warning instead of a | ||
// harness error. | ||
// | ||
// [1] crbug.com/1418753 | ||
// [2] https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/testing/writing_web_tests.md#Relying-on-Blink_Specific-Testing-APIs | ||
const url = new URL(location.href); | ||
|
||
add_completion_callback(function (tests, harness_status) { | ||
var id = decodeURIComponent(location.pathname) + decodeURIComponent(location.search) + decodeURIComponent(location.hash); | ||
var result_string = JSON.stringify([ | ||
id, | ||
harness_status.status, | ||
harness_status.message, | ||
harness_status.stack, | ||
tests.map(function(t) { | ||
return [t.name, t.status, t.message, t.stack] | ||
}), | ||
]); | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
testRunner.setPopupBlockingEnabled(false); | ||
testRunner.setDumpJavaScriptDialogs(false); | ||
// Show `CONSOLE MESSAGE:` and `CONSOLE ERROR:` in stderr. | ||
if (props.debug) { | ||
testRunner.setDumpConsoleMessages(true); | ||
} | ||
|
||
testRunner.setCustomTextOutput(result_string); | ||
testRunner.notifyDone(); | ||
}); | ||
add_completion_callback(function (tests, harness_status) { | ||
const test_id = decodeURIComponent(url.pathname) + decodeURIComponent(url.search) + decodeURIComponent(url.hash); | ||
const result_string = JSON.stringify([ | ||
test_id, | ||
harness_status.status, | ||
harness_status.message, | ||
harness_status.stack, | ||
tests.map(function(t) { | ||
return [t.name, t.status, t.message, t.stack] | ||
}), | ||
]); | ||
testRunner.setCustomTextOutput(result_string); | ||
testRunner.notifyDone(); | ||
}); | ||
})(); |