blob: 5dd33a2acc3529b1b6da9a3f2ac7ef4ee0880813 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<div id="test-container"></div>
<script src="../../resources/js-test.js"></script>
<script>
description('Adopting a script element must not run the script.');
let testContainer = document.getElementById('test-container');
var didRunScript;
var textChild;
var elementChild;
var commentChild;
function scriptElement(type)
{
didRunScript = false;
let namespaceURI = type == 'html' ? 'http://www.w3.org/1999/xhtml' : 'http://www.w3.org/2000/svg';
let script = document.createElementNS(namespaceURI, 'script');
script.type = 'invalid-type';
script.textContent = 'didRunScript = true';
document.body.appendChild(script);
textChild = document.createTextNode('');
script.appendChild(textChild);
elementChild = document.createElement('div');
script.appendChild(elementChild);
commentChild = document.createComment('');
script.appendChild(commentChild);
script.type = "";
return script;
}
shouldBeFalse('script = scriptElement("html"); script.removeChild(textChild); didRunScript');
shouldBeFalse('script = scriptElement("svg"); script.removeChild(textChild); didRunScript');
shouldBeFalse('script = scriptElement("html"); script.removeChild(elementChild); didRunScript');
shouldBeFalse('script = scriptElement("svg"); script.removeChild(elementChild); didRunScript');
shouldBeFalse('script = scriptElement("html"); script.removeChild(commentChild); didRunScript');
shouldBeFalse('script = scriptElement("svg"); script.removeChild(commentChild); didRunScript');
</script>
</body>
</html>