Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=271316 Reviewed by Anne van Kesteren. Upstream commit: web-platform-tests/wpt@577d225 * LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-blocking.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-blocking-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-blocking.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/trusted-types/TrustedTypePolicyFactory-blocking.html. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-parseHTMLUnsafe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-parseHTMLUnsafe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttribute-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttribute.html: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttributeNS-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setAttributeNS.html: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setHTMLUnsafe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setHTMLUnsafe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-ShadowRoot-setHTMLUnsafe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-ShadowRoot-setHTMLUnsafe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/idlharness.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/idlharness.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/idlharness.window.js: Renamed from LayoutTests/imported/w3c/web-platform-tests/trusted-types/idlharness.tentative.window.js.html. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/support/helper.sub.js: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-from-literal.tentative-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-from-literal-expected.txt. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-from-literal.tentative.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/trusted-types/trusted-types-from-literal.html. * LayoutTests/imported/w3c/web-platform-tests/trusted-types/w3c-import.log: Canonical link: https://commits.webkit.org/276793@main
- Loading branch information
1 parent
9a1840e
commit 2e2d6c1
Showing
19 changed files
with
430 additions
and
30 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
...form-tests/trusted-types/block-string-assignment-to-Document-parseHTMLUnsafe-expected.txt
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,9 @@ | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
|
||
PASS Document.parseHTMLUnsafe assigned via policy (successful HTML transformation). | ||
PASS `Document.parseHTMLUnsafe(string)` throws. | ||
PASS 'Document.parseHTMLUnsafe(null)' throws | ||
PASS 'Document.parseHTMLUnsafe(string)' assigned via default policy (successful HTML transformation). | ||
PASS 'Document.parseHTMLUnsafe(null)' assigned via default policy does not throw | ||
|
48 changes: 48 additions & 0 deletions
48
...web-platform-tests/trusted-types/block-string-assignment-to-Document-parseHTMLUnsafe.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> | ||
<html> | ||
<head> | ||
<meta name="author" title="Luke Warlow" href="mailto:lwarlow@igalia.com"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/helper.sub.js"></script> | ||
|
||
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> | ||
</head> | ||
<body> | ||
<script> | ||
test(t => { | ||
let p = createHTML_policy(window, 1); | ||
let html = p.createHTML(INPUTS.HTML); | ||
let doc = Document.parseHTMLUnsafe(html); | ||
assert_equals(doc.body.innerText, RESULTS.HTML); | ||
}, "Document.parseHTMLUnsafe assigned via policy (successful HTML transformation)."); | ||
|
||
// String assignments throw. | ||
test(t => { | ||
assert_throws_js(TypeError, _ => { | ||
var doc = Document.parseHTMLUnsafe("Fail"); | ||
}); | ||
}, "`Document.parseHTMLUnsafe(string)` throws."); | ||
|
||
// Null assignment throws. | ||
test(t => { | ||
assert_throws_js(TypeError, _ => { | ||
var doc = Document.parseHTMLUnsafe(null); | ||
}); | ||
}, "'Document.parseHTMLUnsafe(null)' throws"); | ||
|
||
// After default policy creation string assignment implicitly calls createHTML. | ||
test(t => { | ||
let p = window.trustedTypes.createPolicy("default", { createHTML: createHTMLJS }, true); | ||
let doc = Document.parseHTMLUnsafe(INPUTS.HTML, "text/html"); | ||
assert_equals(doc.body.innerText, RESULTS.HTML); | ||
}, "'Document.parseHTMLUnsafe(string)' assigned via default policy (successful HTML transformation)."); | ||
|
||
// After default policy creation null assignment implicitly calls createHTML. | ||
test(t => { | ||
var doc = Document.parseHTMLUnsafe(null, "text/html"); | ||
assert_equals(doc.body.innerText, "null"); | ||
}, "'Document.parseHTMLUnsafe(null)' assigned via default policy does not throw"); | ||
</script> | ||
</body> | ||
</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
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
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
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
9 changes: 9 additions & 0 deletions
9
...latform-tests/trusted-types/block-string-assignment-to-Element-setHTMLUnsafe-expected.txt
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,9 @@ | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
|
||
PASS element.setHTMLUnsafe(html) assigned via policy (successful HTML transformation). | ||
PASS `element.setHTMLUnsafe(string)` throws. | ||
PASS `element.setHTMLUnsafe(null)` throws. | ||
PASS `element.setHTMLUnsafe(string)` assigned via default policy (successful HTML transformation). | ||
PASS `element.setHTMLUnsafe(string)` assigned via default policy does not throw | ||
|
79 changes: 79 additions & 0 deletions
79
...3c/web-platform-tests/trusted-types/block-string-assignment-to-Element-setHTMLUnsafe.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,79 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="author" title="Luke Warlow" href="mailto:lwarlow@igalia.com"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/helper.sub.js"></script> | ||
|
||
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> | ||
</head> | ||
<body> | ||
<div id="container"></div> | ||
<script> | ||
var container = document.querySelector('#container') | ||
|
||
// TrustedHTML assignments do not throw. | ||
test(t => { | ||
let p = createHTML_policy(window, 1); | ||
let html = p.createHTML(INPUTS.HTML); | ||
|
||
var d = document.createElement('div'); | ||
document.querySelector('#container').appendChild(d); | ||
d.setHTMLUnsafe(html); | ||
assert_equals(container.innerText, RESULTS.HTML); | ||
|
||
while (container.firstChild) | ||
container.firstChild.remove(); | ||
}, "element.setHTMLUnsafe(html) assigned via policy (successful HTML transformation)."); | ||
|
||
// String assignments throw. | ||
test(t => { | ||
var d = document.createElement('div'); | ||
container.appendChild(d); | ||
assert_throws_js(TypeError, _ => { | ||
d.setHTMLUnsafe("Fail"); | ||
}); | ||
assert_equals(container.innerText, ""); | ||
while (container.firstChild) | ||
container.firstChild.remove(); | ||
}, "`element.setHTMLUnsafe(string)` throws."); | ||
|
||
// Null assignment throws. | ||
test(t => { | ||
var d = document.createElement('div'); | ||
container.appendChild(d); | ||
assert_throws_js(TypeError, _ => { | ||
d.outerHTML = null; | ||
}); | ||
assert_equals(container.innerText, ""); | ||
while (container.firstChild) | ||
container.firstChild.remove(); | ||
}, "`element.setHTMLUnsafe(null)` throws."); | ||
|
||
// After default policy creation string assignment implicitly calls createHTML. | ||
test(t => { | ||
let p = window.trustedTypes.createPolicy("default", { createHTML: createHTMLJS }, true); | ||
|
||
var d = document.createElement('div'); | ||
document.querySelector('#container').appendChild(d); | ||
d.setHTMLUnsafe(INPUTS.HTML); | ||
assert_equals(container.innerText, RESULTS.HTML); | ||
|
||
while (container.firstChild) | ||
container.firstChild.remove(); | ||
}, "`element.setHTMLUnsafe(string)` assigned via default policy (successful HTML transformation)."); | ||
|
||
// After default policy creation null assignment implicitly calls createHTML. | ||
test(t => { | ||
var d = document.createElement('div'); | ||
container.appendChild(d); | ||
d.setHTMLUnsafe(null); | ||
assert_equals(container.innerText, "null"); | ||
|
||
while (container.firstChild) | ||
container.firstChild.remove(); | ||
}, "`element.setHTMLUnsafe(string)` assigned via default policy does not throw"); | ||
</script> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
...form-tests/trusted-types/block-string-assignment-to-ShadowRoot-setHTMLUnsafe-expected.txt
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,9 @@ | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
CONSOLE MESSAGE: This requires a TrustedHTML value else it violates the following Content Security Policy directive: "require-trusted-types-for 'script'" | ||
|
||
PASS shadowRoot.setHTMLUnsafe(html) assigned via policy (successful HTML transformation). | ||
PASS `shadowRoot.setHTMLUnsafe(string)` throws. | ||
PASS `shadowRoot.setHTMLUnsafe(null)` throws. | ||
PASS `shadowRoot.setHTMLUnsafe(string)` assigned via default policy (successful HTML transformation). | ||
PASS `shadowRoot.setHTMLUnsafe(string)` assigned via default policy does not throw | ||
|
Oops, something went wrong.