diff --git a/browser/base/content/test/trackingUI/browser_trackingUI_animation_2.js b/browser/base/content/test/trackingUI/browser_trackingUI_animation_2.js index 54fff9180396..510e3c44d10c 100644 --- a/browser/base/content/test/trackingUI/browser_trackingUI_animation_2.js +++ b/browser/base/content/test/trackingUI/browser_trackingUI_animation_2.js @@ -1,4 +1,3 @@ -/* eslint-disable mozilla/no-arbitrary-setTimeout */ /* * Test that the Content Blocking icon is properly animated in the identity * block when loading tabs and switching between tabs. @@ -31,7 +30,7 @@ function waitForSecurityChange(tabbrowser, numChanges = 1) { info("Received onSecurityChange event " + n + " of " + numChanges); if (n >= numChanges) { tabbrowser.removeProgressListener(listener); - resolve(n); + resolve(); } }, }; @@ -86,7 +85,7 @@ async function testTrackingProtectionAnimation(tabbrowser) { ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating"); info("Reload tracking cookies tab"); - securityChanged = waitForSecurityChange(tabbrowser, 3); + securityChanged = waitForSecurityChange(tabbrowser, 4); tabbrowser.reload(); await securityChanged; @@ -95,7 +94,7 @@ async function testTrackingProtectionAnimation(tabbrowser) { await BrowserTestUtils.waitForEvent(ContentBlocking.animatedIcon, "animationend"); info("Reload tracking tab"); - securityChanged = waitForSecurityChange(tabbrowser, 4); + securityChanged = waitForSecurityChange(tabbrowser, 5); tabbrowser.selectedTab = trackingTab; tabbrowser.reload(); await securityChanged; @@ -105,27 +104,23 @@ async function testTrackingProtectionAnimation(tabbrowser) { await BrowserTestUtils.waitForEvent(ContentBlocking.animatedIcon, "animationend"); info("Inject tracking cookie inside tracking tab"); - securityChanged = waitForSecurityChange(tabbrowser); - let timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); + securityChanged = waitForSecurityChange(tabbrowser, 2); await ContentTask.spawn(tabbrowser.selectedBrowser, {}, function() { content.postMessage("cookie", "*"); }); - let result = await Promise.race([securityChanged, timeoutPromise]); - is(result, undefined, "No securityChange events should be received"); + await securityChanged; ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active"); ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating"); info("Inject tracking element inside tracking tab"); securityChanged = waitForSecurityChange(tabbrowser); - timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); await ContentTask.spawn(tabbrowser.selectedBrowser, {}, function() { content.postMessage("tracking", "*"); }); - result = await Promise.race([securityChanged, timeoutPromise]); - is(result, undefined, "No securityChange events should be received"); + await securityChanged; ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active"); ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating"); @@ -133,27 +128,23 @@ async function testTrackingProtectionAnimation(tabbrowser) { tabbrowser.selectedTab = trackingCookiesTab; info("Inject tracking cookie inside tracking cookies tab"); - securityChanged = waitForSecurityChange(tabbrowser); - timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); + securityChanged = waitForSecurityChange(tabbrowser, 2); await ContentTask.spawn(tabbrowser.selectedBrowser, {}, function() { content.postMessage("cookie", "*"); }); - result = await Promise.race([securityChanged, timeoutPromise]); - is(result, undefined, "No securityChange events should be received"); + await securityChanged; ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active"); ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating"); info("Inject tracking element inside tracking cookies tab"); - securityChanged = waitForSecurityChange(tabbrowser); - timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); + securityChanged = waitForSecurityChange(tabbrowser, 2); await ContentTask.spawn(tabbrowser.selectedBrowser, {}, function() { content.postMessage("tracking", "*"); }); - result = await Promise.race([securityChanged, timeoutPromise]); - is(result, undefined, "No securityChange events should be received"); + await securityChanged; ok(ContentBlocking.iconBox.hasAttribute("active"), "iconBox active"); ok(!ContentBlocking.iconBox.hasAttribute("animate"), "iconBox not animating"); diff --git a/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js b/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js index 57e544e9d36f..de64e27f246b 100644 --- a/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js +++ b/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js @@ -1,4 +1,3 @@ -/* eslint-disable mozilla/no-arbitrary-setTimeout */ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ @@ -28,7 +27,7 @@ function waitForSecurityChange(counter) { onSecurityChange: (webProgress, request, oldState, state) => { if (--counter == 0) { gBrowser.removeProgressListener(webProgressListener); - resolve(counter); + resolve(); } }, onProgressChange: () => {}, @@ -68,15 +67,13 @@ async function assertSitesListed(blocked) { ok(true, "Main view was shown"); - let change = waitForSecurityChange(1); - let timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); + let change = waitForSecurityChange(2); await ContentTask.spawn(browser, {}, function() { content.postMessage("more-tracking", "*"); }); - let result = await Promise.race([change, timeoutPromise]); - is(result, undefined, "No securityChange events should be received"); + await change; viewShown = BrowserTestUtils.waitForEvent(trackersView, "ViewShown"); categoryItem.click(); diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 07b12491e3f5..a54c3b9cb595 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5394,11 +5394,6 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState, state &= ~aState; } - if (state == oldState) { - // Avoid dispatching repeated notifications when nothing has changed - return; - } - eventSink->OnSecurityChange(aChannel, oldState, state, doc->GetContentBlockingLog()); }