Bug 1945643 - Update to mozilla-nimbus-schemas 2025.1.1 r=chumphreys
[gecko.git] / dom / xslt / tests / browser / browser_bug1309630.js
blob0056870fd92012436b1937e82fae9bda914d400d
1 "use strict";
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 =>
18 response.ok
19 ? response.text().then(str => Number(str) > value)
20 : Promise.reject()
22 ).then(
23 () => true,
24 () => false
28 add_task(async function test_eternal_xslt() {
29 await resetCounter();
30 await BrowserTestUtils.withNewTab(
31 { gBrowser, url: SERVER_SCRIPT, waitForLoad: false },
32 async function (browser) {
33 info("Waiting for XSLT to keep loading");
35 ok(
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();
46 ok(
47 !(await waitForCounterChangeAbove(0)),
48 "We shouldn't receive more requests to the XSLT file within the timeout period."
53 await resetCounter();
54 await BrowserTestUtils.withNewTab(
55 { gBrowser, url: `${BASE}/file_bug1309630.html` },
56 async function (browser) {
57 ok(
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();
68 ok(
69 !(await waitForCounterChangeAbove(0)),
70 "We shouldn't receive more requests to the XSLT file within the timeout period."
74 });