<!DOCTYPE html>
<html>
<body>
<div>
<script>
parent.document.body.appendChild(document.querySelector("div"));
</script>
<script>
// By the time #prepare-a-script is called, this script will be inserted into
// the outer document. At this time, the script's parser document and
// preparation-time document are different, and as per #prepare-a-script step
// 12, the script will not be executed.
alert('should be outer: ' + document.URL.match(/parser.*/));
</script>
</div>
<script>
alert('should be inner: ' + document.URL.match(/parser.*/));
</script>
</body>
</html>