Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMWindowTimers::setTimeout and setInterval modified to accept Trusted Types. #12554

Merged
merged 1 commit into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lint.whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ SET TIMEOUT: streams/piping/general.js
SET TIMEOUT: streams/readable-streams/cancel.js
SET TIMEOUT: streams/resources/rs-utils.js
SET TIMEOUT: streams/writable-streams/byte-length-queuing-strategy.js
SET TIMEOUT: trusted-types/block-string-assignment-to-DOMWindowTimers-setTimeout-setInterval.tentative.html
SET TIMEOUT: trusted-types/DOMWindowTimers-setTimeout-setInterval.tentative.html
SET TIMEOUT: user-timing/*
SET TIMEOUT: webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
SET TIMEOUT: webauthn/*timeout.https.html
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<body>
<script>
async_test(t => {
window.timeoutTest = t;
let policy = createScript_policy(window, 'timeout');
let script = policy.createScript("window.timeoutTest.done();");
setTimeout(script);
}, "window.setTimeout assigned via policy (successful Script transformation).");

async_test(t => {
window.intervalTest = t;
let policy = createScript_policy(window, 'script');
let script = policy.createScript("window.intervalTest.done();");
setInterval(script);
}, "window.setInterval assigned via policy (successful Script transformation).");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<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="trusted-types">
<body>
<script>
// setTimeout tests
// TrustedScript assignments do not throw.
async_test(t => {
window.timeoutTest = t;
let policy = createScript_policy(window, 'timeout');
let script = policy.createScript("window.timeoutTest.done();");
setTimeout(script);
}, "window.setTimeout assigned via policy (successful Script transformation).");

// String assignments throw.
test(t => {
window.timeoutTestString = t.unreached_func();
assert_throws(new TypeError(), _ => {
setTimeout("window.timeoutTestString();");
});
}, "`window.setTimeout(string)` throws.");

// Null assignment throws.
test(t => {
assert_throws(new TypeError(), _ => {
setTimeout(null);
});
}, "`window.setTimeout(null)` throws.");

// setInterval tests
// TrustedScript assignments do not throw.
async_test(t => {
window.intervalTest = t;
let policy = createScript_policy(window, 'script');
let script = policy.createScript("window.intervalTest.done();");
setInterval(script);
}, "window.setInterval assigned via policy (successful Script transformation).");

// String assignments throw.
test(t => {
window.intervalTestString = t.unreached_func();
assert_throws(new TypeError(), _ => {
setInterval("window.intervalTestString()");
});
}, "`window.setInterval(string)` throws.");

// Null assignment throws.
test(t => {
assert_throws(new TypeError(), _ => {
setInterval(null);
});
}, "`window.setInterval(null)` throws.");
</script>