summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js')
-rw-r--r--toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js91
1 files changed, 57 insertions, 34 deletions
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js b/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js
index 0d96e7cbe..d5d590a3f 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js
@@ -1,40 +1,63 @@
// ----------------------------------------------------------------------------
// Test whether an InstallTrigger.enabled is working
-add_task(function * ()
-{
- let testtab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "bug638292.html");
-
- function* verify(link, button)
- {
- info("Clicking " + link);
-
- let waitForNewTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
-
- yield BrowserTestUtils.synthesizeMouseAtCenter("#" + link, { button: button },
- gBrowser.selectedBrowser);
-
- let newtab = yield waitForNewTabPromise;
-
- yield BrowserTestUtils.browserLoaded(newtab.linkedBrowser);
-
- let result = yield ContentTask.spawn(newtab.linkedBrowser, { }, function* () {
- return (content.document.getElementById("enabled").textContent == "true");
- });
-
- ok(result, "installTrigger for " + link + " should have been enabled");
-
- // Focus the old tab (link3 is opened in the background)
- if (link != "link3") {
- yield BrowserTestUtils.switchTab(gBrowser, testtab);
+function test() {
+ waitForExplicitFinish();
+
+ gBrowser.selectedTab = gBrowser.addTab();
+ gBrowser.selectedBrowser.addEventListener("load", function() {
+ gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
+ waitForFocus(page_loaded, gBrowser.contentWindow);
+ }, true);
+ gBrowser.loadURI(TESTROOT + "bug638292.html");
+}
+
+function check_load(aCallback) {
+ gBrowser.addEventListener("load", function(aEvent) {
+ if (!gBrowser.browsers[2] ||
+ aEvent.target != gBrowser.browsers[2].contentDocument) {
+ // SeaMonkey tabbrowser needs to deal with additional loads.
+ if (navigator.userAgent.match(/ SeaMonkey\//))
+ info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)");
+ else
+ ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)");
+ return;
}
- gBrowser.removeTab(newtab);
- }
- yield* verify("link1", 0);
- yield* verify("link2", 0);
- yield* verify("link3", 1);
-
- gBrowser.removeCurrentTab();
-});
+ gBrowser.removeEventListener("load", arguments.callee, true);
+ // Let the load handler complete
+ executeSoon(function() {
+ var doc = gBrowser.browsers[2].contentDocument;
+ is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled");
+ // Focus the old tab
+ gBrowser.selectedTab = gBrowser.tabs[1];
+ waitForFocus(function() {
+ // Close the new tab
+ gBrowser.removeTab(gBrowser.tabs[2]);
+ aCallback();
+ }, gBrowser.contentWindow);
+ });
+ }, true);
+}
+
+function page_loaded() {
+ var doc = gBrowser.contentDocument;
+ info("Clicking link 1");
+ EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow);
+
+ check_load(function() {
+ info("Clicking link 2");
+ EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow);
+
+ check_load(function() {
+ info("Clicking link 3");
+ EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow);
+
+ check_load(function() {
+ gBrowser.removeCurrentTab();
+ finish();
+ });
+ });
+ });
+}