Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 733a2fe

Browse files
author
Gabriel Schulhof
committed
Pagecontainer: Test event sequence during page load failure
1 parent 7aef437 commit 733a2fe

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

tests/integration/pagecontainer/page-event-sequence-tests.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<div data-role="header"><h1>Start page</h1></div>
3434
<div class="ui-content">
3535
<a href="other-page.html" id="go-to-other-page">Go to other page</a>
36+
<a href="page-does-not-exist.html" id="go-to-nonexistent-page">Go to non-existent page</a>
3637
</div>
3738
</div>
3839
</body>

tests/integration/pagecontainer/page_event_sequence_core.js

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var eventSequence,
77
"pagebeforechange",
88
"pagebeforeload",
99
"pageload",
10+
"pageloadfailed",
1011
"pagebeforehide",
1112
"pagebeforeshow",
1213
"pagehide",
@@ -17,6 +18,7 @@ var eventSequence,
1718
"pagecontainerbeforechange",
1819
"pagecontainerbeforeload",
1920
"pagecontainerload",
21+
"pagecontainerloadfailed",
2022
"pagebeforecreate",
2123
"pagecreate",
2224
"pageinit",
@@ -60,12 +62,19 @@ module( "Page event sequence tests", {
6062
}
6163
});
6264

65+
function makeOtherPageUrl( filename ) {
66+
var parsedUrl = $.mobile.path.parseLocation();
67+
68+
return $.mobile.path.getLocation( $.extend( parsedUrl, {
69+
filename: filename,
70+
pathname: parsedUrl.directory + filename
71+
}));
72+
}
73+
6374
asyncTest( "Event sequence during navigation to another page", function() {
64-
var parsedUrl = $.mobile.path.parseLocation(),
65-
otherPageUrl = $.mobile.path.getLocation( $.extend( parsedUrl, {
66-
filename: "other-page.html",
67-
pathname: parsedUrl.directory + "other-page.html"
68-
})),
75+
expect( 1 );
76+
77+
var otherPageUrl = makeOtherPageUrl( "other-page.html" ),
6978
expectedEventSequence = [
7079

7180
// Deprecated as of 1.4.0
@@ -166,7 +175,54 @@ asyncTest( "Event sequence during navigation to another page", function() {
166175
$( ":mobile-pagecontainer" ).pagecontainer( "back" );
167176
},
168177
function() {
169-
deepEqual( true, true, "Works" );
178+
start();
179+
}
180+
]);
181+
});
182+
183+
asyncTest( "Event sequence during page load failure", function() {
184+
expect( 1 );
185+
186+
var otherPageUrl = makeOtherPageUrl( "page-does-not-exist.html" ),
187+
expectedEventSequence = [
188+
189+
// Deprecated as of 1.4.0
190+
{ type: "pagebeforechange", target: "the-body",
191+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } },
192+
193+
// Valid
194+
{ type: "pagecontainerbeforechange", target: "the-body",
195+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } },
196+
197+
// Deprecated as of 1.4.0
198+
{ type: "pagebeforeload", target: "the-body",
199+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } },
200+
201+
// Valid
202+
{ type: "pagecontainerbeforeload", target: "the-body",
203+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } },
204+
205+
// Deprecated as of 1.4.0
206+
{ type: "pageloadfailed", target: "the-body",
207+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } },
208+
209+
// Valid
210+
{ type: "pagecontainerloadfailed", target: "the-body",
211+
data: { prevPage: "start-page", nextPage: undefined, toPage: otherPageUrl } }
212+
];
213+
214+
$.testHelper.detailedEventCascade([
215+
function() {
216+
$( "#go-to-nonexistent-page" ).click();
217+
},
218+
{
219+
pagecontainerloadfailed: {
220+
src: $( ":mobile-pagecontainer" ),
221+
event: "pagecontainerloadfailed.eventSequenceDuringPageLoadFailure1"
222+
}
223+
},
224+
function() {
225+
deepEqual( eventSequence, expectedEventSequence, "Event sequence as expected" );
170226
start();
171227
}
172228
]);

0 commit comments

Comments
 (0)