Commit eb8e9ed6 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Do not execute classic scripts moved between documents

Intent to deprecate and remove:
https://groups.google.com/a/chromium.org/d/topic/blink-dev/KyB2mwOmjrk/discussion

This CL also removes crash tests that require executing scripts
moved between documents.
Code paths related to scripts moved between documents will be
covered by e.g.
https://github.com/web-platform-tests/wpt/pull/5911

Bug: 721914
Change-Id: I6acb7182c4a62accd5e5285adb6a77a2cd891465
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1843508Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704503}
parent eb91af7d
...@@ -141,16 +141,9 @@ void PendingScript::ExecuteScriptBlock(const KURL& document_url) { ...@@ -141,16 +141,9 @@ void PendingScript::ExecuteScriptBlock(const KURL& document_url) {
} }
if (OriginalContextDocument() != context_document) { if (OriginalContextDocument() != context_document) {
if (GetScriptType() == mojom::ScriptType::kModule) { // Do not execute scripts if they are moved between documents.
// Do not execute module scripts if they are moved between documents. Dispose();
Dispose(); return;
return;
}
// TODO(hiroshige): Also do not execute classic scripts.
// https://crbug.com/721914
UseCounter::Count(context_document,
WebFeature::kEvaluateScriptMovedBetweenDocuments);
} }
if (OriginalContextDocument() == context_document && if (OriginalContextDocument() == context_document &&
......
<!DOCTYPE html>
<iframe src=resources/append-child-adopt-node-frame.html></iframe>
<iframe src=resources/append-child-adopt-node-frame.svg></iframe>
<script>
testRunner.waitUntilDone();
testRunner.dumpAsText();
// Don't use js-test.js because this bug is about <script> loading and
// it makes sense to keep this small and easy to debug when regress.
console.log("PASS unless crash.");
var count = document.querySelectorAll("iframe").length;
function done() {
if (--count)
return;
testRunner.notifyDone();
}
</script>
<!DOCTYPE html>
<script>
testRunner.waitUntilDone();
testRunner.dumpAsText();
// Don't use js-test.js because this bug is about a failing load of an async
// <script> of a frame document being moved to its parent document.
// Hence it makes sense to keep this small and easy to debug when regress.
console.log("PASS unless crash.");
var count = 2;
function done() {
if (--count)
return;
testRunner.notifyDone();
}
</script>
<iframe src=resources/append-child-adopt-node-error-frame.html></iframe>
<iframe src=resources/append-child-adopt-node-error-frame.svg></iframe>
<!DOCTYPE html>
<html>
<body>
<script>
function init()
{
var script = document.createElement("script");
script.src = "does-not-exist.js";
script.onerror = function () { window.top.done(); };
document.body.appendChild(script);
var contextDoc = window.top.document.implementation.createDocument("", null);
contextDoc.adoptNode(document.documentElement);
}
init();
</script>
</body>
</html>
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
<script>
function init()
{
var script = document.createElementNS("http://www.w3.org/2000/svg", "script");
script.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "does-not-exist.js");
script.onerror = function() { window.top.done(); };
document.documentElement.appendChild(script);
var contextDoc = window.top.document.implementation.createDocument("", null);
contextDoc.adoptNode(document.documentElement);
}
init();
</script>
</svg>
<!DOCTYPE html>
<html>
<body>
<script>
function init()
{
var script = document.createElement("script");
script.src = "should-load.js";
document.body.appendChild(script);
var contextDoc = window.top.document.implementation.createDocument("", null);
contextDoc.adoptNode(document.documentElement);
}
init();
</script>
</body>
</html>
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
<script>
function init()
{
var script = document.createElementNS("http://www.w3.org/2000/svg", "script");
script.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "should-load.js");
document.documentElement.appendChild(script);
var contextDoc = window.top.document.implementation.createDocument("", null);
contextDoc.adoptNode(document.documentElement);
}
init();
</script>
</svg>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment