Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/innerHTML/script-execution.html

Issue 2657263002: Experiment with blocking script inside fragment-parser-inserted `<iframe srcdoc>`.
Patch Set: Bitwise logic is hard. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_element_factory.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <body>
5 <script>
6 async_test(t => {
7 var container = document.createElement('div');
8 container.innerHTML = '<script>document.currentScript.executed = true;</scr' + 'ipt>';
9 document.body.appendChild(container);
10
11 // run the test after this task ends, to yield to the parser and give the
12 // script time to potentially execute.
13 requestAnimationFrame(t.step_func_done(_ => {
14 assert_equals(container.querySelector('script').executed, undefined);
15 }));
16 }, "<script> inserted via innerHTML does not execute.");
17
18 var payload = `
19 <script>
20 var current = window;
21 while (current.frameElement) {
22 current.frameElement.executed = true;
23 current = current.parent;
24 }
25 </scr` + `ipt>
26 `;
27 function assert_no_execution(name, html) {
28 async_test(t => {
29 var container = document.createElement('div');
30 document.body.appendChild(container);
31 var observer = new MutationObserver(mutations => {
32 for (var mutation of mutations) {
33 for (var node of mutation.addedNodes) {
34 if (node.dataset['test'] == name) {
35 observer.disconnect();
36 node.addEventListener('load', t.step_func(e => {
37 // Give nested scripts a frame or so to execute:
38 requestAnimationFrame(t.step_func_done(_ => {
39 assert_equals(node.executedScript, undefined, "Script should n ot execute.");
40 container.remove();
41 }));
42 }));
43 }
44 }
45 }
46 });
47 observer.observe(container, { childList: true });
48 container.innerHTML = html.replace(/<iframe/, `<iframe data-test="${name}" `);
49 }, name);
50 }
51 </script>
52 <script>
53 assert_no_execution("script in srcdoc", `<iframe srcdoc="${payload}"></iframe> `);
54 </script>
55 <script>
56 assert_no_execution("script in nested srcdoc", `<iframe srcdoc="<iframe srcdoc ='${payload}'></iframe>"></iframe>`);
57 </script>
58 <script>
59 assert_no_execution("script in nested srcdoc in nested srcdoc", `<iframe srcdo c="<iframe srcdoc=&quot;<iframe srcdoc='${payload}'></iframe>&quot;></iframe>">< /iframe>`);
60 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_element_factory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698