3 const BASE
= "https://example.com/browser/dom/xslt/tests/browser";
4 const SERVER_SCRIPT
= `${BASE}/bug1309630.sjs`;
6 function resetCounter() {
7 return fetch(`${SERVER_SCRIPT}?reset_counter`);
9 function recordCounter() {
10 return fetch(`${SERVER_SCRIPT}?record_counter`);
12 // Returns a promise that resolves to true if the counter in
13 // bug1309630.sjs changed by more than 'value' since last calling
14 // recordCounter(), or false if it doesn't and we time out.
15 function waitForCounterChangeAbove(value
) {
16 return TestUtils
.waitForCondition(() =>
17 fetch(`${SERVER_SCRIPT}?get_counter_change`).then(response
=>
19 ? response
.text().then(str
=> Number(str
) > value
)
28 add_task(async
function test_eternal_xslt() {
30 await BrowserTestUtils
.withNewTab(
31 { gBrowser
, url
: SERVER_SCRIPT
, waitForLoad
: false },
32 async
function (browser
) {
33 info("Waiting for XSLT to keep loading");
36 await
waitForCounterChangeAbove(1),
37 "We should receive at least a request from the document function call."
40 info("Navigating to about:blank");
41 BrowserTestUtils
.startLoadingURIString(browser
, "about:blank");
42 await BrowserTestUtils
.browserLoaded(browser
);
44 info("Check to see if XSLT stops loading");
45 await
recordCounter();
47 !(await
waitForCounterChangeAbove(0)),
48 "We shouldn't receive more requests to the XSLT file within the timeout period."
54 await BrowserTestUtils
.withNewTab(
55 { gBrowser
, url
: `${BASE}/file_bug1309630.html` },
56 async
function (browser
) {
58 await
waitForCounterChangeAbove(1),
59 "We should receive at least a request from the document function call."
62 info("Navigating to about:blank");
63 BrowserTestUtils
.startLoadingURIString(browser
, "about:blank");
64 await BrowserTestUtils
.browserLoaded(browser
);
66 info("Check to see if XSLT stops loading");
67 await
recordCounter();
69 !(await
waitForCounterChangeAbove(0)),
70 "We shouldn't receive more requests to the XSLT file within the timeout period."