Bug 1549261 - Improved reliability of full-screen addon install block test. r=johannh
authorPaul Zuehlcke <pzuhlcke@mozilla.com>
Thu, 09 May 2019 19:59:03 +0000
changeset 532123 8784b7d0fcbf5c7f11af9da3cf3dd27662e8a429
parent 532122 5e3d6e5df827b23b963386002c4ba2c6fba87fae
child 532124 e4eab914f8217b7eb04a311ad6f33bd4c7aca2ab
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1549261
milestone68.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 1549261 - Improved reliability of full-screen addon install block test. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D30471
toolkit/mozapps/extensions/test/xpinstall/browser_block_fullscreen_prompt.js
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_block_fullscreen_prompt.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_block_fullscreen_prompt.js
@@ -32,25 +32,16 @@ const ADDON_EVENTS = [
 function waitForNextAddonEvent() {
   return Promise.race(ADDON_EVENTS.map( async (eventStr) => {
     await TestUtils.topicObserved(eventStr);
     return eventStr;
   }));
 }
 
 /**
- * Check if an addon installation prompt is visible
- */
-function addonPromptVisible(browser) {
-  if (!PopupNotifications.isPanelOpen) return false;
-  if (ADDON_EVENTS.some(id => PopupNotifications.getNotification(id, browser) != null)) return true;
-  return false;
-}
-
-/**
  * Spawns content task in browser to enter / leave fullscreen
  * @param browser - Browser to use for JS fullscreen requests
  * @param {Boolean} fullscreenState - true to enter fullscreen, false to leave
  */
 function changeFullscreen(browser, fullscreenState) {
   return ContentTask.spawn(browser, fullscreenState, async function(state) {
     if (state) {
       await content.document.body.requestFullscreen();
@@ -70,40 +61,48 @@ add_task(async function testFullscreenBl
     BrowserTestUtils.loadURI(browser, ADDON_FILE_URI);
 
     // Wait for addon manager event and check if installation has been blocked
     let eventStr = await waitForNextAddonEvent();
 
     Assert.equal(eventStr, "addon-install-blocked-silent", "Addon installation was blocked");
 
     // Test if addon installation prompt has been blocked
-    Assert.ok(!addonPromptVisible(), "Addon installation prompt not opened");
+    let panelOpened;
+    try {
+      panelOpened = await TestUtils.waitForCondition(() => PopupNotifications.isPanelOpen, 100, 10);
+    } catch (ex) {
+      panelOpened = false;
+    }
+    is(panelOpened, false, "Addon installation prompt not opened");
 
-    await changeFullscreen(browser, false);
+    window.fullScreen = false;
   });
 });
 
 
-
 // This tests if the addon install prompt is closed when entering fullscreen
 add_task(async function testFullscreenCloseAddonInstallPrompt() {
   // Open example.com
   await BrowserTestUtils.withNewTab("http://example.com", async function(browser) {
     // Navigate to addon file path
     BrowserTestUtils.loadURI(browser, ADDON_FILE_URI);
 
     // Test if addon installation started
     let eventStr = await waitForNextAddonEvent();
 
     Assert.ok(eventStr === "addon-install-started", "Addon installation started");
 
     // Test if addon installation prompt is visible
-    Assert.ok(addonPromptVisible(), "Addon installation prompt opened");
+    await TestUtils.waitForCondition(() => PopupNotifications.isPanelOpen, "Waiting for addon installation prompt to open");
+    Assert.ok(ADDON_EVENTS.some(id => PopupNotifications.getNotification(id, browser) != null), "Opened notification is installation prompt");
+
+    // Test for addon installation prompt close
+    let panelClosePromise = TestUtils.waitForCondition(() => !PopupNotifications.isPanelOpen, "Waiting for addon installation prompt to close");
 
     // Switch to fullscreen
     await changeFullscreen(browser, true);
 
-    // Test if addon installation prompt has been closed
-    Assert.ok(!addonPromptVisible(), "Addon installation prompt closed for fullscreen");
+    await panelClosePromise;
 
-    await changeFullscreen(browser, false);
+    window.fullScreen = false;
   });
 });