-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1917783 - Add WPT tests for getAttributeType with event handler c…
…ontent attributes. r=smaug The spec is not really clear, for now add a tentative test with the cases detected while implementing the method in Firefox. For details, see w3c/trusted-types#520 Differential Revision: https://phabricator.services.mozilla.com/D226442
- Loading branch information
Showing
2 changed files
with
330 additions
and
0 deletions.
There are no files selected for viewing
282 changes: 282 additions & 0 deletions
282
...tedTypePolicyFactory-getAttributeType-event-handler-content-attributes.tentative.html.ini
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,282 @@ | ||
[TrustedTypePolicyFactory-getAttributeType-event-handler-content-attributes.tentative.html] | ||
[getAttributeType("dummy", "onabort", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onauxclick", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbeforeinput", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbeforematch", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbeforetoggle", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onblur", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncancel", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncanplay", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncanplaythrough", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onchange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onclick", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onclose", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncontextlost", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncontextmenu", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncontextrestored", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncopy", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncuechange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oncut", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondblclick", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondrag", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondragend", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondragenter", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondragleave", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondragover", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondragstart", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondrop", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ondurationchange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onemptied", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onended", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onerror", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onfocus", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onformdata", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oninput", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "oninvalid", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onkeydown", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onkeypress", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onkeyup", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onload", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onloadeddata", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onloadedmetadata", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onloadstart", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmousedown", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmouseenter", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmouseleave", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmousemove", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmouseout", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmouseover", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmouseup", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpaste", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpause", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onplay", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onplaying", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onprogress", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onratechange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onreset", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onresize", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onscroll", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onscrollend", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onsecuritypolicyviolation", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onseeked", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onseeking", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onselect", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onslotchange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onstalled", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onsubmit", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onsuspend", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ontimeupdate", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ontoggle", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onvolumechange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onwaiting", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onwheel", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onafterprint", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbeforeprint", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbeforeunload", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onhashchange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onlanguagechange", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmessage", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onmessageerror", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onoffline", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "ononline", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpagehide", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpagereveal", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpageshow", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpageswap", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onpopstate", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onrejectionhandled", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onstorage", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onunhandledrejection", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onunload", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onencrypted", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onwaitingforkey", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onbegin", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onend", "dummyNs", attrNs)] | ||
expected: FAIL | ||
|
||
[getAttributeType("dummy", "onrepeat", "dummyNs", attrNs)] | ||
expected: FAIL |
48 changes: 48 additions & 0 deletions
48
...TrustedTypePolicyFactory-getAttributeType-event-handler-content-attributes.tentative.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,48 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-getattributetype"> | ||
<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#abstract-opdef-get-trusted-type-data-for-attribute"> | ||
<link rel="help" href="https://github.com/w3c/trusted-types/issues/520"> | ||
<meta name="assert" content="getAttributeType() with empty attributeNs returns 'TrustedScript' for event handler content attributes."> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/WebIDLParser.js"></script> | ||
<script src="support/namespaces.js"></script> | ||
<script> | ||
promise_setup(async function() { | ||
let attributeNames = []; | ||
function addOnAttributes(IDL, interfaceName) { | ||
// Parsing the whole IDL file is slow, so use a small regexp to extract only | ||
// the part that is relevant for this test. | ||
let regexp = new RegExp(`^.*\(partial \)?interface \(mixin \)?${interfaceName}[^{]*{[^{}]*};$`, "m"); | ||
let parsedIDL = WebIDL2.parse(IDL.match(regexp)[0]); | ||
parsedIDL.find(idl => idl.name === interfaceName) | ||
.members.map(member => member.name) | ||
.filter(name => name.length >= 3 && name.startsWith("on") && | ||
!name.startsWith("onwebkit")) | ||
.forEach(name => attributeNames.push(name)); | ||
} | ||
|
||
const htmlIDL = await (await fetch("/interfaces/html.idl")).text(); | ||
["GlobalEventHandlers", "WindowEventHandlers"].forEach(interfaceName => { | ||
addOnAttributes(htmlIDL, interfaceName); | ||
}); | ||
|
||
const entrypedMediaIDL = await (await fetch("/interfaces/encrypted-media.idl")).text(); | ||
addOnAttributes(entrypedMediaIDL, "HTMLMediaElement"); | ||
|
||
const svgAnimationsIDL = await (await fetch("/interfaces/svg-animations.idl")).text(); | ||
addOnAttributes(svgAnimationsIDL, "SVGAnimationElement"); | ||
|
||
for (const attributeName of attributeNames) { | ||
promise_test(async () => { | ||
NSURI_ARRAY.forEach(attrNs => { | ||
assert_equals(trustedTypes.getAttributeType( | ||
"dummy", attributeName, "dummyNs", attrNs), | ||
attrNs === NSURI_EMPTY ? "TrustedScript" : null, | ||
`for attrNs='${attrNs}'`); | ||
}); | ||
}, `getAttributeType("dummy", "${attributeName}", "dummyNs", attrNs)`); | ||
} | ||
}); | ||
</script> |