зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1405636 - enable and rename browser_webconsole_netlogging_reset_filter.js;r=Honza
MozReview-Commit-ID: IcFW6itKo7I --HG-- rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_netlogging_reset_filter.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_network_reset_filter.js extra : rebase_source : 98a22f95f1f93ea799d9e789d02cf9913de14629
This commit is contained in:
Родитель
765b6f3069
Коммит
1bc58767e9
|
@ -326,13 +326,12 @@ skip-if = true # Bug 1404384
|
||||||
tags = mcb
|
tags = mcb
|
||||||
skip-if = true # Bug 1404886
|
skip-if = true # Bug 1404886
|
||||||
[browser_webconsole_multiple_windows_and_tabs.js]
|
[browser_webconsole_multiple_windows_and_tabs.js]
|
||||||
[browser_webconsole_netlogging_reset_filter.js]
|
|
||||||
skip-if = true # Bug 1405636
|
|
||||||
[browser_webconsole_network_attach.js]
|
[browser_webconsole_network_attach.js]
|
||||||
[browser_webconsole_network_exceptions.js]
|
[browser_webconsole_network_exceptions.js]
|
||||||
[browser_webconsole_network_messages_expand.js]
|
[browser_webconsole_network_messages_expand.js]
|
||||||
[browser_webconsole_network_messages_openinnet.js]
|
[browser_webconsole_network_messages_openinnet.js]
|
||||||
[browser_webconsole_network_requests_from_chrome.js]
|
[browser_webconsole_network_requests_from_chrome.js]
|
||||||
|
[browser_webconsole_network_reset_filter.js]
|
||||||
[browser_webconsole_nodes_highlight.js]
|
[browser_webconsole_nodes_highlight.js]
|
||||||
[browser_webconsole_nodes_select.js]
|
[browser_webconsole_nodes_select.js]
|
||||||
[browser_webconsole_notifications.js]
|
[browser_webconsole_notifications.js]
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
||||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
// Tests that network log messages bring up the network panel and select the
|
|
||||||
// right request even if it was previously filtered off.
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const TEST_FILE_URI =
|
|
||||||
"http://example.com/browser/devtools/client/webconsole/test/" +
|
|
||||||
"test-network.html";
|
|
||||||
const TEST_URI = "data:text/html;charset=utf8,<p>test file URI";
|
|
||||||
|
|
||||||
var hud;
|
|
||||||
|
|
||||||
add_task(function* () {
|
|
||||||
let requests = [];
|
|
||||||
let { browser } = yield loadTab(TEST_URI);
|
|
||||||
|
|
||||||
yield pushPrefEnv();
|
|
||||||
hud = yield openConsole();
|
|
||||||
hud.jsterm.clearOutput();
|
|
||||||
|
|
||||||
HUDService.lastFinishedRequest.callback = request => requests.push(request);
|
|
||||||
|
|
||||||
let loaded = loadBrowser(browser);
|
|
||||||
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_FILE_URI);
|
|
||||||
yield loaded;
|
|
||||||
|
|
||||||
yield testMessages();
|
|
||||||
let htmlRequest = requests.find(e => e.request.url.endsWith("html"));
|
|
||||||
ok(htmlRequest, "htmlRequest was a html");
|
|
||||||
|
|
||||||
yield hud.ui.openNetworkPanel(htmlRequest.actor);
|
|
||||||
let toolbox = gDevTools.getToolbox(hud.target);
|
|
||||||
is(toolbox.currentToolId, "netmonitor", "Network panel was opened");
|
|
||||||
|
|
||||||
let panel = toolbox.getCurrentPanel();
|
|
||||||
let { store, windowRequire } = panel.panelWin;
|
|
||||||
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
|
||||||
let { getSelectedRequest } = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
|
||||||
|
|
||||||
let selected = getSelectedRequest(store.getState());
|
|
||||||
is(selected.method, htmlRequest.request.method,
|
|
||||||
"The correct request is selected");
|
|
||||||
is(selected.url, htmlRequest.request.url,
|
|
||||||
"The correct request is definitely selected");
|
|
||||||
|
|
||||||
// Filter out the HTML request.
|
|
||||||
store.dispatch(Actions.toggleRequestFilterType("js"));
|
|
||||||
|
|
||||||
yield toolbox.selectTool("webconsole");
|
|
||||||
is(toolbox.currentToolId, "webconsole", "Web console was selected");
|
|
||||||
yield hud.ui.openNetworkPanel(htmlRequest.actor);
|
|
||||||
|
|
||||||
selected = getSelectedRequest(store.getState());
|
|
||||||
is(selected.method, htmlRequest.request.method,
|
|
||||||
"The correct request is selected");
|
|
||||||
is(selected.url, htmlRequest.request.url,
|
|
||||||
"The correct request is definitely selected");
|
|
||||||
|
|
||||||
// All tests are done. Shutdown.
|
|
||||||
HUDService.lastFinishedRequest.callback = null;
|
|
||||||
htmlRequest = browser = requests = hud = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
function testMessages() {
|
|
||||||
return waitForMessages({
|
|
||||||
webconsole: hud,
|
|
||||||
messages: [{
|
|
||||||
text: "running network console logging tests",
|
|
||||||
category: CATEGORY_WEBDEV,
|
|
||||||
severity: SEVERITY_LOG,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "test-network.html",
|
|
||||||
category: CATEGORY_NETWORK,
|
|
||||||
severity: SEVERITY_LOG,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "testscript.js",
|
|
||||||
category: CATEGORY_NETWORK,
|
|
||||||
severity: SEVERITY_LOG,
|
|
||||||
}],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function pushPrefEnv() {
|
|
||||||
let deferred = defer();
|
|
||||||
let options = {
|
|
||||||
set: [["devtools.webconsole.filter.networkinfo", true]]
|
|
||||||
};
|
|
||||||
SpecialPowers.pushPrefEnv(options, deferred.resolve);
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
|
@ -31,7 +31,7 @@ add_task(async function task() {
|
||||||
await loadDocument(documentUrl);
|
await loadDocument(documentUrl);
|
||||||
info("Document loaded.");
|
info("Document loaded.");
|
||||||
|
|
||||||
await testNetmonitorLink(toolbox, hud, documentUrl);
|
await openMessageInNetmonitor(toolbox, hud, documentUrl);
|
||||||
|
|
||||||
// Go back to console.
|
// Go back to console.
|
||||||
await toolbox.selectTool("webconsole");
|
await toolbox.selectTool("webconsole");
|
||||||
|
@ -43,36 +43,5 @@ add_task(async function task() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const jsonUrl = TEST_PATH + JSON_TEST_URL;
|
const jsonUrl = TEST_PATH + JSON_TEST_URL;
|
||||||
await testNetmonitorLink(toolbox, hud, jsonUrl);
|
await openMessageInNetmonitor(toolbox, hud, jsonUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function testNetmonitorLink(toolbox, hud, url) {
|
|
||||||
let messageNode = await waitFor(() => findMessage(hud, url));
|
|
||||||
info("Network message found.");
|
|
||||||
|
|
||||||
let onNetmonitorSelected = toolbox.once("netmonitor-selected", (event, panel) => {
|
|
||||||
return panel;
|
|
||||||
});
|
|
||||||
|
|
||||||
let menuPopup = await openContextMenu(hud, messageNode);
|
|
||||||
let openInNetMenuItem = menuPopup.querySelector("#console-menu-open-in-network-panel");
|
|
||||||
ok(openInNetMenuItem, "open in network panel item is enabled");
|
|
||||||
openInNetMenuItem.click();
|
|
||||||
|
|
||||||
const {panelWin} = await onNetmonitorSelected;
|
|
||||||
ok(true, "The netmonitor panel is selected when clicking on the network message");
|
|
||||||
|
|
||||||
let { store, windowRequire } = panelWin;
|
|
||||||
let actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
|
||||||
let { getSelectedRequest } =
|
|
||||||
windowRequire("devtools/client/netmonitor/src/selectors/index");
|
|
||||||
|
|
||||||
store.dispatch(actions.batchEnable(false));
|
|
||||||
|
|
||||||
await waitUntil(() => {
|
|
||||||
const selected = getSelectedRequest(store.getState());
|
|
||||||
return selected && selected.url === url;
|
|
||||||
});
|
|
||||||
|
|
||||||
ok(true, "The attached url is correct.");
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||||
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
// Tests that network log messages bring up the network panel and select the
|
||||||
|
// right request even if it was previously filtered off.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const TEST_PATH = "http://example.com/browser/devtools/client/webconsole/" +
|
||||||
|
"new-console-output/test/mochitest/";
|
||||||
|
const TEST_URI = "data:text/html;charset=utf8,<p>test file URI";
|
||||||
|
|
||||||
|
add_task(async function () {
|
||||||
|
await pushPref("devtools.webconsole.filter.net", true);
|
||||||
|
|
||||||
|
let toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
|
||||||
|
let hud = toolbox.getCurrentPanel().hud;
|
||||||
|
|
||||||
|
let onMessages = waitForMessages({
|
||||||
|
hud,
|
||||||
|
messages: [
|
||||||
|
{ text: "running network console logging tests" },
|
||||||
|
{ text: "test-network.html" },
|
||||||
|
{ text: "testscript.js" }
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
info("Wait for document to load");
|
||||||
|
await loadDocument(TEST_PATH + "test-network.html");
|
||||||
|
|
||||||
|
info("Wait for expected messages to appear");
|
||||||
|
await onMessages;
|
||||||
|
|
||||||
|
let url = TEST_PATH + "testscript.js?foo";
|
||||||
|
// The url as it appears in the webconsole, without the GET parameters
|
||||||
|
let shortUrl = TEST_PATH + "testscript.js";
|
||||||
|
|
||||||
|
info("Open the testscript.js request in the network monitor");
|
||||||
|
await openMessageInNetmonitor(toolbox, hud, url, shortUrl);
|
||||||
|
|
||||||
|
info("Filter out the current request");
|
||||||
|
let panel = toolbox.getCurrentPanel();
|
||||||
|
let { store, windowRequire } = panel.panelWin;
|
||||||
|
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||||
|
store.dispatch(Actions.toggleRequestFilterType("js"));
|
||||||
|
|
||||||
|
info("Select back the webconsole");
|
||||||
|
await toolbox.selectTool("webconsole");
|
||||||
|
is(toolbox.currentToolId, "webconsole", "Web console was selected");
|
||||||
|
|
||||||
|
info("Open the testscript.js request again in the network monitor");
|
||||||
|
await openMessageInNetmonitor(toolbox, hud, url, shortUrl);
|
||||||
|
});
|
|
@ -451,3 +451,46 @@ function openNewBrowserWindow() {
|
||||||
}, "browser-delayed-startup-finished");
|
}, "browser-delayed-startup-finished");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a network request logged in the webconsole in the netmonitor panel.
|
||||||
|
*
|
||||||
|
* @param {Object} toolbox
|
||||||
|
* @param {Object} hud
|
||||||
|
* @param {String} url
|
||||||
|
* URL of the request as logged in the netmonitor.
|
||||||
|
* @param {String} urlInConsole
|
||||||
|
* (optional) Use if the logged URL in webconsole is different from the real URL.
|
||||||
|
*/
|
||||||
|
async function openMessageInNetmonitor(toolbox, hud, url, urlInConsole) {
|
||||||
|
// By default urlInConsole should be the same as the complete url.
|
||||||
|
urlInConsole = urlInConsole || url;
|
||||||
|
|
||||||
|
let message = await waitFor(() => findMessage(hud, urlInConsole));
|
||||||
|
|
||||||
|
let onNetmonitorSelected = toolbox.once("netmonitor-selected", (event, panel) => {
|
||||||
|
return panel;
|
||||||
|
});
|
||||||
|
|
||||||
|
let menuPopup = await openContextMenu(hud, message);
|
||||||
|
let openInNetMenuItem = menuPopup.querySelector("#console-menu-open-in-network-panel");
|
||||||
|
ok(openInNetMenuItem, "open in network panel item is enabled");
|
||||||
|
openInNetMenuItem.click();
|
||||||
|
|
||||||
|
const {panelWin} = await onNetmonitorSelected;
|
||||||
|
ok(true, "The netmonitor panel is selected when clicking on the network message");
|
||||||
|
|
||||||
|
let { store, windowRequire } = panelWin;
|
||||||
|
let actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||||
|
let { getSelectedRequest } =
|
||||||
|
windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||||
|
|
||||||
|
store.dispatch(actions.batchEnable(false));
|
||||||
|
|
||||||
|
await waitUntil(() => {
|
||||||
|
const selected = getSelectedRequest(store.getState());
|
||||||
|
return selected && selected.url === url;
|
||||||
|
});
|
||||||
|
|
||||||
|
ok(true, "The attached url is correct.");
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче