1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window id="690056Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="600"
height="600"
onload="setTimeout(nextTest, 0);"
title="bug 6500056 test">
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
<script type="application/javascript" src="docshell_helpers.js" />
<script type="application/javascript"><![CDATA[
var tests = testIterator();
function nextTest() {
tests.next();
}
// Makes sure that we fire the visibilitychange events
function* testIterator() {
// Enable bfcache
enableBFCache(8);
// Load something for a start
doPageNavigation({
uri: 'data:text/html,<title>initial load</title>',
onNavComplete: nextTest
});
yield undefined;
// Now load a new page
doPageNavigation({
uri: 'data:text/html,<title>new load</title>',
eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
expectedEvents: [ { type: "pagehide",
title: "initial load",
persisted: true },
{ type: "visibilitychange",
title: "initial load",
visibilityState: "hidden",
hidden: true },
// No visibilitychange events fired for initial pageload
{ type: "pageshow",
title: "new load",
persisted: false }, // false on initial load
],
onNavComplete: nextTest
});
yield undefined;
// Now go back
doPageNavigation({
back: true,
eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
expectedEvents: [ { type: "pagehide",
title: "new load",
persisted: true },
{ type: "visibilitychange",
title: "new load",
visibilityState: "hidden",
hidden: true },
{ type: "visibilitychange",
title: "initial load",
visibilityState: "visible",
hidden: false },
{ type: "pageshow",
title: "initial load",
persisted: true },
],
onNavComplete: nextTest
});
yield undefined;
// And forward
doPageNavigation({
forward: true,
eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
expectedEvents: [ { type: "pagehide",
title: "initial load",
persisted: true },
{ type: "visibilitychange",
title: "initial load",
visibilityState: "hidden",
hidden: true },
{ type: "visibilitychange",
title: "new load",
visibilityState: "visible",
hidden: false },
{ type: "pageshow",
title: "new load",
persisted: true },
],
onNavComplete: nextTest
});
yield undefined;
waitForPageEvents({
eventsToListenFor: [ "visibilitychange" ],
expectedEvents: [ { type: "visibilitychange",
title: "new load",
visibilityState: "hidden",
hidden: true },
],
onNavComplete: nextTest
});
// Now flip our docshell to not active
TestWindow.getBrowser().docShellIsActive = false;
yield undefined;
// And navigate back; there should be no visibility state transitions
doPageNavigation({
back: true,
eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
expectedEvents: [ { type: "pagehide",
title: "new load",
persisted: true },
{ type: "pageshow",
title: "initial load",
persisted: true },
],
unexpectedEvents: [ "visibilitychange" ],
onNavComplete: nextTest
});
yield undefined;
waitForPageEvents({
eventsToListenFor: [ "visibilitychange" ],
expectedEvents: [ { type: "visibilitychange",
title: "initial load",
visibilityState: "visible",
hidden: false },
],
onNavComplete: nextTest
});
// Now set the docshell active again
TestWindow.getBrowser().docShellIsActive = true;
yield undefined;
// And forward
doPageNavigation({
forward: true,
eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
expectedEvents: [ { type: "pagehide",
title: "initial load",
persisted: true },
{ type: "visibilitychange",
title: "initial load",
visibilityState: "hidden",
hidden: true },
{ type: "visibilitychange",
title: "new load",
visibilityState: "visible",
hidden: false },
{ type: "pageshow",
title: "new load",
persisted: true },
],
onNavComplete: nextTest
});
yield undefined;
// Tell the framework the test is finished.
finish();
}
]]></script>
<browser type="content" primary="true" flex="1" id="content" remote="true" maychangeremoteness="true" />
</window>
|