WIP draft
authorJay Lim <jay@imjching.com>
Thu, 06 Sep 2018 23:40:59 -0400
changeset 1689360 966a619fed9d
parent 1686559 7986ad89f328
child 1689361 694d5779084f
child 1689679 a2d3fa8a3710
child 1695844 3967b3cd2427
child 1696081 7836a0ac89a6
push id297218
push userjay@imjching.com
push dateFri, 07 Sep 2018 03:42:06 +0000
treeherdertry@694d5779084f [default view] [failures only]
milestone64.0a1
WIP
accessible/tests/browser/general/browser_test_doc_creation.js
browser/base/content/test/general/browser_e10s_about_process.js
js/xpconnect/loader/ScriptCacheActors.cpp
--- a/accessible/tests/browser/general/browser_test_doc_creation.js
+++ b/accessible/tests/browser/general/browser_test_doc_creation.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
+
 "use strict";
 
 const tab1URL = `data:text/html,
   <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
       <meta charset="utf-8"/>
       <title>First tab to be loaded</title>
     </head>
@@ -21,20 +23,27 @@ const tab2URL = `data:text/html,
       <meta charset="utf-8"/>
       <title>Second tab to be loaded</title>
     </head>
     <body>
       <butotn>JUST A BUTTON</butotn>
     </body>
   </html>`;
 
+const PRIVILEGED_SP_FINISHED_TOPIC = "privileged-sp-finished";
+
 // Checking that, if there are open windows before accessibility was started,
 // root accessibles for open windows are created so that all root accessibles
 // are stored in application accessible children array.
 add_task(async function testDocumentCreation() {
+  let promiseEvent = new Promise(resolve => Services.obs.addObserver(function obs(subject) {
+    Services.obs.removeObserver(obs, PRIVILEGED_SP_FINISHED_TOPIC);
+    resolve();
+  }, PRIVILEGED_SP_FINISHED_TOPIC));
+
   let tab1 = await openNewTab(tab1URL);
   let tab2 = await openNewTab(tab2URL);
   let accService = await initAccessibilityService(); // eslint-disable-line no-unused-vars
 
   info("Verifying that each tab content document is in accessible cache.");
   for (const browser of [...gBrowser.browsers]) {
     await ContentTask.spawn(browser, null, async () => {
       let accServiceContent =
@@ -43,11 +52,13 @@ add_task(async function testDocumentCrea
       ok(!!accServiceContent.getAccessibleFromCache(content.document),
         "Document accessible is in cache.");
     });
   }
 
   BrowserTestUtils.removeTab(tab1);
   BrowserTestUtils.removeTab(tab2);
 
+  await promiseEvent;
+
   accService = null;
   await shutdownAccessibilityService();
 });
--- a/browser/base/content/test/general/browser_e10s_about_process.js
+++ b/browser/base/content/test/general/browser_e10s_about_process.js
@@ -128,29 +128,29 @@ add_task(async function test_any() {
 add_task(async function test_remote() {
   test_url("about:" + MUSTREMOTE.path, false, true, false);
 });
 
 add_task(async function test_privileged_remote_true() {
   await SpecialPowers.pushPrefEnv({
     set: [
       ["browser.tabs.remote.separatePrivilegedContentProcess", true],
-    ]
+    ],
   });
 
   // This shouldn't be taken literally. We will always use the privileged
   // content type if the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag is enabled and
   // the pref is turned on.
   test_url("about:" + CANPRIVILEGEDREMOTE.path, false, false, true);
 });
 
 add_task(async function test_privileged_remote_false() {
   await SpecialPowers.pushPrefEnv({
     set: [
       ["browser.tabs.remote.separatePrivilegedContentProcess", false],
-    ]
+    ],
   });
 
   // This shouldn't be taken literally. We will always use the privileged
   // content type if the URI_CAN_LOAD_IN_PRIVILEGED_CHILD flag is enabled and
   // the pref is turned on.
   test_url("about:" + CANPRIVILEGEDREMOTE.path, false, true, false);
 });
--- a/js/xpconnect/loader/ScriptCacheActors.cpp
+++ b/js/xpconnect/loader/ScriptCacheActors.cpp
@@ -84,16 +84,21 @@ ScriptCacheParent::Recv__delete__(nsTArr
     auto processType = ScriptPreloader::GetChildProcessType(parent->GetRemoteType());
 
     auto& cache = ScriptPreloader::GetChildSingleton();
     for (auto& script : scripts) {
         cache.NoteScript(script.url(), script.cachePath(), processType,
                          std::move(script.xdrData()), script.loadTime());
     }
 
+    if (processType == ProcessType::Privileged) {
+        nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+        obs->NotifyObservers(nullptr, "privileged-sp-finished", nullptr);
+    }
+
     return IPC_OK();
 }
 
 void
 ScriptCacheParent::ActorDestroy(ActorDestroyReason aWhy)
 {}
 
 } // namespace loader