Backed out changeset 9029eac178ab (bug 1421213) for devtools failures on /browser_webconsole_hpkp_invalid-headers.js. on a CLOSED TREE

This commit is contained in:
Narcis Beleuzu 2018-01-17 11:16:50 +02:00
parent 9e4a4577fd
commit ba2bcb9d99
12 changed files with 33 additions and 219 deletions

View File

@ -35,9 +35,7 @@ function onLearnMoreClick(e, url) {
e.preventDefault();
let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
let { button, ctrlKey, metaKey } = e;
let isOSX = Services.appinfo.OS == "Darwin";
if (button === 1 || (button === 0 && (isOSX ? metaKey : ctrlKey))) {
if (e.button === 1) {
win.openUILinkIn(url, "tabshifted");
} else {
win.openUILinkIn(url, "tab");

View File

@ -141,9 +141,8 @@ const SUPPORTED_HTTP_CODES = [
];
const MDN_URL = "https://developer.mozilla.org/docs/";
const getGAParams = (panelId = "netmonitor") => {
return `?utm_source=mozilla&utm_medium=devtools-${panelId}&utm_campaign=default`;
};
const GA_PARAMS =
"?utm_source=mozilla&utm_medium=devtools-netmonitor&utm_campaign=default";
/**
* Get the MDN URL for the specified header.
@ -157,7 +156,7 @@ function getHeadersURL(header) {
let idx = SUPPORTED_HEADERS.findIndex(item =>
item.toLowerCase() === lowerCaseHeader);
return idx > -1 ?
`${MDN_URL}Web/HTTP/Headers/${SUPPORTED_HEADERS[idx] + getGAParams()}` : null;
`${MDN_URL}Web/HTTP/Headers/${SUPPORTED_HEADERS[idx] + GA_PARAMS}` : null;
}
/**
@ -167,11 +166,10 @@ function getHeadersURL(header) {
*
* @return {string} The MDN URL for the HTTP status code, or null if not available.
*/
function getHTTPStatusCodeURL(statusCode, panelId) {
function getHTTPStatusCodeURL(statusCode) {
let idx = SUPPORTED_HTTP_CODES.indexOf(statusCode);
return idx > -1 ?
`${MDN_URL}Web/HTTP/Status/${SUPPORTED_HTTP_CODES[idx] + getGAParams(panelId)}`
: null;
`${MDN_URL}Web/HTTP/Status/${SUPPORTED_HTTP_CODES[idx] + GA_PARAMS}` : null;
}
/**
@ -180,7 +178,7 @@ function getHTTPStatusCodeURL(statusCode, panelId) {
* @return {string} the MDN URL of the Timings tag for Network Monitor.
*/
function getNetMonitorTimingsURL() {
return `${MDN_URL}Tools/Network_Monitor${getGAParams()}#Timings`;
return `${MDN_URL}Tools/Network_Monitor${GA_PARAMS}#Timings`;
}
/**
@ -189,7 +187,7 @@ function getNetMonitorTimingsURL() {
* @return {string} The MDN URL for the documentation of Performance Analysis.
*/
function getPerformanceAnalysisURL() {
return `${MDN_URL}Tools/Network_Monitor${getGAParams()}#Performance_analysis`;
return `${MDN_URL}Tools/Network_Monitor${GA_PARAMS}#Performance_analysis`;
}
module.exports = {

View File

@ -1012,8 +1012,6 @@ a.learn-more-link.webconsole-learn-more-link {
.webconsole-output-wrapper .message.network .status .status-info .status-code {
padding: 0 2px;
border-radius: 3px;
text-decoration: none;
font-style: normal;
}
.webconsole-output-wrapper .message.network .status .status-info .status-code:not([data-code^="3"]) {

View File

@ -420,14 +420,9 @@ WebConsole.prototype = {
* @param string aLink
* The URL you want to open in a new tab.
*/
openLink: function WC_openLink(aLink, e)
openLink: function WC_openLink(aLink)
{
let isOSX = Services.appinfo.OS == "Darwin";
if (e != null && (e.button === 1 || (e.button === 0 && (isOSX ? e.metaKey : e.ctrlKey)))) {
this.chromeUtilsWindow.openUILinkIn(aLink, "tabshifted");
} else {
this.chromeUtilsWindow.openUILinkIn(aLink, "tab");
}
this.chromeUtilsWindow.openUILinkIn(aLink, "tab");
},
/**

View File

@ -93,9 +93,9 @@ class Message extends Component {
}
}
onLearnMoreClick(e) {
onLearnMoreClick() {
let {exceptionDocURL} = this.props;
this.props.serviceContainer.openLink(exceptionDocURL, e);
this.props.serviceContainer.openLink(exceptionDocURL);
}
onContextMenu(e) {

View File

@ -14,8 +14,6 @@ const Message = createFactory(require("devtools/client/webconsole/new-console-ou
const actions = require("devtools/client/webconsole/new-console-output/actions/index");
const { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
const TabboxPanel = createFactory(require("devtools/client/netmonitor/src/components/TabboxPanel"));
const { getHTTPStatusCodeURL } = require("devtools/client/netmonitor/src/utils/mdn-utils");
const LEARN_MORE = l10n.getStr("webConsoleMoreInfoLabel");
NetworkEventMessage.displayName = "NetworkEventMessage";
@ -76,17 +74,7 @@ function NetworkEventMessage({
let statusCode, statusInfo;
if (httpVersion && status && statusText !== undefined && totalTime !== undefined) {
let statusCodeDocURL = getHTTPStatusCodeURL(status.toString(), "webconsole");
statusCode = dom.a({
className: "status-code",
"data-code": status,
title: LEARN_MORE,
onClick: (e) => {
e.stopPropagation();
e.preventDefault();
serviceContainer.openLink(statusCodeDocURL, e);
}
}, status);
statusCode = dom.span({className: "status-code", "data-code": status}, status);
statusInfo = dom.span(
{className: "status-info"},
`[${httpVersion} `, statusCode, ` ${statusText} ${totalTime}ms]`

View File

@ -88,8 +88,8 @@ NewConsoleOutputWrapper.prototype = {
}]));
},
hudProxy: hud.proxy,
openLink: (url, e) => {
hud.owner.openLink(url, e);
openLink: url => {
hud.owner.openLink(url);
},
createElement: nodename => {
return this.document.createElement(nodename);

View File

@ -326,7 +326,6 @@ skip-if = true # Bug 1404886
[browser_webconsole_network_exceptions.js]
[browser_webconsole_network_messages_expand.js]
[browser_webconsole_network_messages_openinnet.js]
[browser_webconsole_network_messages_status_code.js]
[browser_webconsole_network_requests_from_chrome.js]
[browser_webconsole_network_reset_filter.js]
[browser_webconsole_nodes_highlight.js]

View File

@ -43,30 +43,8 @@ add_task(async function () {
const mixedActiveContentMessage = await onMixedActiveContent;
ok(true, "Mixed active content warning message is visible");
const checkLink = ({ link, where, expectedLink, expectedTab }) => {
is(link, expectedLink, `Clicking the provided link opens ${link}`);
is(where, expectedTab, `Clicking the provided link opens in expected tab`);
}
info("Clicking on the Learn More link");
const learnMoreLink = mixedActiveContentMessage.querySelector(".learn-more-link");
let linkSimulation = await simulateLinkClick(learnMoreLink);
checkLink({
...linkSimulation,
expectedLink: LEARN_MORE_URI,
expectedTab: "tab"
});
let isOSX = Services.appinfo.OS == "Darwin";
let ctrlOrCmdKeyMouseEvent = new MouseEvent("click", {
bubbles: true,
[isOSX ? "metaKey" : "ctrlKey"]: true,
view: window
});
linkSimulation = await simulateLinkClick(learnMoreLink, ctrlOrCmdKeyMouseEvent);
checkLink({
...linkSimulation,
expectedLink: LEARN_MORE_URI,
expectedTab: "tabshifted"
});
const url = await simulateLinkClick(learnMoreLink);
is(url, LEARN_MORE_URI, `Clicking the provided link opens ${url}`);
});

View File

@ -49,8 +49,8 @@ add_task(async function() {
info("Clicking on the Learn More link");
let learnMoreLink = blockedMixedActiveContentMessage.querySelector(".learn-more-link");
let response = await simulateLinkClick(learnMoreLink);
is(response.link, LEARN_MORE_URI, `Clicking the provided link opens ${response.link}`);
let url = await simulateLinkClick(learnMoreLink);
is(url, LEARN_MORE_URI, `Clicking the provided link opens ${url}`);
info("Test disabling mixed content protection");
@ -74,8 +74,8 @@ add_task(async function() {
info("Clicking on the Learn More link");
learnMoreLink = mixedActiveContentMessage.querySelector(".learn-more-link");
response = await simulateLinkClick(learnMoreLink);
is(response.link, LEARN_MORE_URI, `Clicking the provided link opens ${response.link}`);
url = await simulateLinkClick(learnMoreLink);
is(url, LEARN_MORE_URI, `Clicking the provided link opens ${url}`);
});
function pushPrefEnv() {

View File

@ -1,104 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_FILE = "test-network-request.html";
const TEST_PATH = "http://example.com/browser/devtools/client/webconsole/new-console-output/test/mochitest/";
const TEST_URI = TEST_PATH + TEST_FILE;
const NET_PREF = "devtools.webconsole.filter.net";
const XHR_PREF = "devtools.webconsole.filter.netxhr";
let { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Web/HTTP/Status/200" + STATUS_CODES_GA_PARAMS;
pushPref(NET_PREF, true);
pushPref(XHR_PREF, true);
add_task(async function task() {
const hud = await openNewTabAndConsole(TEST_URI);
const currentTab = gBrowser.selectedTab;
let target = TargetFactory.forTab(currentTab);
let toolbox = gDevTools.getToolbox(target);
let {ui} = toolbox.getCurrentPanel().hud;
const onNetworkMessageUpdate = ui.jsterm.hud.once("network-message-updated");
// Fire an XHR POST request.
await ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
content.wrappedJSObject.testXhrPost();
});
info("XHR executed");
await onNetworkMessageUpdate;
let xhrUrl = TEST_PATH + "test-data.json";
let messageNode = await waitFor(() => findMessage(hud, xhrUrl));
let urlNode = messageNode.querySelector(".url");
let statusCodeNode = messageNode.querySelector(".status-code");
info("Network message found.");
ok(statusCodeNode.title, l10n.getStr("webConsoleMoreInfoLabel"));
let {
middleMouseEvent,
ctrlOrCmdKeyMouseEvent,
rightClickMouseEvent,
rightClickCtrlOrCmdKeyMouseEvent,
} = getMouseEvents();
let testCases = [
{ clickEvent: middleMouseEvent, link: LEARN_MORE_URI, where: "tabshifted" },
{ clickEvent: null, link: LEARN_MORE_URI, where: "tab" },
{ clickEvent: ctrlOrCmdKeyMouseEvent, link: LEARN_MORE_URI, where: "tabshifted" },
{ clickEvent: rightClickMouseEvent, link: null, where: null },
{ clickEvent: rightClickCtrlOrCmdKeyMouseEvent, link: null, where: null }
];
for (let testCase of testCases) {
const { clickEvent } = testCase;
let onConsoleMenuOpened = [rightClickMouseEvent, rightClickCtrlOrCmdKeyMouseEvent].includes(clickEvent) ?
hud.ui.newConsoleOutput.once("menu-open") : null;
let { link, where } = await simulateLinkClick(statusCodeNode, testCase.clickEvent);
is(link, testCase.link, `Clicking the provided link opens ${link}`);
is(where, testCase.where, `Link opened in correct tab`);
if (onConsoleMenuOpened) {
info("Check if context menu is opened on right clicking the status-code");
await onConsoleMenuOpened;
}
}
});
function getMouseEvents() {
let isOSX = Services.appinfo.OS == "Darwin";
let middleMouseEvent = new MouseEvent("click", {
bubbles: true,
button: 1,
view: window
});
let ctrlOrCmdKeyMouseEvent = new MouseEvent("click", {
bubbles: true,
[isOSX ? "metaKey" : "ctrlKey"]: true,
view: window
});
let rightClickMouseEvent = new MouseEvent("contextmenu", {
bubbles: true,
button: 2,
view: window
});
let rightClickCtrlOrCmdKeyMouseEvent = new MouseEvent("contextmenu", {
bubbles: true,
button: 2,
[isOSX ? "metaKey" : "ctrlKey"]: true,
view: window
});
return {
middleMouseEvent,
ctrlOrCmdKeyMouseEvent,
rightClickMouseEvent,
rightClickCtrlOrCmdKeyMouseEvent,
};
}

View File

@ -20,16 +20,9 @@ Services.scriptloader.loadSubScript(
var {HUDService} = require("devtools/client/webconsole/hudservice");
var WCUL10n = require("devtools/client/webconsole/webconsole-l10n");
const DOCS_GA_PARAMS = `?${new URLSearchParams({
"utm_source": "mozilla",
"utm_medium": "firefox-console-errors",
"utm_campaign": "default"
})}`;
const STATUS_CODES_GA_PARAMS = `?${new URLSearchParams({
"utm_source": "mozilla",
"utm_medium": "devtools-webconsole",
"utm_campaign": "default"
})}`;
const DOCS_GA_PARAMS = "?utm_source=mozilla" +
"&utm_medium=firefox-console-errors" +
"&utm_campaign=default";
Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", true);
registerCleanupFunction(function* () {
@ -420,53 +413,24 @@ async function closeConsole(tab = gBrowser.selectedTab) {
* Fake clicking a link and return the URL we would have navigated to.
* This function should be used to check external links since we can't access
* network in tests.
* This can also be used to test that a click will not be fired.
*
* @param ElementNode element
* The <a> element we want to simulate click on.
* @param Object clickEventProps
* The custom properties which would be used to dispatch a click event
* @returns Promise
* A Promise that is resolved when the link click simulation occured or when the click is not dispatched.
* The promise resolves with an object that holds the following properties
* - link: url of the link or null(if event not fired)
* - where: "tab" if tab is active or "tabshifted" if tab is inactive or null(if event not fired)
* A Promise that resolved when the link clik simulation occured.
*/
function simulateLinkClick(element, clickEventProps) {
// Override openUILinkIn to prevent navigating.
let oldOpenUILinkIn = window.openUILinkIn;
const onOpenLink = new Promise((resolve) => {
window.openUILinkIn = function (link, where) {
function simulateLinkClick(element) {
return new Promise((resolve) => {
// Override openUILinkIn to prevent navigating.
let oldOpenUILinkIn = window.openUILinkIn;
window.openUILinkIn = function (link) {
window.openUILinkIn = oldOpenUILinkIn;
resolve({link: link, where});
resolve(link);
};
if (clickEventProps) {
// Click on the link using the event properties.
element.dispatchEvent(clickEventProps);
} else {
// Click on the link.
element.click();
}
// Click on the link.
element.click();
});
// Declare a timeout Promise that we can use to make sure openUILinkIn was not called.
let timeoutId;
const onTimeout = new Promise(function(resolve, reject) {
timeoutId = setTimeout(() => {
window.openUILinkIn = oldOpenUILinkIn;
timeoutId = null;
resolve({link: null, where: null});
}, 1000);
});
onOpenLink.then(() => {
if (timeoutId) {
clearTimeout(timeoutId);
}
});
return Promise.race([onOpenLink, onTimeout]);
}
/**