|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 var target; |
|
6 |
|
7 function test() |
|
8 { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 gBrowser.selectedTab = gBrowser.addTab(); |
|
12 gBrowser.selectedBrowser.addEventListener("load", onLoad, true); |
|
13 } |
|
14 |
|
15 function onLoad(evt) { |
|
16 gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); |
|
17 |
|
18 target = TargetFactory.forTab(gBrowser.selectedTab); |
|
19 |
|
20 is(target.tab, gBrowser.selectedTab, "Target linked to the right tab."); |
|
21 |
|
22 target.once("hidden", onHidden); |
|
23 gBrowser.selectedTab = gBrowser.addTab(); |
|
24 } |
|
25 |
|
26 function onHidden() { |
|
27 ok(true, "Hidden event received"); |
|
28 target.once("visible", onVisible); |
|
29 gBrowser.removeCurrentTab(); |
|
30 } |
|
31 |
|
32 function onVisible() { |
|
33 ok(true, "Visible event received"); |
|
34 target.once("will-navigate", onWillNavigate); |
|
35 gBrowser.contentWindow.location = "data:text/html,test navigation"; |
|
36 } |
|
37 |
|
38 function onWillNavigate(event, request) { |
|
39 ok(true, "will-navigate event received"); |
|
40 // Wait for navigation handling to complete before removing the tab, in order |
|
41 // to avoid triggering assertions. |
|
42 target.once("navigate", executeSoon.bind(null, onNavigate)); |
|
43 } |
|
44 |
|
45 function onNavigate() { |
|
46 ok(true, "navigate event received"); |
|
47 target.once("close", onClose); |
|
48 gBrowser.removeCurrentTab(); |
|
49 } |
|
50 |
|
51 function onClose() { |
|
52 ok(true, "close event received"); |
|
53 |
|
54 target = null; |
|
55 finish(); |
|
56 } |