-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathscript-runs-on-character-data-mutation.window.js
More file actions
36 lines (28 loc) · 1.17 KB
/
script-runs-on-character-data-mutation.window.js
File metadata and controls
36 lines (28 loc) · 1.17 KB
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
27
28
29
30
31
32
33
34
35
36
// https://github.com/whatwg/html/issues/12279
test(() => {
window.script_did_run = false;
const script = document.createElement('script');
// This prevents execution on insertion.
script.type = '0';
const text = document.createTextNode('script_did_run = true;');
script.append(text);
document.body.append(script);
assert_false(script_did_run,
'Appending script with invalid type does not trigger execution');
// This enables, but does not trigger, execution.
script.type = '';
assert_false(script_did_run,
'Unsetting script type does not trigger execution');
text.data = 'script_did_run = true;';
assert_false(script_did_run,
'Setting CharacterData.data does not trigger execution');
text.appendData(' /* still should not run */');
assert_false(script_did_run,
'appendData() does not trigger execution');
text.replaceData(0, text.length, 'script_did_run = true;');
assert_false(script_did_run,
'replaceData() does not trigger execution');
text.deleteData(text.length - 1, 1);
assert_false(script_did_run,
'deleteData() does not trigger execution');
}, "Script execution is never triggered on child mutation");