Skip to content

Commit

Permalink
Expand noscript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Jan 5, 2020
1 parent dec40c7 commit 4c11581
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions domparsing/DOMParser-parseFromString-html.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
// |expected| should be an object indicating the expected type of node.
function assert_node(actual, expected) {
assert_true(actual instanceof expected.type,
'Node type mismatch: actual = ' + actual.nodeType + ', expected = ' + expected.nodeType);
'Node type mismatch: actual = ' + actual.constructor.name + ', expected = ' + expected.type.name);
if (typeof(expected.id) !== 'undefined')
assert_equals(actual.id, expected.id, expected.idMessage);
if (typeof(expected.nodeValue) !== 'undefined')
assert_equals(actual.nodeValue, expected.nodeValue, expected.nodeValueMessage);
}

var doc;
Expand Down Expand Up @@ -72,10 +70,17 @@
<style>
@import url(/dummy.css)
</style>
<script>x = 8<\/script>
<script>document.x = 8<\/script>
</body></html>`, 'text/html');

assert_not_equals(doc.querySelector('script'), null, 'script must be found');
assert_equals(doc.x, undefined, 'script must not be executed');
assert_equals(doc.x, undefined, 'script must not be executed (1)');
assert_equals(document.x, undefined, 'script must not be executed (2)');
}, 'script is found synchronously even when there is a css import');

test(() => {
const doc = new DOMParser().parseFromString(`<body><noscript><p id="test1">test1<p id="test2">test2</noscript>`, 'text/html');
assert_node(doc.body.firstChild.childNodes[0], { type: HTMLParagraphElement, id: 'test1' });
assert_node(doc.body.firstChild.childNodes[1], { type: HTMLParagraphElement, id: 'test2' });
}, 'must be parsed with scripting disabled, so noscript works');
</script>

0 comments on commit 4c11581

Please sign in to comment.