summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/html/script-does-not-run-on-child-removal.html
blob: e87a1a97cf1f11746ff8962c76eb730eef2dd8c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var script_did_run, script, x;

test(() => {
  script_did_run = false;
  script = document.createElement('script');
  script.type = '0';  // This prevents execution on insertion.
  script.textContent = 'script_did_run = true; script.appendChild(x);';
  document.documentElement.appendChild(script);

  x = document.createElement('x');
  script.appendChild(x);
  script.type = '';   // This enables, but does not trigger, execution.
  assert_false(script_did_run, 'setting type should not trigger execution');

  var iframe = document.createElement('iframe');
  document.documentElement.appendChild(iframe);
  iframe.contentDocument.adoptNode(x);
  assert_false(script_did_run, 'removing child should not trigger execution');
  assert_equals(x.ownerDocument, iframe.contentDocument,
                'the element should have been adopted by the frame document');
});
</script>