-
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.
DOMWindowTimers::setTimeout and setInterval modified to accept Trusted
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 Reviewed-on: https://chromium-review.googlesource.com/1179899 Reviewed-by: Mike West <[email protected]> Reviewed-by: Yuki Shiino <[email protected]> Commit-Queue: Maja Kabus <[email protected]> Cr-Commit-Position: refs/heads/master@{#591327}
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
trusted-types/DOMWindowTimers-setTimeout-setInterval.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,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> |
56 changes: 56 additions & 0 deletions
56
...ed-types/block-string-assignment-to-DOMWindowTimers-setTimeout-setInterval.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,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> |