Bug 1459309 - currentScript should be null when evaluating scripts from shadow DOM, r=peterv

--HG--
extra : rebase_source : 53979237d9d94438966ef470cc9ff80d612ef4ee
This commit is contained in:
Olli Pettay 2018-05-11 20:24:50 +03:00
parent 21590be8b8
commit ae2b960685
3 changed files with 6 additions and 11 deletions

View File

@ -57,7 +57,9 @@ class ScriptLoader final : public nsISupports
: mOldScript(aScriptLoader->mCurrentScript)
, mScriptLoader(aScriptLoader)
{
mScriptLoader->mCurrentScript = aCurrentScript;
nsCOMPtr<nsINode> node = do_QueryInterface(aCurrentScript);
mScriptLoader->mCurrentScript =
node && !node->IsInShadowTree() ? aCurrentScript : nullptr;
}
~AutoCurrentScriptUpdater()

View File

@ -1,8 +0,0 @@
[Document-prototype-currentScript.html]
expected: ERROR
[document.currentScript must not be set to a script element that loads an external script in an open shadow tree]
expected: FAIL
[document.currentScript must not be set to a script element that loads an external script in a closed shadow tree]
expected: FAIL

View File

@ -40,10 +40,11 @@ var testedScriptElement = null;
function executeNextTest()
{
var testCase = asyncScriptTests.shift();
var mode = testCase.mode;
if (!testCase)
return;
var mode = testCase.mode;
testCase.test.step(function () {
testedScriptElement = document.createElement('script');
testedScriptElement.src = 'resources/Document-prototype-currentScript-helper.js';
@ -75,7 +76,7 @@ var asyncScriptTests = [
test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
mode: null, remove: false, expected: function () { return testedScriptElement; }},
{
test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree (2)'),
mode: null, remove: true, expected: function () { return testedScriptElement; }},
{
test: async_test('document.currentScript must not be set to a script element that loads an external script in an open shadow tree'),