Bug 1265194 - Fix test bustage.
authorJustin Dolske <dolske@mozilla.com>
Sun, 24 Apr 2016 11:01:01 -0700
changeset 332393 13cbfc180fe6ea8ba7ad99eb5da126e1b5b7fdf2
parent 332392 7f54642144c27146b981a6d4c632396c7cd1d6c8
child 332394 ecdcf1026a3ba4bcd21304627a0eceba8f285ba0
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1265194
milestone48.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 1265194 - Fix test bustage.
toolkit/components/prompts/test/prompt_common.js
toolkit/components/prompts/test/test_bug625187.html
--- a/toolkit/components/prompts/test/prompt_common.js
+++ b/toolkit/components/prompts/test/prompt_common.js
@@ -1,27 +1,38 @@
 const Ci = SpecialPowers.Ci;
 const Cc = SpecialPowers.Cc;
 ok(Ci != null, "Access Ci");
 ok(Cc != null, "Access Cc");
 
+function hasTabModalPrompts() {
+  var prefName = "prompts.tab_modal.enabled";
+  var Services = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").Services;
+  return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
+         Services.prefs.getBoolPref(prefName);
+}
+var isTabModal = hasTabModalPrompts();
 var isSelectDialog = false;
-var isTabModal = false;
-if (SpecialPowers.getBoolPref("prompts.tab_modal.enabled")) {
-    isTabModal = true;
-}
-
 var isOSX = ("nsILocalFileMac" in SpecialPowers.Ci);
 var isLinux = ("@mozilla.org/gnome-gconf-service;1" in SpecialPowers.Cc);
 var isE10S = SpecialPowers.Services.appinfo.processType == 2;
 
 
 var gChromeScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("chromeScript.js"));
 SimpleTest.registerCleanupFunction(() => gChromeScript.destroy());
 
+function onloadPromiseFor(id) {
+  var iframe = document.getElementById(id);
+  return new Promise(resolve => {
+    iframe.addEventListener("load", function onload(e) {
+      iframe.removeEventListener("load", onload);
+      resolve(true);
+    });
+  });
+}
 
 function handlePrompt() {
   return new Promise(resolve => {
     gChromeScript.addMessageListener("promptHandled", function handled(msg) {
       gChromeScript.removeMessageListener("promptHandled", handled);
       checkPromptState(msg.promptState, state);
       resolve(true);
     });
--- a/toolkit/components/prompts/test/test_bug625187.html
+++ b/toolkit/components/prompts/test/test_bug625187.html
@@ -22,24 +22,32 @@
 
 <iframe id="iframe_diff_origin" src="http://example.com/tests/toolkit/components/prompts/test/bug625187_iframe.html"></iframe>
 
 <iframe id="iframe_same_origin" src="bug625187_iframe.html"></iframe>
 
 <pre id="test"></pre>
 
 <script class="testbody" type="text/javascript">
+var iframe1Loaded = onloadPromiseFor("iframe_diff_origin");
+var iframe2Loaded = onloadPromiseFor("iframe_same_origin");
+
 add_task(function* runTest()
 {
   // This test depends on tab modal prompts being enabled.
   if (!isTabModal) {
     todo(false, "Test disabled when tab modal prompts are not enabled.");
     return;
   }
 
+  info("Ensuring iframe1 has loaded...");
+  yield iframe1Loaded;
+  info("Ensuring iframe2 has loaded...");
+  yield iframe2Loaded;
+
   state = {
     msg         : "hello world",
     iconClass   : "alert-icon",
     titleHidden : true,
     textHidden  : true,
     passHidden  : true,
     checkHidden : true,
     textValue   : "",