From 85e079584d2ace0d68ea4d340a06588aead261a8 Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Thu, 23 Apr 2015 17:02:51 -0700 Subject: [PATCH] Bug 1079554 - Test ignoring UITour messages from pages that aren't visible. r=Unfocused --HG-- extra : rebase_source : 2b872f3c3c9fbe40101753cc386ebaccf9b6f7c9 --- browser/components/uitour/test/browser.ini | 2 + .../uitour/test/browser_backgroundTab.js | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 browser/components/uitour/test/browser_backgroundTab.js diff --git a/browser/components/uitour/test/browser.ini b/browser/components/uitour/test/browser.ini index 9e0a851f0cae..61e88ea1d489 100644 --- a/browser/components/uitour/test/browser.ini +++ b/browser/components/uitour/test/browser.ini @@ -5,6 +5,8 @@ support-files = uitour.html ../UITour-lib.js +[browser_backgroundTab.js] +skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly [browser_no_tabs.js] [browser_UITour.js] skip-if = os == "linux" || e10s # Intermittent failures, bug 951965 diff --git a/browser/components/uitour/test/browser_backgroundTab.js b/browser/components/uitour/test/browser_backgroundTab.js new file mode 100644 index 000000000000..092d1386c2a7 --- /dev/null +++ b/browser/components/uitour/test/browser_backgroundTab.js @@ -0,0 +1,49 @@ +"use strict"; + +let gTestTab; +let gContentAPI; +let gContentWindow; + +Components.utils.import("resource:///modules/UITour.jsm"); + +function test() { + requestLongerTimeout(2); + UITourTest(); +} + +let tests = [ + function test_bg_getConfiguration(done) { + info("getConfiguration is on the allowed list so should work"); + loadForegroundTab().then(() => { + gContentAPI.getConfiguration("availableTargets", (data) => { + ok(data, "Got data from getConfiguration"); + gBrowser.removeCurrentTab(); + done(); + }); + }); + }, + taskify(function* test_bg_showInfo() { + info("showInfo isn't on the allowed action list so should be denied"); + yield loadForegroundTab(); + + yield showInfoPromise("appMenu", "Hello from the backgrund", "Surprise!").then( + () => ok(false, "panel shouldn't have shown from a background tab"), + () => ok(true, "panel wasn't shown from a background tab")); + + gBrowser.removeCurrentTab(); + }), +]; + + +function loadForegroundTab() { + let newTab = gBrowser.addTab("about:blank", {skipAnimation: true}); + gBrowser.selectedTab = newTab; + + return new Promise((resolve) => { + newTab.linkedBrowser.addEventListener("load", function onLoad() { + newTab.linkedBrowser.removeEventListener("load", onLoad, true); + isnot(gBrowser.selectedTab, gTestTab, "Make sure tour tab isn't selected"); + resolve(); + }, true); + }); +}