-
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
- Loading branch information
Maja Kabus
authored and
Chrome-bot
committed
Sep 12, 2018
1 parent
af3dc21
commit 07e4937
Showing
3 changed files
with
82 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.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> |
60 changes: 60 additions & 0 deletions
60
...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,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> |