blob: e148d33fb672df7390ecd674ba97158a571eba91 [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 doc;
var didRunScript;
var div;
function runTest(createScriptElement)
{
didRunScript = false;
div = document.createElement('div');
let iframe = document.createElement('iframe');
testContainer.appendChild(iframe);
doc = iframe.contentDocument;
let script = createScriptElement(doc);
script.type = 'invalid-type';
script.textContent = 'parent.didRunScript = true; document.body.appendChild(parent.div)';
script.appendChild(div);
doc.body.appendChild(script);
script.type = '';
document.adoptNode(div);
testContainer.innerHTML = '';
shouldBeFalse('didRunScript');
shouldNotBe('div.parentNode', 'doc.body');
shouldBe('div.parentNode', 'null');
shouldBe('div.ownerDocument', 'document');
}
debug('Testing HTMLScriptElement');
runTest((doc) => doc.createElement('script'));
debug('');
debug('Testing SVGScriptElement');
runTest((doc) => doc.createElementNS('http://www.w3.org/2000/svg', 'script'));
</script>
</body>
</html>