Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 43956c6

Browse files
committed
Refactor static lifecycle html file
Consolidates as much of the test functionality into one html file.
1 parent 6791e5b commit 43956c6

File tree

6 files changed

+14
-100
lines changed

6 files changed

+14
-100
lines changed

tests/lifecycle_wait_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func TestLifecycleWaitForNavigation(t *testing.T) {
113113
tb := newTestBrowser(t, withFileServer())
114114
p := tb.NewPage(nil)
115115

116-
withHomeHandler(t, tb, "wait_for_nav_lifecycle.html")
116+
withHomeHandler(t, tb, "lifecycle.html?pingCount=10")
117117
withPingHandler(t, tb, tt.pingSlowness, nil)
118118
withPingJSHandler(t, tb, tt.pingJSSlow, nil, false)
119119

@@ -168,7 +168,7 @@ func TestLifecycleWaitForNavigationTimeout(t *testing.T) {
168168
tb := newTestBrowser(t, withFileServer())
169169
p := tb.NewPage(nil)
170170

171-
withHomeHandler(t, tb, "prolonged_network_idle_10.html")
171+
withHomeHandler(t, tb, "lifecycle_no_ping_js.html")
172172
withPingHandler(t, tb, 0, nil)
173173

174174
waitUntil := common.LifecycleEventNetworkIdle
@@ -297,7 +297,7 @@ func TestLifecycleWaitForLoadState(t *testing.T) {
297297
tb := newTestBrowser(t, withFileServer())
298298
p := tb.NewPage(nil)
299299

300-
withHomeHandler(t, tb, "wait_for_nav_lifecycle.html")
300+
withHomeHandler(t, tb, "lifecycle.html?pingCount=10")
301301
withPingHandler(t, tb, tt.pingSlowness, nil)
302302
withPingJSHandler(t, tb, tt.pingJSSlow, nil, false)
303303

@@ -391,7 +391,7 @@ func TestLifecycleReload(t *testing.T) {
391391
tb := newTestBrowser(t, withFileServer())
392392
p := tb.NewPage(nil)
393393

394-
withHomeHandler(t, tb, "reload_lifecycle.html")
394+
withHomeHandler(t, tb, "lifecycle.html?pingCount=10")
395395
withPingHandler(t, tb, tt.pingSlowness, nil)
396396
withPingJSHandler(t, tb, tt.pingJSSlow, nil, false)
397397

@@ -487,7 +487,7 @@ func TestLifecycleGotoWithSubFrame(t *testing.T) {
487487
p := tb.NewPage(nil)
488488

489489
withHomeHandler(t, tb, "lifecycle_main_frame.html")
490-
withSubHandler(t, tb, "lifecycle_subframe.html")
490+
withSubHandler(t, tb, "lifecycle.html?pingCount=10")
491491
withPingHandler(t, tb, tt.pingSlowness, nil)
492492
withPingJSHandler(t, tb, tt.pingJSSlow, nil, true)
493493

@@ -557,7 +557,7 @@ func TestLifecycleGoto(t *testing.T) {
557557
tb := newTestBrowser(t, withFileServer())
558558
p := tb.NewPage(nil)
559559

560-
withHomeHandler(t, tb, "wait_for_nav_lifecycle.html")
560+
withHomeHandler(t, tb, "lifecycle.html?pingCount=10")
561561
withPingHandler(t, tb, tt.pingSlowness, nil)
562562
withPingJSHandler(t, tb, tt.pingJSSlow, nil, false)
563563

@@ -610,7 +610,7 @@ func TestLifecycleGotoNetworkIdle(t *testing.T) {
610610
tb := newTestBrowser(t, withFileServer())
611611
p := tb.NewPage(nil)
612612

613-
withHomeHandler(t, tb, "prolonged_network_idle.html")
613+
withHomeHandler(t, tb, "lifecycle.html?pingCount=4")
614614
ch := make(chan bool)
615615
withPingHandler(t, tb, 50*time.Millisecond, ch)
616616
withPingJSHandler(t, tb, false, ch, false)
@@ -632,7 +632,7 @@ func TestLifecycleGotoNetworkIdle(t *testing.T) {
632632
tb := newTestBrowser(t, withFileServer())
633633
p := tb.NewPage(nil)
634634

635-
withHomeHandler(t, tb, "prolonged_network_idle_10.html")
635+
withHomeHandler(t, tb, "lifecycle_no_ping_js.html")
636636
withPingHandler(t, tb, 50*time.Millisecond, nil)
637637

638638
assertHome(t, tb, p, common.LifecycleEventNetworkIdle, func() testPromise {

tests/static/lifecycle_subframe.html renamed to tests/static/lifecycle.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head></head>
44

55
<body>
6+
<a href="/home" id="homeLink">Home</a>
67
<div id="pingRequestText">Waiting...</div>
78
<div id="pingJSText">Waiting...</div>
89

@@ -19,7 +20,11 @@
1920
})
2021

2122
async function pingRequestText() {
22-
for (var i = 0; i < 10; i++) {
23+
const queryString = window.location.search;
24+
const urlParams = new URLSearchParams(queryString);
25+
const pingCount = urlParams.get('pingCount')
26+
27+
for (var i = 0; i < pingCount; i++) {
2328
await fetch('/ping')
2429
.then(response => response.text())
2530
.then((data) => {

tests/static/prolonged_network_idle.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/static/reload_lifecycle.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/static/wait_for_nav_lifecycle.html

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)