Bug 1093028 - Imports should block DOMContentLoaded of the parent. r=mrbkap
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Thu, 06 Nov 2014 13:41:19 +0100
changeset 214388 7ebb820f3cca0d8c11c56f54c9e5e4a26b55cdec
parent 214387 b24744aa87da29de3cb944720c5931a5ba4e9ed0
child 214389 e25127d1ad196c638af12c5dfbca9bb43babe939
push id27780
push userkwierso@gmail.com
push dateFri, 07 Nov 2014 02:25:05 +0000
treeherdermozilla-central@e6d47abb6a7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1093028
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1093028 - Imports should block DOMContentLoaded of the parent. r=mrbkap
dom/base/ImportManager.cpp
dom/html/test/imports/file_blocking_DOMContentLoaded_A.html
dom/html/test/imports/file_blocking_DOMContentLoaded_B.html
dom/html/test/imports/file_blocking_DOMContentLoaded_C.html
dom/html/test/imports/file_blocking_DOMContentLoaded_D.html
dom/html/test/imports/mochitest.ini
dom/html/test/imports/test_blocking_DOMContentLoaded.html
testing/web-platform/meta/custom-elements/creating-and-passing-registries/share-registry-import-document.html.ini
--- a/dom/base/ImportManager.cpp
+++ b/dom/base/ImportManager.cpp
@@ -144,16 +144,17 @@ ImportLoader::Updater::UpdateMainReferre
   // This new link means we have to execute our scripts sooner...
   // Let's make sure that unblocking a loader does not trigger a script execution.
   // So we start with placing the new blockers and only then will we remove any
   // blockers.
   if (mLoader->IsBlocking()) {
     // Our import parent is changed, let's block the new one and later unblock
     // the old one.
     newMainReferrer->OwnerDoc()->ScriptLoader()->AddExecuteBlocker();
+    newMainReferrer->OwnerDoc()->BlockDOMContentLoaded();
   }
 
   if (mLoader->mDocument) {
     // Our nearest predecessor has changed. So let's add the ScriptLoader to the
     // new one if there is any. And remove it from the old one.
     nsRefPtr<ImportManager> manager = mLoader->Manager();
     nsScriptLoader* loader = mLoader->mDocument->ScriptLoader();
     ImportLoader*& pred = mLoader->mBlockingPredecessor;
@@ -163,16 +164,17 @@ ImportLoader::Updater::UpdateMainReferre
         newPred->AddBlockedScriptLoader(loader);
       }
       pred->RemoveBlockedScriptLoader(loader);
     }
   }
 
   if (mLoader->IsBlocking()) {
     mLoader->mImportParent->ScriptLoader()->RemoveExecuteBlocker();
+    mLoader->mImportParent->UnblockDOMContentLoaded();
   }
 
   // Finally update mMainReferrer to point to the newly added link.
   mLoader->mMainReferrer = aNewIdx;
   mLoader->mImportParent = newMainReferrer->OwnerDoc();
 }
 
 nsINode*
@@ -295,24 +297,26 @@ ImportLoader::ImportLoader(nsIURI* aURI,
 {
 }
 
 void
 ImportLoader::BlockScripts()
 {
   MOZ_ASSERT(!mBlockingScripts);
   mImportParent->ScriptLoader()->AddExecuteBlocker();
+  mImportParent->BlockDOMContentLoaded();
   mBlockingScripts = true;
 }
 
 void
 ImportLoader::UnblockScripts()
 {
   MOZ_ASSERT(mBlockingScripts);
   mImportParent->ScriptLoader()->RemoveExecuteBlocker();
+  mImportParent->UnblockDOMContentLoaded();
   for (uint32_t i = 0; i < mBlockedScriptLoaders.Length(); i++) {
     mBlockedScriptLoaders[i]->RemoveExecuteBlocker();
   }
   mBlockedScriptLoaders.Clear();
   mBlockingScripts = false;
 }
 
 void
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_A.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("AS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_B.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_B.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("BS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_C.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_C.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("CS0");
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_D.html" onload="loaded()" onerror="failed()"></link>
+</head>
+<body>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/file_blocking_DOMContentLoaded_D.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+  <script>
+    order.push("DS0");
+  </script>
+</head>
+<body>
+</body>
+</html>
--- a/dom/html/test/imports/mochitest.ini
+++ b/dom/html/test/imports/mochitest.ini
@@ -28,19 +28,25 @@ support-files =
   file_cycle_3_C.html
   file_cycle_4_A.html
   file_cycle_4_B.html
   file_cycle_4_C.html
   file_cycle_4_D.html
   file_cycle_4_E.html
   file_encoding.html
   file_simple_import.html
+  file_blocking_DOMContentLoaded_A.html
+  file_blocking_DOMContentLoaded_B.html
+  file_blocking_DOMContentLoaded_C.html
+  file_blocking_DOMContentLoaded_D.html
 
 [test_cycle_1.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_2.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_3.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_cycle_4.html]
 skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
+[test_blocking_DOMContentLoaded.html]
+skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
 [test_encoding.html]
 [test_defaultView.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/imports/test_blocking_DOMContentLoaded.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1093028
+-->
+<head>
+  <title>Test for Bug 1093028</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+</head>
+<body>
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1093028">Mozilla Bug 1093028</a>
+  <script type="text/javascript">
+    SimpleTest.waitForExplicitFinish();
+    var counter = 0;
+    var fcounter = 0;
+    var order = [];
+    function loaded() {
+      counter++;
+    }
+    function failed() {
+      fcounter++;
+    }
+  </script>
+  <link rel="import" href="file_blocking_DOMContentLoaded_A.html" onload="loaded()" onerror="failed()"></link>
+  <script type="text/javascript">
+    is(counter, 4, "Imports are loaded");
+    is(fcounter, 0, "No error in imports");
+    var expected = ["AS0","BS0","CS0","DS0"];
+    for (i in expected)
+      is(order[i], expected[i], "import " + i + " should be " + expected[i]);
+    SimpleTest.finish();
+  </script>
+</body>
+</html>
--- a/testing/web-platform/meta/custom-elements/creating-and-passing-registries/share-registry-import-document.html.ini
+++ b/testing/web-platform/meta/custom-elements/creating-and-passing-registries/share-registry-import-document.html.ini
@@ -1,17 +1,18 @@
 [share-registry-import-document.html]
   type: testharness
+  expected: TIMEOUT
   [Registry of the import should share master document registry]
     expected: TIMEOUT
 
   [Registry of the master document should be shared with imported document\'s registry]
     expected: TIMEOUT
 
-  [Registry of the master document should be shared with imported document. Import is asynchronous]
-    expected: FAIL
+  [Registry of the imported document should be shared with master document. Import is asynchronous]
+    expected: TIMEOUT
 
-  [Registry of the imported document should be shared with master document. Import is syncronous]
-    expected: FAIL
+  [Registry of the master document should be shared with imported document. Import is asynchronous]
+    expected: TIMEOUT
 
   [Registry of the master document should be shared with imported document. Import is syncronous]
     expected: FAIL