toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // ----------------------------------------------------------------------------
michael@0 2 // Test whether an InstallTrigger.enabled is working
michael@0 3 function test() {
michael@0 4 waitForExplicitFinish();
michael@0 5
michael@0 6 gBrowser.selectedTab = gBrowser.addTab();
michael@0 7 gBrowser.selectedBrowser.addEventListener("load", function() {
michael@0 8 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 9 waitForFocus(page_loaded, gBrowser.contentWindow);
michael@0 10 }, true);
michael@0 11 gBrowser.loadURI(TESTROOT + "bug638292.html");
michael@0 12 }
michael@0 13
michael@0 14 function check_load(aCallback) {
michael@0 15 gBrowser.addEventListener("load", function(aEvent) {
michael@0 16 if (!gBrowser.browsers[2] ||
michael@0 17 aEvent.target != gBrowser.browsers[2].contentDocument) {
michael@0 18 // SeaMonkey tabbrowser needs to deal with additional loads.
michael@0 19 if (navigator.userAgent.match(/ SeaMonkey\//))
michael@0 20 info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)");
michael@0 21 else
michael@0 22 ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)");
michael@0 23 return;
michael@0 24 }
michael@0 25
michael@0 26 gBrowser.removeEventListener("load", arguments.callee, true);
michael@0 27
michael@0 28 // Let the load handler complete
michael@0 29 executeSoon(function() {
michael@0 30 var doc = gBrowser.browsers[2].contentDocument;
michael@0 31 is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled");
michael@0 32
michael@0 33 // Focus the old tab
michael@0 34 gBrowser.selectedTab = gBrowser.tabs[1];
michael@0 35 waitForFocus(function() {
michael@0 36 // Close the new tab
michael@0 37 gBrowser.removeTab(gBrowser.tabs[2]);
michael@0 38 aCallback();
michael@0 39 }, gBrowser.contentWindow);
michael@0 40 });
michael@0 41 }, true);
michael@0 42 }
michael@0 43
michael@0 44 function page_loaded() {
michael@0 45 var doc = gBrowser.contentDocument;
michael@0 46 info("Clicking link 1");
michael@0 47 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow);
michael@0 48
michael@0 49 check_load(function() {
michael@0 50 info("Clicking link 2");
michael@0 51 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow);
michael@0 52
michael@0 53 check_load(function() {
michael@0 54 info("Clicking link 3");
michael@0 55 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow);
michael@0 56
michael@0 57 check_load(function() {
michael@0 58 gBrowser.removeCurrentTab();
michael@0 59 finish();
michael@0 60 });
michael@0 61 });
michael@0 62 });
michael@0 63 }

mercurial