browser_bug521216.js (1683B)
1 var expected = [ 2 "TabOpen", 3 "onStateChange", 4 "onLocationChange", 5 "onLinkIconAvailable", 6 ]; 7 var actual = []; 8 var tabIndex = -1; 9 this.__defineGetter__("tab", () => gBrowser.tabs[tabIndex]); 10 11 function test() { 12 waitForExplicitFinish(); 13 tabIndex = gBrowser.tabs.length; 14 gBrowser.addTabsProgressListener(progressListener); 15 gBrowser.tabContainer.addEventListener("TabOpen", TabOpen); 16 BrowserTestUtils.addTab( 17 gBrowser, 18 "data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>" 19 ); 20 } 21 22 function recordEvent(aName) { 23 info("got " + aName); 24 if (!actual.includes(aName)) { 25 actual.push(aName); 26 } 27 if (actual.length == expected.length) { 28 is( 29 actual.toString(), 30 expected.toString(), 31 "got events and progress notifications in expected order" 32 ); 33 34 executeSoon( 35 // eslint-disable-next-line no-shadow 36 function (tab) { 37 gBrowser.removeTab(tab); 38 gBrowser.removeTabsProgressListener(progressListener); 39 gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen); 40 finish(); 41 }.bind(null, tab) 42 ); 43 } 44 } 45 46 function TabOpen(aEvent) { 47 if (aEvent.target == tab) { 48 recordEvent("TabOpen"); 49 } 50 } 51 52 var progressListener = { 53 onLocationChange: function onLocationChange(aBrowser) { 54 if (aBrowser == tab.linkedBrowser) { 55 recordEvent("onLocationChange"); 56 } 57 }, 58 onStateChange: function onStateChange(aBrowser) { 59 if (aBrowser == tab.linkedBrowser) { 60 recordEvent("onStateChange"); 61 } 62 }, 63 onLinkIconAvailable: function onLinkIconAvailable(aBrowser) { 64 if (aBrowser == tab.linkedBrowser) { 65 recordEvent("onLinkIconAvailable"); 66 } 67 }, 68 };