forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Location object tests from query-encoding/
Helps with web-platform-tests#4934.
- Loading branch information
Showing
2 changed files
with
49 additions
and
51 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
html/infrastructure/urls/resolving-urls/query-encoding/location.sub.html
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 --> | ||
<meta name=variant content="?encoding=x-cp1251"> | ||
<meta name=variant content="?encoding=utf8"> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<div id=log></div> | ||
<script> | ||
function expected(encoding) { | ||
return "?" + { | ||
"UTF-8": "%C3%BF", | ||
"windows-1251": "&%23255;", | ||
"windows-1252": "%FF" | ||
}[encoding]; | ||
} | ||
|
||
[ | ||
[(win, input) => { win.location = input; }, "location [PutForwards]"], | ||
[(win, input) => { win.location.assign(input); }, "location.assign()"], | ||
[(win, input) => { win.location.replace(input); }, "location.replace()"], | ||
[(win, input) => { win.location.href = input; }, "location.href"] | ||
].forEach(([callback, desc]) => { | ||
async_test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")), | ||
actualEncoding = document.characterSet | ||
callback(frame.contentWindow, "/common/blank.html?\u00FF"); | ||
frame.onload = t.step_func_done(() => { | ||
assert_equals(frame.contentWindow.location.search, expected(actualEncoding)); | ||
}); | ||
}, desc); | ||
}); | ||
|
||
async_test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")), | ||
actualEncoding = document.characterSet; | ||
frame.src = "/common/blank.html"; | ||
frame.onload = t.step_func(() => { | ||
frame.contentWindow.location.search = "\u00FF"; | ||
frame.onload = t.step_func_done(() => { | ||
assert_equals(frame.contentWindow.location.search, expected(actualEncoding)); | ||
}); | ||
}); | ||
}, "location.search"); | ||
</script> |
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