|
1 var expected = ["TabOpen", "onStateChange", "onLocationChange", "onLinkIconAvailable"]; |
|
2 var actual = []; |
|
3 var tabIndex = -1; |
|
4 this.__defineGetter__("tab", function () gBrowser.tabs[tabIndex]); |
|
5 |
|
6 function test() { |
|
7 waitForExplicitFinish(); |
|
8 tabIndex = gBrowser.tabs.length; |
|
9 gBrowser.addTabsProgressListener(progressListener); |
|
10 gBrowser.tabContainer.addEventListener("TabOpen", TabOpen, false); |
|
11 gBrowser.addTab("data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>"); |
|
12 } |
|
13 |
|
14 function record(aName) { |
|
15 info("got " + aName); |
|
16 if (actual.indexOf(aName) == -1) |
|
17 actual.push(aName); |
|
18 if (actual.length == expected.length) { |
|
19 is(actual.toString(), expected.toString(), |
|
20 "got events and progress notifications in expected order"); |
|
21 gBrowser.removeTab(tab); |
|
22 gBrowser.removeTabsProgressListener(progressListener); |
|
23 gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen, false); |
|
24 finish(); |
|
25 } |
|
26 } |
|
27 |
|
28 function TabOpen(aEvent) { |
|
29 if (aEvent.target == tab) |
|
30 record(arguments.callee.name); |
|
31 } |
|
32 |
|
33 var progressListener = { |
|
34 onLocationChange: function onLocationChange(aBrowser) { |
|
35 if (aBrowser == tab.linkedBrowser) |
|
36 record(arguments.callee.name); |
|
37 }, |
|
38 onStateChange: function onStateChange(aBrowser) { |
|
39 if (aBrowser == tab.linkedBrowser) |
|
40 record(arguments.callee.name); |
|
41 }, |
|
42 onLinkIconAvailable: function onLinkIconAvailable(aBrowser, aIconURL) { |
|
43 if (aBrowser == tab.linkedBrowser && |
|
44 aIconURL == "about:logo") |
|
45 record(arguments.callee.name); |
|
46 } |
|
47 }; |