Skip to content

Commit

Permalink
DOMWindowTimers::setTimeout and setInterval modified to accept Trusted
Browse files Browse the repository at this point in the history
Types.

New implementations of DOMWindowTimers::setTimeout() and setInterval()
added to accept TrustedScript as an argument.
Previously existing implementations renamed to setTimeoutFromString()
and setIntervalFromString(), respectively.

Bug: 739170
Change-Id: I3513ebb651534f0b1ef1b8de9c694136b02e2412
  • Loading branch information
Maja Kabus authored and Chrome-bot committed Sep 12, 2018
1 parent af3dc21 commit 07e4937
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
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.Timeout_test = t;
let policy = createScript_policy(window, 'timeout');
let script = policy.createScript("window.Timeout_test.done();");
setTimeout(script);
}, "window.setTimeout assigned via policy (successful Script transformation).");

async_test(t => {
window.Interval_test = t;
let policy = createScript_policy(window, 'interval');
let script = policy.createScript("window.Interval_test.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,60 @@
<!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.Timeout_test = t;
let policy = createScript_policy(window, 'timeout');
let script = policy.createScript("window.Timeout_test.done();");
setTimeout(script);
}, "window.setTimeout assigned via policy (successful Script transformation).");

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

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

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

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

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

0 comments on commit 07e4937

Please sign in to comment.