Bug 1416628 - Wait for the "popupshown" event when opening the Site Identity panel. r=johannh draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 13 Nov 2017 13:27:54 +0000
changeset 697167 c28fb31676eaa260210d5b80ef6676d79ed3bfba
parent 697096 fc194660762d1b92e1679d860a8bf41116d0f54f
child 740035 e5c0b0aa3291d39f63b644a8748e60fe6579a1a7
push id88911
push userpaolo.mozmail@amadzone.org
push dateMon, 13 Nov 2017 13:28:48 +0000
reviewersjohannh
bugs1416628
milestone59.0a1
Bug 1416628 - Wait for the "popupshown" event when opening the Site Identity panel. r=johannh MozReview-Commit-ID: D6JW4h32O5T
browser/base/content/test/siteIdentity/browser_insecureLoginForms.js
--- a/browser/base/content/test/siteIdentity/browser_insecureLoginForms.js
+++ b/browser/base/content/test/siteIdentity/browser_insecureLoginForms.js
@@ -32,17 +32,19 @@ add_task(async function test_simple() {
     await Promise.all([
       BrowserTestUtils.switchTab(gBrowser, tab),
       BrowserTestUtils.browserLoaded(browser),
       // One event is triggered by pageshow and one by DOMFormHasPassword.
       waitForInsecureLoginFormsStateChange(browser, 2),
     ]);
 
     let { gIdentityHandler } = gBrowser.ownerGlobal;
+    let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
     gIdentityHandler._identityBox.click();
+    await promisePanelOpen;
 
     // Messages should be visible when the scheme is HTTP, and invisible when
     // the scheme is HTTPS.
     is(Array.every(document.getElementById("identity-popup-mainView")
                            .querySelectorAll("[when-loginforms=insecure]"),
                    element => !is_hidden(element)),
        expectWarning,
        "The relevant messages should be visible or hidden in the main view.");
@@ -141,17 +143,19 @@ add_task(async function test_ignoring_wi
       content.document.getElementById("link").click();
     });
     let tab = await loaded;
     browser = tab.linkedBrowser;
     await waitForInsecureLoginFormsStateChange(browser, 2);
 
     // Open the identity popup.
     let { gIdentityHandler } = gBrowser.ownerGlobal;
+    let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
     gIdentityHandler._identityBox.click();
+    await promisePanelOpen;
 
     ok(Array.every(document.getElementById("identity-popup-mainView")
                            .querySelectorAll("[when-loginforms=insecure]"),
                    element => is_hidden(element)),
        "All messages should be hidden in the main view.");
 
     let promiseViewShown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "ViewShown");
     document.getElementById("identity-popup-security-expander").click();