Bug 1709346 - Part 2: Add test for cancelling a long-running load by removing its subframes, r=kmag

This seems to be the behaviour which was causing the failures with twitter embeds.

Differential Revision: https://phabricator.services.mozilla.com/D115707
This commit is contained in:
Nika Layzell 2021-05-25 17:31:54 +00:00
Родитель 804c0c75da
Коммит 76f83124d6
4 изменённых файлов: 69 добавлений и 0 удалений

Просмотреть файл

@ -139,3 +139,7 @@ support-files =
support-files =
page_bytecode_cache_asm_js.html
page_bytecode_cache_asm_js.js
[browser_bug1709346.js]
support-files =
load_forever.sjs
file_empty_cross_site_frame.html

Просмотреть файл

@ -0,0 +1,48 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(async function remove_subframe_in_cross_site_frame() {
await BrowserTestUtils.withNewTab(
"http://mochi.test:8888/browser/dom/tests/browser/file_empty_cross_site_frame.html",
async browser => {
await TestUtils.waitForCondition(
() => !XULBrowserWindow.isBusy,
"browser is not busy after the tab finishes loading"
);
// Spawn into the cross-site subframe, and begin loading a slow network
// connection. We'll cancel the load before this navigation completes.
await SpecialPowers.spawn(
browser.browsingContext.children[0],
[],
async () => {
let frame = content.document.createElement("iframe");
frame.src = "load_forever.sjs";
content.document.body.appendChild(frame);
frame.addEventListener("load", function() {
ok(false, "load should not finish before the frame is removed");
});
}
);
is(
XULBrowserWindow.isBusy,
true,
"browser should be busy after the load starts"
);
// Remove the outer iframe, ending the load within this frame's subframe
// early.
await SpecialPowers.spawn(browser, [], async () => {
content.document.querySelector("iframe").remove();
});
await TestUtils.waitForCondition(
() => !XULBrowserWindow.isBusy,
"Browser should no longer be busy after the frame is removed"
);
}
);
});

Просмотреть файл

@ -0,0 +1,2 @@
<!doctype html>
<iframe src="http://example.com/browser/dom/tests/browser/file_empty.html"></iframe>

Просмотреть файл

@ -0,0 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let gResponses = [];
function handleRequest(request, response) {
response.seizePower();
response.write("HTTP/1.1 200 OK\r\n");
response.write("Content-Type: text/plain; charset=utf-8\r\n");
response.write("Cache-Control: no-cache, must-revalidate\r\n");
response.write("\r\n");
// Keep the response alive indefinitely.
gResponses.push(response);
}