Bug 1590318 - Make browser_test_FTP_console_warning.js fission ready r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D50075

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sebastian Streich 2019-10-22 16:20:11 +00:00
Родитель a2f3e00d0d
Коммит 14d2d23a81
2 изменённых файлов: 11 добавлений и 86 удалений

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

@ -14,7 +14,6 @@ support-files =
support-files =
file_view_image_data_navigation.html
[browser_test_FTP_console_warning.js]
fail-if = fission
support-files =
file_FTP_console_warning.html
[browser_test_assert_systemprincipal_documents.js]

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

@ -7,77 +7,20 @@ function scopedCuImport(path) {
ChromeUtils.import(path, scope);
return scope;
}
const { loader, require } = scopedCuImport(
"resource://devtools/shared/Loader.jsm"
);
const { TargetFactory } = require("devtools/client/framework/target");
const { Utils: WebConsoleUtils } = require("devtools/client/webconsole/utils");
let { gDevTools } = require("devtools/client/framework/devtools");
let promise = require("promise");
/**
* Open the toolbox in a given tab.
* @param {XULNode} tab The tab the toolbox should be opened in.
* @param {String} toolId Optional. The ID of the tool to be selected.
* @param {String} hostType Optional. The type of toolbox host to be used.
* @return {Promise} Resolves with the toolbox, when it has been opened.
*/
var openToolboxForTab = async function(tab, toolId, hostType) {
info("Opening the toolbox");
let toolbox;
let target = await TargetFactory.forTab(tab);
await target.attach();
// Check if the toolbox is already loaded.
toolbox = gDevTools.getToolbox(target);
if (toolbox) {
if (!toolId || (toolId && toolbox.getPanel(toolId))) {
info("Toolbox is already opened");
return toolbox;
}
}
// If not, load it now.
toolbox = await gDevTools.showToolbox(target, toolId, hostType);
// Make sure that the toolbox frame is focused.
await new Promise(resolve => waitForFocus(resolve, toolbox.win));
info("Toolbox opened and focused");
return toolbox;
};
function console_observer(subject, topic, data) {
var message = subject.wrappedJSObject.arguments[0];
ok(false, message);
}
var webconsole = null;
// These files don't actually exist, we are just looking for messages
// that indicate that loading those files would have been blocked.
var seen_files = ["a.html", "b.html", "c.html", "d.png"];
function on_new_message(new_messages) {
for (let message of new_messages) {
let elem = message.node;
let text = elem.textContent;
if (
text.includes("Loading FTP subresource within http(s) page not allowed")
) {
// Remove the file in the message from the list.
seen_files = seen_files.filter(file => {
return !text.includes(file);
});
}
}
}
async function do_cleanup() {
if (webconsole) {
webconsole.ui.off("new-messages", on_new_message);
function on_new_message(msgObj) {
let text = msgObj.message;
if (
text.includes("Loading FTP subresource within http(s) page not allowed")
) {
// Remove the file in the message from the list.
seen_files = seen_files.filter(file => {
return !text.includes(file);
});
}
}
@ -91,29 +34,12 @@ add_task(async function() {
// A longer timeout is necessary for this test than the plain mochitests
// due to opening a new tab with the web console.
requestLongerTimeout(4);
registerCleanupFunction(do_cleanup);
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
let toolbox = await openToolboxForTab(tab, "webconsole");
ok(toolbox, "Got toolbox");
let hud = toolbox.getCurrentPanel().hud;
ok(hud, "Got hud");
if (!webconsole) {
registerCleanupFunction(do_cleanup);
hud.ui.on("new-messages", on_new_message);
webconsole = hud;
}
Services.console.registerListener(on_new_message);
await BrowserTestUtils.loadURI(gBrowser.selectedBrowser, kTestURI);
await BrowserTestUtils.waitForCondition(() => seen_files.length === 0);
is(seen_files.length, 0, "All FTP subresources should be blocked");
BrowserTestUtils.removeTab(tab);
Services.console.unregisterListener(on_new_message);
});