-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test query encoding of attributes separately
This also changes how we test the ping IDL attribute as the HTML Standard does not require it to be reflected other than as a string. It also adds testing for <area>. Helps with #4934.
- Loading branch information
Showing
2 changed files
with
66 additions
and
49 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
html/infrastructure/urls/resolving-urls/query-encoding/attributes.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,66 @@ | ||
<!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> | ||
<link rel=help href=https://html.spec.whatwg.org/multipage/rendering.html#the-page> | ||
<link rel=help href=https://html.spec.whatwg.org/multipage/rendering.html#tables-2> | ||
<link rel=help href=https://html.spec.whatwg.org/multipage/#reflecting-content-attributes-in-idl-attributes> | ||
<div id=log></div> | ||
<script> | ||
function expected(encoding) { | ||
return "?" + { | ||
"UTF-8": "%C3%BF", | ||
"windows-1251": "%26%23255%3B", | ||
"windows-1252": "%FF" | ||
}[encoding]; | ||
} | ||
|
||
function assert_ends_with(input, endsWith) { | ||
assert_true(input.endsWith(endsWith), input + " did not end with " + endsWith); | ||
} | ||
|
||
"body table thead tbody tfoot tr td th".split(" ").forEach(localName => { | ||
test(t => { | ||
const elm = document.createElement(localName); | ||
document.body.appendChild(elm); | ||
t.add_cleanup(() => document.body.removeChild(elm)); | ||
elm.setAttribute("background", "?\u00FF"); | ||
assert_ends_with(getComputedStyle(elm).backgroundImage, expected(document.characterSet) + "\")"); | ||
}, "getComputedStyle <" + localName + " background>"); | ||
}); | ||
|
||
function test_url_reflecting(localName, attr, idlAttr) { | ||
idlAttr = idlAttr || attr; | ||
test(() => { | ||
let input = "?\u00FF"; | ||
const elm = document.createElement(localName); | ||
assert_true(idlAttr in elm, idlAttr + " is not supported"); | ||
elm.setAttribute(attr, input); | ||
assert_ends_with(elm[idlAttr], expected(document.characterSet)); | ||
}, "Getting <" + localName + ">." + idlAttr); | ||
} | ||
|
||
("iframe src, a href, area href, base href, link href, img src, embed src, object data, " + | ||
"track src, video src, audio src, input src, form action, input formaction formAction, " + | ||
"button formaction formAction, script src").split(", ").forEach(str => { | ||
const arr = str.split(" "); | ||
test_url_reflecting(arr[0], arr[1], arr[2]); | ||
}); | ||
|
||
function test_string_reflecting(localName, attr) { | ||
test(() => { | ||
let input = "?\u00FF ?\u00FF"; | ||
const elm = document.createElement(localName); | ||
assert_true(attr in elm, attr + " is not supported"); | ||
elm.setAttribute(attr, input); | ||
assert_equals(elm[attr], input); | ||
}, "Getting <" + localName + ">." + attr); | ||
} | ||
|
||
"a ping, area ping".split(", ").forEach(str => { | ||
const arr = str.split(" "); | ||
test_string_reflecting(arr[0], arr[1]); | ||
}); | ||
</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