From 32230477c611d6baddb4f2f6caf5c55c8b8cc198 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:41:01 +0100 Subject: DevTools - Inspector - tooltip get element width/height wrong when browser zoomed https://github.com/MoonchildProductions/moebius/pull/54 --- devtools/client/inspector/test/browser.ini | 1 + .../inspector/test/browser_inspector_infobar_04.js | 38 ++++++++++++++++++++++ devtools/server/actors/highlighters/box-model.js | 15 ++++++--- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 devtools/client/inspector/test/browser_inspector_infobar_04.js diff --git a/devtools/client/inspector/test/browser.ini b/devtools/client/inspector/test/browser.ini index 65ad71c0c..499df25f0 100644 --- a/devtools/client/inspector/test/browser.ini +++ b/devtools/client/inspector/test/browser.ini @@ -113,6 +113,7 @@ subsuite = clipboard [browser_inspector_infobar_01.js] [browser_inspector_infobar_02.js] [browser_inspector_infobar_03.js] +[browser_inspector_infobar_04.js] [browser_inspector_infobar_textnode.js] [browser_inspector_initialization.js] skip-if = (e10s && debug) # Bug 1250058 - Docshell leak on debug e10s diff --git a/devtools/client/inspector/test/browser_inspector_infobar_04.js b/devtools/client/inspector/test/browser_inspector_infobar_04.js new file mode 100644 index 000000000..f1b9eca49 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_infobar_04.js @@ -0,0 +1,38 @@ +/* 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/. */ + +"use strict"; + +// Check the position and text content of the highlighter nodeinfo bar under page zoom. + +const TEST_URI = URL_ROOT + "doc_inspector_infobar_01.html"; + +add_task(function* () { + let {inspector, testActor} = yield openInspectorForURL(TEST_URI); + let testData = { + selector: "#top", + dims: "500" + " \u00D7 " + "100" + }; + + yield testInfobar(testData, inspector, testActor); + info("Change zoom page to level 2."); + yield testActor.zoomPageTo(2); + info("Testing again the infobar after zoom."); + yield testInfobar(testData, inspector, testActor); +}); + +function* testInfobar(test, inspector, testActor) { + info(`Testing ${test.selector}`); + + yield selectAndHighlightNode(test.selector, inspector); + + // Ensure the node is the correct one. + let id = yield testActor.getHighlighterNodeTextContent( + "box-model-infobar-id"); + is(id, test.selector, `Node ${test.selector} selected.`); + + let dims = yield testActor.getHighlighterNodeTextContent( + "box-model-infobar-dimensions"); + is(dims, test.dims, "Node's infobar displays the right dimensions."); +} diff --git a/devtools/server/actors/highlighters/box-model.js b/devtools/server/actors/highlighters/box-model.js index 35f201a04..ae4284424 100644 --- a/devtools/server/actors/highlighters/box-model.js +++ b/devtools/server/actors/highlighters/box-model.js @@ -15,7 +15,10 @@ const { isNodeValid, moveInfobar, } = require("./utils/markup"); -const { setIgnoreLayoutChanges } = require("devtools/shared/layout/utils"); +const { + setIgnoreLayoutChanges, + getCurrentZoom, + } = require("devtools/shared/layout/utils"); const inspector = require("devtools/server/actors/inspector"); const nodeConstants = require("devtools/shared/dom-node-constants"); @@ -670,10 +673,14 @@ BoxModelHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, { pseudos += ":" + pseudo; } - let rect = this._getOuterQuad("border").bounds; - let dim = parseFloat(rect.width.toPrecision(6)) + + // We want to display the original `width` and `height`, instead of the ones affected + // by any zoom. Since the infobar can be displayed also for text nodes, we can't + // access the computed style for that, and this is why we recalculate them here. + let zoom = getCurrentZoom(this.win); + let { width, height } = this._getOuterQuad("border").bounds; + let dim = parseFloat((width / zoom).toPrecision(6)) + " \u00D7 " + - parseFloat(rect.height.toPrecision(6)); + parseFloat((height / zoom).toPrecision(6)); this.getElement("infobar-tagname").setTextContent(displayName); this.getElement("infobar-id").setTextContent(id); -- cgit v1.2.3 From ad35e2a11f30dd2db1ae63431dbb9065eea2771c Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:41:33 +0100 Subject: DevTools - gcli commands - cookie https://github.com/MoonchildProductions/moebius/pull/55 --- devtools/shared/gcli/commands/cookie.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/devtools/shared/gcli/commands/cookie.js b/devtools/shared/gcli/commands/cookie.js index f1680042f..203ac738c 100644 --- a/devtools/shared/gcli/commands/cookie.js +++ b/devtools/shared/gcli/commands/cookie.js @@ -100,7 +100,7 @@ exports.items = [ let cookies = []; while (enm.hasMoreElements()) { - let cookie = enm.getNext().QueryInterface(Ci.nsICookie); + let cookie = enm.getNext().QueryInterface(Ci.nsICookie2); if (isCookieAtHost(cookie, host)) { cookies.push({ host: cookie.host, @@ -108,9 +108,10 @@ exports.items = [ value: cookie.value, path: cookie.path, expires: cookie.expires, - secure: cookie.secure, - httpOnly: cookie.httpOnly, - sameDomain: cookie.sameDomain + isDomain: cookie.isDomain, + isHttpOnly: cookie.isHttpOnly, + isSecure: cookie.isSecure, + isSession: cookie.isSession, }); } } @@ -169,11 +170,14 @@ exports.items = [ for (let cookie of cookies) { cookie.expires = translateExpires(cookie.expires); - let noAttrs = !cookie.secure && !cookie.httpOnly && !cookie.sameDomain; - cookie.attrs = (cookie.secure ? "secure" : " ") + - (cookie.httpOnly ? "httpOnly" : " ") + - (cookie.sameDomain ? "sameDomain" : " ") + - (noAttrs ? l10n.lookup("cookieListOutNone") : " "); + let noAttrs = !cookie.isDomain && !cookie.isHttpOnly && + !cookie.isSecure && !cookie.isSession; + cookie.attrs = ((cookie.isDomain ? "isDomain " : "") + + (cookie.isHttpOnly ? "isHttpOnly " : "") + + (cookie.isSecure ? "isSecure " : "") + + (cookie.isSession ? "isSession " : "") + + (noAttrs ? l10n.lookup("cookieListOutNone") : "")) + .trim(); } return context.createView({ -- cgit v1.2.3 From 259e214960c23346628311d88427c7ca13bdb335 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:49:42 +0100 Subject: Basilisk - the cmd line - help (the columns alignment, error improvements) https://github.com/MoonchildProductions/moebius/pull/58 --- browser/components/nsBrowserContentHandler.js | 14 +++++------ browser/components/shell/nsSetDefaultBrowser.js | 2 +- devtools/client/devtools-startup.js | 19 +++++++++------ layout/tools/recording/recording-cmdline.js | 4 ++-- toolkit/xre/nsAppRunner.cpp | 31 +++++++++++++------------ 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index e8fe0fe93..b366c3f81 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -454,16 +454,16 @@ nsBrowserContentHandler.prototype = { get helpInfo() { let info = - " --browser Open a browser window.\n" + - " --new-window Open in a new window.\n" + - " --new-tab Open in a new tab.\n" + - " --private-window Open in a new private window.\n"; + " --browser Open a browser window.\n" + + " --new-window Open in a new window.\n" + + " --new-tab Open in a new tab.\n" + + " --private-window Open in a new private window.\n"; if (AppConstants.platform == "win") { - info += " --preferences Open Options dialog.\n"; + info += " --preferences Open Options dialog.\n"; } else { - info += " --preferences Open Preferences dialog.\n"; + info += " --preferences Open Preferences dialog.\n"; } - info += " --search Search with your default search engine.\n"; + info += " --search Search with your default search engine.\n"; return info; }, diff --git a/browser/components/shell/nsSetDefaultBrowser.js b/browser/components/shell/nsSetDefaultBrowser.js index bb09ab213..c7a78c538 100644 --- a/browser/components/shell/nsSetDefaultBrowser.js +++ b/browser/components/shell/nsSetDefaultBrowser.js @@ -21,7 +21,7 @@ nsSetDefaultBrowser.prototype = { } }, - helpInfo: " --setDefaultBrowser Set this app as the default browser.\n", + helpInfo: " --setDefaultBrowser Set this app as the default browser.\n", classID: Components.ID("{F57899D0-4E2C-4ac6-9E29-50C736103B0C}"), QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), diff --git a/devtools/client/devtools-startup.js b/devtools/client/devtools-startup.js index 2271dd790..f07e4ff2b 100644 --- a/devtools/client/devtools-startup.js +++ b/devtools/client/devtools-startup.js @@ -190,7 +190,10 @@ DevToolsStartup.prototype = { listener.open(); dump("Started debugger server on " + portOrPath + "\n"); } catch (e) { - dump("Unable to start debugger server on " + portOrPath + ": " + e); + let _error = "Unable to start debugger server on " + portOrPath + ": " + + e; + Cu.reportError(_error); + dump(_error + "\n"); } if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) { @@ -199,12 +202,14 @@ DevToolsStartup.prototype = { }, /* eslint-disable max-len */ - helpInfo: " --jsconsole Open the Browser Console.\n" + - " --jsdebugger Open the Browser Toolbox.\n" + - " --devtools Open DevTools on initial load.\n" + - " --start-debugger-server [ws:][ | ] Start the debugger server on\n" + - " a TCP port or Unix domain socket path. Defaults to TCP port\n" + - " 6000. Use WebSocket protocol if ws: prefix is specified.\n", + helpInfo: " --jsconsole Open the Browser Console.\n" + + " --jsdebugger Open the Browser Toolbox.\n" + + " --devtools Open DevTools on initial load.\n" + + " --start-debugger-server [ws:][|] Start the debugger server on\n" + + " a TCP port or Unix domain socket path.\n" + + " Defaults to TCP port 6000.\n" + + " Use WebSocket protocol if ws: prefix\n" + + " is specified.\n", /* eslint-disable max-len */ classID: Components.ID("{9e9a9283-0ce9-4e4a-8f1c-ba129a032c32}"), diff --git a/layout/tools/recording/recording-cmdline.js b/layout/tools/recording/recording-cmdline.js index e043aa29c..0f127bbd5 100644 --- a/layout/tools/recording/recording-cmdline.js +++ b/layout/tools/recording/recording-cmdline.js @@ -67,8 +67,8 @@ RecordingCmdLineHandler.prototype = cmdLine.preventDefault = true; }, - helpInfo : " --recording Record drawing for a given URL.\n" + - " --recording-output Specify destination file for a drawing recording.\n" + helpInfo : " --recording Record drawing for a given URL.\n" + + " --recording-output Specify destination file for a drawing recording.\n" }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]); diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 4a1d3046f..1b5c2ed75 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1589,28 +1589,29 @@ DumpHelp() #ifdef MOZ_X11 printf("X11 options\n" - " --display=DISPLAY X display to use\n" - " --sync Make X calls synchronous\n"); + " --display=DISPLAY X display to use.\n" + " --sync Make X calls synchronous.\n"); #endif #ifdef XP_UNIX - printf(" --g-fatal-warnings Make all warnings fatal\n" + printf(" --g-fatal-warnings Make all warnings fatal.\n" "\n%s options\n", gAppData->name); #endif - printf(" -h or --help Print this message.\n" - " -v or --version Print %s version.\n" - " -P Start with .\n" - " --profile Start with profile at .\n" - " --migration Start with migration wizard.\n" - " --ProfileManager Start with ProfileManager.\n" - " --no-remote Do not accept or send remote commands; implies\n" - " --new-instance.\n" - " --new-instance Open new instance, not a new window in running instance.\n" - " --UILocale Start with resources as UI Locale.\n" - " --safe-mode Disables extensions and themes for this session.\n", gAppData->name); + printf(" -h or --help Print this message.\n" + " -v or --version Print %s version.\n" + " -P Start with .\n" + " --profile Start with profile at .\n" + " --migration Start with migration wizard.\n" + " --ProfileManager Start with ProfileManager.\n" + " --no-remote Do not accept or send remote commands;\n" + " implies --new-instance.\n" + " --new-instance Open new instance, not a new window\n" + " in running instance.\n" + " --UILocale Start with resources as UI Locale.\n" + " --safe-mode Disables extensions and themes for this session.\n", (const char*) gAppData->name); #if defined(XP_WIN) - printf(" --console Start %s with a debugging console.\n", gAppData->name); + printf(" --console Start %s with a debugging console.\n", (const char*) gAppData->name); #endif // this works, but only after the components have registered. so if you drop in a new command line handler, --help -- cgit v1.2.3 From f7e146b34388db880d34d4d8082d71f903c6cabe Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:51:01 +0100 Subject: [partial fix] DevTools - network - proxy - throws an errors (remoteAddress) https://github.com/MoonchildProductions/moebius/pull/63 --- devtools/shared/webconsole/network-monitor.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/devtools/shared/webconsole/network-monitor.js b/devtools/shared/webconsole/network-monitor.js index 084493432..5416a7760 100644 --- a/devtools/shared/webconsole/network-monitor.js +++ b/devtools/shared/webconsole/network-monitor.js @@ -1327,8 +1327,24 @@ NetworkMonitor.prototype = { let response = {}; response.httpVersion = statusLineArray.shift(); - response.remoteAddress = httpActivity.channel.remoteAddress; - response.remotePort = httpActivity.channel.remotePort; + // XXX: + // Sometimes, when using a proxy server (manual proxy configuration), + // throws an errors: + // 0x80040111 (NS_ERROR_NOT_AVAILABLE) + // [nsIHttpChannelInternal.remoteAddress] + // Bug 1337791 is the suspect. + response.remoteAddress = null; + try { + response.remoteAddress = httpActivity.channel.remoteAddress; + } catch (e) { + Cu.reportError(e); + } + response.remotePort = null; + try { + response.remotePort = httpActivity.channel.remotePort; + } catch (e) { + Cu.reportError(e); + } response.status = statusLineArray.shift(); response.statusText = statusLineArray.join(" "); response.headersSize = extraStringData.length; -- cgit v1.2.3 From b19e4e2cf0c1537c8c2a56d0b783d38b6b25de7f Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:57:48 +0100 Subject: DevTools - inspector - data URL source links and their tooltips are unreadable https://github.com/MoonchildProductions/moebius/pull/95 --- devtools/client/inspector/rules/models/rule.js | 11 +++++-- .../rules/test/browser_rules_style-editor-link.js | 35 +++++++++++++++------- devtools/shared/inspector/css-logic.js | 12 ++++++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/devtools/client/inspector/rules/models/rule.js b/devtools/client/inspector/rules/models/rule.js index 1a3fa057a..4c978cb58 100644 --- a/devtools/client/inspector/rules/models/rule.js +++ b/devtools/client/inspector/rules/models/rule.js @@ -140,11 +140,18 @@ Rule.prototype = { line, mediaText}) => { let mediaString = mediaText ? " @" + mediaText : ""; let linePart = line > 0 ? (":" + line) : ""; + let decodedHref = href; + + if (decodedHref) { + try { + decodedHref = decodeURIComponent(href); + } catch (e) {} + } let sourceStrings = { - full: (href || CssLogic.l10n("rule.sourceInline")) + linePart + + full: (decodedHref || CssLogic.l10n("rule.sourceInline")) + linePart + mediaString, - short: CssLogic.shortSource({href: href}) + linePart + mediaString + short: CssLogic.shortSource({href: decodedHref}) + linePart + mediaString }; return sourceStrings; diff --git a/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js b/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js index 927deb8ce..6a4fd1d66 100644 --- a/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js +++ b/devtools/client/inspector/rules/test/browser_rules_style-editor-link.js @@ -10,10 +10,12 @@ thisTestLeaksUncaughtRejectionsAndShouldBeFixed("Error: Unknown sheet source"); // Test the links from the rule-view to the styleeditor -const STYLESHEET_URL = "data:text/css," + encodeURIComponent( - ["#first {", - "color: blue", - "}"].join("\n")); +const STYLESHEET_DATA_URL_CONTENTS = ["#first {", + "color: blue", + "}"].join("\n"); +const STYLESHEET_DATA_URL = + `data:text/css,${encodeURIComponent(STYLESHEET_DATA_URL_CONTENTS)}`; +const STYLESHEET_DECODED_DATA_URL = `data:text/css,${STYLESHEET_DATA_URL_CONTENTS}`; const EXTERNAL_STYLESHEET_FILE_NAME = "doc_style_editor_link.css"; const EXTERNAL_STYLESHEET_URL = URL_ROOT + EXTERNAL_STYLESHEET_FILE_NAME; @@ -31,7 +33,7 @@ const DOCUMENT_URL = "data:text/html;charset=utf-8," + encodeURIComponent(` - + @@ -178,15 +180,28 @@ function* testDisabledStyleEditor(view, toolbox) { } function testRuleViewLinkLabel(view) { - let link = getRuleViewLinkByIndex(view, 2); + info("Checking the data URL link label"); + + let link = getRuleViewLinkByIndex(view, 1); let labelElem = link.querySelector(".ruleview-rule-source-label"); let value = labelElem.textContent; let tooltipText = labelElem.getAttribute("title"); - is(value, EXTERNAL_STYLESHEET_FILE_NAME + ":1", - "rule view stylesheet display value matches filename and line number"); - is(tooltipText, EXTERNAL_STYLESHEET_URL + ":1", - "rule view stylesheet tooltip text matches the full URI path"); + is(value, `${STYLESHEET_DATA_URL_CONTENTS}:1`, + "Rule view data URL stylesheet display value matches contents"); + is(tooltipText, `${STYLESHEET_DECODED_DATA_URL}:1`, + "Rule view data URL stylesheet tooltip text matches the full URI path"); + + info("Checking the external link label"); + link = getRuleViewLinkByIndex(view, 2); + labelElem = link.querySelector(".ruleview-rule-source-label"); + value = labelElem.textContent; + tooltipText = labelElem.getAttribute("title"); + + is(value, `${EXTERNAL_STYLESHEET_FILE_NAME}:1`, + "Rule view external stylesheet display value matches filename and line number"); + is(tooltipText, `${EXTERNAL_STYLESHEET_URL}:1`, + "Rule view external stylesheet tooltip text matches the full URI path"); } function testUnselectableRuleViewLink(view, index) { diff --git a/devtools/shared/inspector/css-logic.js b/devtools/shared/inspector/css-logic.js index c8cdd2fdb..901b7a189 100644 --- a/devtools/shared/inspector/css-logic.js +++ b/devtools/shared/inspector/css-logic.js @@ -30,6 +30,8 @@ "use strict"; +const MAX_DATA_URL_LENGTH = 40; + /** * Provide access to the style information in a page. * CssLogic uses the standard DOM API, and the Gecko inIDOMUtils API to access @@ -103,6 +105,13 @@ exports.shortSource = function (sheet) { return exports.l10n("rule.sourceInline"); } + // If the sheet is a data URL, return a trimmed version of it. + let dataUrl = sheet.href.trim().match(/^data:.*?,((?:.|\r|\n)*)$/); + if (dataUrl) { + return dataUrl[1].length > MAX_DATA_URL_LENGTH ? + `${dataUrl[1].substr(0, MAX_DATA_URL_LENGTH - 1)}…` : dataUrl[1]; + } + // We try, in turn, the filename, filePath, query string, whole thing let url = {}; try { @@ -123,8 +132,7 @@ exports.shortSource = function (sheet) { return url.query; } - let dataUrl = sheet.href.match(/^(data:[^,]*),/); - return dataUrl ? dataUrl[1] : sheet.href; + return sheet.href; }; const TAB_CHARS = "\t"; -- cgit v1.2.3 From 627f167bf41935cad572b04c5b412f9294293ecb Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 12:17:13 +0100 Subject: Bug 1309194: Implement summary info in Net Panel Toolbar; Bug 1317205: CSS improvement for summary button Required for: https://github.com/MoonchildProductions/moebius/pull/93 --- devtools/client/netmonitor/actions/index.js | 5 +- devtools/client/netmonitor/actions/moz.build | 3 +- devtools/client/netmonitor/actions/requests.js | 25 +++++ devtools/client/netmonitor/actions/sidebar.js | 49 ---------- devtools/client/netmonitor/actions/ui.js | 36 +++++++ devtools/client/netmonitor/components/moz.build | 1 + .../client/netmonitor/components/summary-button.js | 57 +++++++++++ .../client/netmonitor/components/toggle-button.js | 32 +++---- devtools/client/netmonitor/constants.js | 8 +- devtools/client/netmonitor/netmonitor-view.js | 5 +- devtools/client/netmonitor/netmonitor.xul | 5 +- devtools/client/netmonitor/reducers/index.js | 6 +- devtools/client/netmonitor/reducers/moz.build | 3 +- devtools/client/netmonitor/reducers/requests.js | 28 ++++++ devtools/client/netmonitor/reducers/sidebar.js | 43 --------- devtools/client/netmonitor/reducers/ui.js | 40 ++++++++ devtools/client/netmonitor/requests-menu-view.js | 105 ++------------------- devtools/client/netmonitor/selectors/index.js | 57 ++++++++++- .../netmonitor/test/browser_net_footer-summary.js | 22 ++--- devtools/client/netmonitor/toolbar-view.js | 13 ++- devtools/client/themes/common.css | 6 ++ devtools/client/themes/netmonitor.css | 24 ++++- 22 files changed, 333 insertions(+), 240 deletions(-) create mode 100644 devtools/client/netmonitor/actions/requests.js delete mode 100644 devtools/client/netmonitor/actions/sidebar.js create mode 100644 devtools/client/netmonitor/actions/ui.js create mode 100644 devtools/client/netmonitor/components/summary-button.js create mode 100644 devtools/client/netmonitor/reducers/requests.js delete mode 100644 devtools/client/netmonitor/reducers/sidebar.js create mode 100644 devtools/client/netmonitor/reducers/ui.js diff --git a/devtools/client/netmonitor/actions/index.js b/devtools/client/netmonitor/actions/index.js index 3f7b0bd2f..2ce23448e 100644 --- a/devtools/client/netmonitor/actions/index.js +++ b/devtools/client/netmonitor/actions/index.js @@ -4,6 +4,7 @@ "use strict"; const filters = require("./filters"); -const sidebar = require("./sidebar"); +const requests = require("./requests"); +const ui = require("./ui"); -module.exports = Object.assign({}, filters, sidebar); +module.exports = Object.assign({}, filters, requests, ui); diff --git a/devtools/client/netmonitor/actions/moz.build b/devtools/client/netmonitor/actions/moz.build index 477cafb41..d0ac61944 100644 --- a/devtools/client/netmonitor/actions/moz.build +++ b/devtools/client/netmonitor/actions/moz.build @@ -6,5 +6,6 @@ DevToolsModules( 'filters.js', 'index.js', - 'sidebar.js', + 'requests.js', + 'ui.js', ) diff --git a/devtools/client/netmonitor/actions/requests.js b/devtools/client/netmonitor/actions/requests.js new file mode 100644 index 000000000..ae794a437 --- /dev/null +++ b/devtools/client/netmonitor/actions/requests.js @@ -0,0 +1,25 @@ +/* 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/. */ + +"use strict"; + +const { + UPDATE_REQUESTS, +} = require("../constants"); + +/** + * Update request items + * + * @param {array} requests - visible request items + */ +function updateRequests(items) { + return { + type: UPDATE_REQUESTS, + items, + }; +} + +module.exports = { + updateRequests, +}; diff --git a/devtools/client/netmonitor/actions/sidebar.js b/devtools/client/netmonitor/actions/sidebar.js deleted file mode 100644 index 7e8dca5c1..000000000 --- a/devtools/client/netmonitor/actions/sidebar.js +++ /dev/null @@ -1,49 +0,0 @@ -/* 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/. */ -"use strict"; - -const { - DISABLE_TOGGLE_BUTTON, - SHOW_SIDEBAR, - TOGGLE_SIDEBAR, -} = require("../constants"); - -/** - * Change ToggleButton disabled state. - * - * @param {boolean} disabled - expected button disabled state - */ -function disableToggleButton(disabled) { - return { - type: DISABLE_TOGGLE_BUTTON, - disabled: disabled, - }; -} - -/** - * Change sidebar visible state. - * - * @param {boolean} visible - expected sidebar visible state - */ -function showSidebar(visible) { - return { - type: SHOW_SIDEBAR, - visible: visible, - }; -} - -/** - * Toggle to show/hide sidebar. - */ -function toggleSidebar() { - return { - type: TOGGLE_SIDEBAR, - }; -} - -module.exports = { - disableToggleButton, - showSidebar, - toggleSidebar, -}; diff --git a/devtools/client/netmonitor/actions/ui.js b/devtools/client/netmonitor/actions/ui.js new file mode 100644 index 000000000..c6df307ed --- /dev/null +++ b/devtools/client/netmonitor/actions/ui.js @@ -0,0 +1,36 @@ ++/* 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/. */ + +"use strict"; + +const { + OPEN_SIDEBAR, + TOGGLE_SIDEBAR, +} = require("../constants"); + +/** + * Change sidebar open state. + * + * @param {boolean} open - open state + */ +function openSidebar(open) { + return { + type: OPEN_SIDEBAR, + open, + }; +} + +/** + * Toggle sidebar open state. + */ +function toggleSidebar() { + return { + type: TOGGLE_SIDEBAR, + }; +} + +module.exports = { + openSidebar, + toggleSidebar, +}; diff --git a/devtools/client/netmonitor/components/moz.build b/devtools/client/netmonitor/components/moz.build index 47ef7f026..42459584d 100644 --- a/devtools/client/netmonitor/components/moz.build +++ b/devtools/client/netmonitor/components/moz.build @@ -6,5 +6,6 @@ DevToolsModules( 'filter-buttons.js', 'search-box.js', + 'summary-button.js', 'toggle-button.js', ) diff --git a/devtools/client/netmonitor/components/summary-button.js b/devtools/client/netmonitor/components/summary-button.js new file mode 100644 index 000000000..9465d3147 --- /dev/null +++ b/devtools/client/netmonitor/components/summary-button.js @@ -0,0 +1,57 @@ +/* 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/. */ + +/* globals NetMonitorView */ + +"use strict"; + +const { + CONTENT_SIZE_DECIMALS, + REQUEST_TIME_DECIMALS, +} = require("../constants"); +const { DOM, PropTypes } = require("devtools/client/shared/vendor/react"); +const { connect } = require("devtools/client/shared/vendor/react-redux"); +const { PluralForm } = require("devtools/shared/plural-form"); +const { L10N } = require("../l10n"); +const { getSummary } = require("../selectors/index"); + +const { button, span } = DOM; + +function SummaryButton({ + summary, + triggerSummary, +}) { + let { count, totalBytes, totalMillis } = summary; + const text = (count === 0) ? L10N.getStr("networkMenu.empty") : + PluralForm.get(count, L10N.getStr("networkMenu.summary")) + .replace("#1", count) + .replace("#2", L10N.numberWithDecimals(totalBytes / 1024, + CONTENT_SIZE_DECIMALS)) + .replace("#3", L10N.numberWithDecimals(totalMillis / 1000, + REQUEST_TIME_DECIMALS)); + + return button({ + id: "requests-menu-network-summary-button", + className: "devtools-button", + title: count ? text : L10N.getStr("netmonitor.toolbar.perf"), + onClick: triggerSummary, + }, + span({ className: "summary-info-icon" }), + span({ className: "summary-info-text" }, text)); +} + +SummaryButton.propTypes = { + summary: PropTypes.object.isRequired, +}; + +module.exports = connect( + (state) => ({ + summary: getSummary(state), + }), + (dispatch) => ({ + triggerSummary: () => { + NetMonitorView.toggleFrontendMode(); + }, + }) +)(SummaryButton); diff --git a/devtools/client/netmonitor/components/toggle-button.js b/devtools/client/netmonitor/components/toggle-button.js index db546c55d..c9a59a76b 100644 --- a/devtools/client/netmonitor/components/toggle-button.js +++ b/devtools/client/netmonitor/components/toggle-button.js @@ -1,5 +1,3 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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/. */ @@ -11,47 +9,43 @@ const { connect } = require("devtools/client/shared/vendor/react-redux"); const { L10N } = require("../l10n"); const Actions = require("../actions/index"); -// Shortcuts const { button } = DOM; -/** - * Button used to toggle sidebar - */ function ToggleButton({ disabled, - onToggle, - visible, + open, + triggerSidebar, }) { let className = ["devtools-button"]; - if (!visible) { + if (!open) { className.push("pane-collapsed"); } - let titleMsg = visible ? L10N.getStr("collapseDetailsPane") : - L10N.getStr("expandDetailsPane"); + + const title = open ? L10N.getStr("collapseDetailsPane") : + L10N.getStr("expandDetailsPane"); return button({ id: "details-pane-toggle", className: className.join(" "), - title: titleMsg, - disabled: disabled, + title, + disabled, tabIndex: "0", - onMouseDown: onToggle, + onMouseDown: triggerSidebar, }); } ToggleButton.propTypes = { disabled: PropTypes.bool.isRequired, - onToggle: PropTypes.func.isRequired, - visible: PropTypes.bool.isRequired, + triggerSidebar: PropTypes.func.isRequired, }; module.exports = connect( (state) => ({ - disabled: state.sidebar.toggleButtonDisabled, - visible: state.sidebar.visible, + disabled: state.requests.items.length === 0, + open: state.ui.sidebar.open, }), (dispatch) => ({ - onToggle: () => { + triggerSidebar: () => { dispatch(Actions.toggleSidebar()); let requestsMenu = NetMonitorView.RequestsMenu; diff --git a/devtools/client/netmonitor/constants.js b/devtools/client/netmonitor/constants.js index a540d74b2..33bc71ea7 100644 --- a/devtools/client/netmonitor/constants.js +++ b/devtools/client/netmonitor/constants.js @@ -5,15 +5,17 @@ const general = { FREETEXT_FILTER_SEARCH_DELAY: 200, + CONTENT_SIZE_DECIMALS: 2, + REQUEST_TIME_DECIMALS: 2, }; const actionTypes = { TOGGLE_FILTER_TYPE: "TOGGLE_FILTER_TYPE", ENABLE_FILTER_TYPE_ONLY: "ENABLE_FILTER_TYPE_ONLY", - TOGGLE_SIDEBAR: "TOGGLE_SIDEBAR", - SHOW_SIDEBAR: "SHOW_SIDEBAR", - DISABLE_TOGGLE_BUTTON: "DISABLE_TOGGLE_BUTTON", SET_FILTER_TEXT: "SET_FILTER_TEXT", + OPEN_SIDEBAR: "OPEN_SIDEBAR", + TOGGLE_SIDEBAR: "TOGGLE_SIDEBAR", + UPDATE_REQUESTS: "UPDATE_REQUESTS", }; module.exports = Object.assign({}, general, actionTypes); diff --git a/devtools/client/netmonitor/netmonitor-view.js b/devtools/client/netmonitor/netmonitor-view.js index 68470f7a9..8da5a2038 100644 --- a/devtools/client/netmonitor/netmonitor-view.js +++ b/devtools/client/netmonitor/netmonitor-view.js @@ -125,7 +125,6 @@ var NetMonitorView = { if (!Prefs.statistics) { $("#request-menu-context-perf").hidden = true; $("#notice-perf-message").hidden = true; - $("#requests-menu-network-summary-button").hidden = true; } }, @@ -171,10 +170,10 @@ var NetMonitorView = { if (flags.visible) { this._body.classList.remove("pane-collapsed"); - gStore.dispatch(Actions.showSidebar(true)); + gStore.dispatch(Actions.openSidebar(true)); } else { this._body.classList.add("pane-collapsed"); - gStore.dispatch(Actions.showSidebar(false)); + gStore.dispatch(Actions.openSidebar(false)); } if (tabIndex !== undefined) { diff --git a/devtools/client/netmonitor/netmonitor.xul b/devtools/client/netmonitor/netmonitor.xul index bb580f7ad..8a0c60389 100644 --- a/devtools/client/netmonitor/netmonitor.xul +++ b/devtools/client/netmonitor/netmonitor.xul @@ -28,9 +28,8 @@ id="react-filter-buttons-hook"/> - + { + const oldValue = currentValue; const newValue = reduceValue(currentValue); - if (newValue !== currentValue) { - onChange(newValue, currentValue); + if (newValue !== oldValue) { currentValue = newValue; + onChange(newValue, oldValue); } }; } @@ -129,8 +129,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { let widgetParentEl = $("#requests-menu-contents"); this.widget = new SideMenuWidget(widgetParentEl); this._splitter = $("#network-inspector-view-splitter"); - this._summary = $("#requests-menu-network-summary-button"); - this._summary.setAttribute("label", L10N.getStr("networkMenu.empty")); // Create a tooltip for the newly appended network request item. this.tooltip = new HTMLTooltip(NetMonitorController._toolbox.doc, { type: "arrow" }); @@ -211,13 +209,10 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { if (NetMonitorController.supportsPerfStats) { $("#requests-menu-perf-notice-button").addEventListener("command", this._onContextPerfCommand, false); - $("#requests-menu-network-summary-button").addEventListener("command", - this._onContextPerfCommand, false); $("#network-statistics-back-button").addEventListener("command", this._onContextPerfCommand, false); } else { $("#notice-perf-message").hidden = true; - $("#requests-menu-network-summary-button").hidden = true; } if (!NetMonitorController.supportsTransferredResponseSize) { @@ -257,8 +252,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { this._onReloadCommand, false); $("#requests-menu-perf-notice-button").removeEventListener("command", this._onContextPerfCommand, false); - $("#requests-menu-network-summary-button").removeEventListener("command", - this._onContextPerfCommand, false); $("#network-statistics-back-button").removeEventListener("command", this._onContextPerfCommand, false); @@ -422,7 +415,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { */ reFilterRequests: function () { this.filterContents(this._filterPredicate); - this.refreshSummary(); + this.updateRequests(); this.refreshZebra(); }, @@ -541,7 +534,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { break; } - this.refreshSummary(); + this.updateRequests(); this.refreshZebra(); }, @@ -552,41 +545,17 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { NetMonitorController.NetworkEventsHandler.clearMarkers(); NetMonitorView.Sidebar.toggle(false); - this.store.dispatch(Actions.disableToggleButton(true)); $("#requests-menu-empty-notice").hidden = false; this.empty(); - this.refreshSummary(); + this.updateRequests(); }, /** - * Refreshes the status displayed in this container's footer, providing - * concise information about all requests. + * Update store request itmes and trigger related UI update */ - refreshSummary: function () { - let visibleItems = this.visibleItems; - let visibleRequestsCount = visibleItems.length; - if (!visibleRequestsCount) { - this._summary.setAttribute("label", L10N.getStr("networkMenu.empty")); - return; - } - - let totalBytes = this._getTotalBytesOfRequests(visibleItems); - let totalMillis = - this._getNewestRequest(visibleItems).attachment.endedMillis - - this._getOldestRequest(visibleItems).attachment.startedMillis; - - // https://developer.mozilla.org/en-US/docs/Localization_and_Plurals - let str = PluralForm.get(visibleRequestsCount, - L10N.getStr("networkMenu.summary")); - - this._summary.setAttribute("label", str - .replace("#1", visibleRequestsCount) - .replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, - CONTENT_SIZE_DECIMALS)) - .replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, - REQUEST_TIME_DECIMALS)) - ); + updateRequests: function () { + this.store.dispatch(Actions.updateRequests(this.visibleItems)); }, /** @@ -865,7 +834,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { this._updateQueue = []; this._addQueue = []; - this.store.dispatch(Actions.disableToggleButton(!this.itemCount)); $("#requests-menu-empty-notice").hidden = !!this.itemCount; // Make sure all the requests are sorted and filtered. @@ -875,7 +843,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { // so this doesn't happen once per network event update). this.sortContents(); this.filterContents(); - this.refreshSummary(); + this.updateRequests(); this.refreshZebra(); // Rescale all the waterfalls so that everything is visible at once. @@ -1558,59 +1526,6 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { } }, - /** - * Gets the total number of bytes representing the cumulated content size of - * a set of requests. Returns 0 for an empty set. - * - * @param array itemsArray - * @return number - */ - _getTotalBytesOfRequests: function (itemsArray) { - if (!itemsArray.length) { - return 0; - } - - let result = 0; - itemsArray.forEach(item => { - let size = item.attachment.contentSize; - result += (typeof size == "number") ? size : 0; - }); - - return result; - }, - - /** - * Gets the oldest (first performed) request in a set. Returns null for an - * empty set. - * - * @param array itemsArray - * @return object - */ - _getOldestRequest: function (itemsArray) { - if (!itemsArray.length) { - return null; - } - return itemsArray.reduce((prev, curr) => - prev.attachment.startedMillis < curr.attachment.startedMillis ? - prev : curr); - }, - - /** - * Gets the newest (latest performed) request in a set. Returns null for an - * empty set. - * - * @param array itemsArray - * @return object - */ - _getNewestRequest: function (itemsArray) { - if (!itemsArray.length) { - return null; - } - return itemsArray.reduce((prev, curr) => - prev.attachment.startedMillis > curr.attachment.startedMillis ? - prev : curr); - }, - /** * Gets the available waterfall width in this container. * @return number diff --git a/devtools/client/netmonitor/selectors/index.js b/devtools/client/netmonitor/selectors/index.js index f473149b5..8cd6b6ffc 100644 --- a/devtools/client/netmonitor/selectors/index.js +++ b/devtools/client/netmonitor/selectors/index.js @@ -1,8 +1,63 @@ /* 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/. */ + "use strict"; +const { createSelector } = require("devtools/client/shared/vendor/reselect"); + +/** + * Gets the total number of bytes representing the cumulated content size of + * a set of requests. Returns 0 for an empty set. + * + * @param {array} items - an array of request items + * @return {number} total bytes of requests + */ +function getTotalBytesOfRequests(items) { + if (!items.length) { + return 0; + } + + let result = 0; + items.forEach((item) => { + let size = item.attachment.contentSize; + result += (typeof size == "number") ? size : 0; + }); + + return result; +} + +/** + * Gets the total milliseconds for all requests. Returns null for an + * empty set. + * + * @param {array} items - an array of request items + * @return {object} total milliseconds for all requests + */ +function getTotalMillisOfRequests(items) { + if (!items.length) { + return null; + } + + const oldest = items.reduce((prev, curr) => + prev.attachment.startedMillis < curr.attachment.startedMillis ? + prev : curr); + const newest = items.reduce((prev, curr) => + prev.attachment.startedMillis > curr.attachment.startedMillis ? + prev : curr); + + return newest.attachment.endedMillis - oldest.attachment.startedMillis; +} + +const getSummary = createSelector( + (state) => state.requests.items, + (requests) => ({ + count: requests.length, + totalBytes: getTotalBytesOfRequests(requests), + totalMillis: getTotalMillisOfRequests(requests), + }) +); + module.exports = { - // selectors... + getSummary, }; diff --git a/devtools/client/netmonitor/test/browser_net_footer-summary.js b/devtools/client/netmonitor/test/browser_net_footer-summary.js index e484b2097..94bfa604b 100644 --- a/devtools/client/netmonitor/test/browser_net_footer-summary.js +++ b/devtools/client/netmonitor/test/browser_net_footer-summary.js @@ -10,13 +10,14 @@ add_task(function* () { requestLongerTimeout(2); + let { getSummary } = require("devtools/client/netmonitor/selectors/index"); let { L10N } = require("devtools/client/netmonitor/l10n"); let { PluralForm } = require("devtools/shared/plural-form"); let { tab, monitor } = yield initNetMonitor(FILTERING_URL); info("Starting test... "); - let { $, NetMonitorView } = monitor.panelWin; + let { $, NetMonitorView, gStore } = monitor.panelWin; let { RequestsMenu } = NetMonitorView; RequestsMenu.lazyUpdate = false; @@ -43,31 +44,24 @@ add_task(function* () { yield teardown(monitor); function testStatus() { - let summary = $("#requests-menu-network-summary-button"); - let value = summary.getAttribute("label"); + const { count, totalBytes, totalMillis } = getSummary(gStore.getState()); + let value = $("#requests-menu-network-summary-button").textContent; info("Current summary: " + value); - let visibleItems = RequestsMenu.visibleItems; - let visibleRequestsCount = visibleItems.length; let totalRequestsCount = RequestsMenu.itemCount; - info("Current requests: " + visibleRequestsCount + " of " + totalRequestsCount + "."); + info("Current requests: " + count + " of " + totalRequestsCount + "."); - if (!totalRequestsCount || !visibleRequestsCount) { + if (!totalRequestsCount || !count) { is(value, L10N.getStr("networkMenu.empty"), "The current summary text is incorrect, expected an 'empty' label."); return; } - let totalBytes = RequestsMenu._getTotalBytesOfRequests(visibleItems); - let totalMillis = - RequestsMenu._getNewestRequest(visibleItems).attachment.endedMillis - - RequestsMenu._getOldestRequest(visibleItems).attachment.startedMillis; - info("Computed total bytes: " + totalBytes); info("Computed total millis: " + totalMillis); - is(value, PluralForm.get(visibleRequestsCount, L10N.getStr("networkMenu.summary")) - .replace("#1", visibleRequestsCount) + is(value, PluralForm.get(count, L10N.getStr("networkMenu.summary")) + .replace("#1", count) .replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, 2)) .replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, 2)) , "The current summary text is incorrect."); diff --git a/devtools/client/netmonitor/toolbar-view.js b/devtools/client/netmonitor/toolbar-view.js index 28c3cf99b..1834d3ee9 100644 --- a/devtools/client/netmonitor/toolbar-view.js +++ b/devtools/client/netmonitor/toolbar-view.js @@ -7,6 +7,7 @@ const Provider = createFactory(require("devtools/client/shared/vendor/react-redu const FilterButtons = createFactory(require("./components/filter-buttons")); const ToggleButton = createFactory(require("./components/toggle-button")); const SearchBox = createFactory(require("./components/search-box")); +const SummaryButton = createFactory(require("./components/summary-button")); const { L10N } = require("./l10n"); // Shortcuts @@ -28,8 +29,9 @@ ToolbarView.prototype = { this._clearContainerNode = $("#react-clear-button-hook"); this._filterContainerNode = $("#react-filter-buttons-hook"); - this._toggleContainerNode = $("#react-details-pane-toggle-hook"); + this._summaryContainerNode = $("#react-summary-button-hook"); this._searchContainerNode = $("#react-search-box-hook"); + this._toggleContainerNode = $("#react-details-pane-toggle-hook"); // clear button ReactDOM.render(button({ @@ -47,6 +49,12 @@ ToolbarView.prototype = { FilterButtons() ), this._filterContainerNode); + // summary button + ReactDOM.render(Provider( + { store }, + SummaryButton() + ), this._summaryContainerNode); + // search box ReactDOM.render(Provider( { store }, @@ -68,8 +76,9 @@ ToolbarView.prototype = { ReactDOM.unmountComponentAtNode(this._clearContainerNode); ReactDOM.unmountComponentAtNode(this._filterContainerNode); - ReactDOM.unmountComponentAtNode(this._toggleContainerNode); + ReactDOM.unmountComponentAtNode(this._summaryContainerNode); ReactDOM.unmountComponentAtNode(this._searchContainerNode); + ReactDOM.unmountComponentAtNode(this._toggleContainerNode); } }; diff --git a/devtools/client/themes/common.css b/devtools/client/themes/common.css index 3d713ada7..133770150 100644 --- a/devtools/client/themes/common.css +++ b/devtools/client/themes/common.css @@ -2,7 +2,9 @@ * 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/. */ + @import url("resource://devtools/client/themes/splitters.css"); +@namespace html url("http://www.w3.org/1999/xhtml"); :root { font: message-box; @@ -33,6 +35,10 @@ font-size: 80%; } +/* Override wrong system font from forms.css */ +html|button, html|select { + font: message-box; +} /* Autocomplete Popup */ diff --git a/devtools/client/themes/netmonitor.css b/devtools/client/themes/netmonitor.css index fea634a0e..eae6272be 100644 --- a/devtools/client/themes/netmonitor.css +++ b/devtools/client/themes/netmonitor.css @@ -8,6 +8,7 @@ } #react-clear-button-hook, +#react-summary-button-hook, #react-details-pane-toggle-hook { display: flex; } @@ -47,7 +48,7 @@ #details-pane-toggle, #details-pane.pane-collapsed, .requests-menu-waterfall, - #requests-menu-network-summary-button > .toolbarbutton-text { + #requests-menu-network-summary-button > .summary-info-text { display: none; } } @@ -744,16 +745,35 @@ /* Performance analysis buttons */ #requests-menu-network-summary-button { + display: flex; + align-items: center; background: none; box-shadow: none; border-color: transparent; - list-style-image: url(images/profiler-stopwatch.svg); padding-inline-end: 0; cursor: pointer; margin-inline-end: 1em; min-width: 0; } +#requests-menu-network-summary-button > .summary-info-icon { + background-image: url(images/profiler-stopwatch.svg); + filter: var(--icon-filter); + width: 16px; + height: 16px; + opacity: 0.8; +} + +#requests-menu-network-summary-button > .summary-info-text { + opacity: 0.8; + margin-inline-start: 0.5em; +} + +#requests-menu-network-summary-button:hover > .summary-info-icon, +#requests-menu-network-summary-button:hover > .summary-info-text { + opacity: 1; +} + /* Performance analysis view */ #network-statistics-toolbar { -- cgit v1.2.3 From b05346cf372073730179e1f287b73f170a22eb99 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 12:18:11 +0100 Subject: DevTools - Scratchpad - fix an old bug (Shift+Alt+R / Reload and Run) - follow up (Ctrl+Alt+R does not work) https://github.com/MoonchildProductions/moebius/pull/50 --- devtools/client/scratchpad/scratchpad.xul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/client/scratchpad/scratchpad.xul b/devtools/client/scratchpad/scratchpad.xul index 3712f163d..8694c1bb5 100644 --- a/devtools/client/scratchpad/scratchpad.xul +++ b/devtools/client/scratchpad/scratchpad.xul @@ -121,7 +121,7 @@ + modifiers="shift,alt"/> Date: Wed, 28 Feb 2018 12:30:08 +0100 Subject: Basilisk - the cmd line - help (the columns alignment, error improvements) - follow up https://github.com/MoonchildProductions/moebius/pull/58 --- toolkit/components/console/jsconsole-clhandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/components/console/jsconsole-clhandler.js b/toolkit/components/console/jsconsole-clhandler.js index 7e5d0ea51..1fff88890 100644 --- a/toolkit/components/console/jsconsole-clhandler.js +++ b/toolkit/components/console/jsconsole-clhandler.js @@ -31,7 +31,7 @@ jsConsoleHandler.prototype = { cmdLine.preventDefault = true; }, - helpInfo : " -jsconsole Open the Error console.\n", + helpInfo : " --jsconsole Open the Error console.\n", classID: Components.ID("{2cd0c310-e127-44d0-88fc-4435c9ab4d4b}"), QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), -- cgit v1.2.3 From 9fafdd4546bb51ff2a29a67f369797d19d614350 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 15:12:38 +0100 Subject: basilisk -jsdebugger - Import Console.jsm before calling console.[something] https://github.com/MoonchildProductions/moebius/pull/250 --- devtools/client/devtools-startup.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devtools/client/devtools-startup.js b/devtools/client/devtools-startup.js index f07e4ff2b..377ab6419 100644 --- a/devtools/client/devtools-startup.js +++ b/devtools/client/devtools-startup.js @@ -104,12 +104,14 @@ DevToolsStartup.prototype = { return Services.prefs.getBoolPref(pref); }); } catch (ex) { + let { console } = Cu.import("resource://gre/modules/Console.jsm", {}); console.error(ex); return false; } if (!remoteDebuggingEnabled) { let errorMsg = "Could not run chrome debugger! You need the following " + "prefs to be set to true: " + kDebuggerPrefs.join(", "); + let { console } = Cu.import("resource://gre/modules/Console.jsm", {}); console.error(new Error(errorMsg)); // Dump as well, as we're doing this from a commandline, make sure people // don't miss it: -- cgit v1.2.3 From abf60058584772437a317fbc27ea32cbda4a07cb Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 16:02:31 +0100 Subject: Bug 1168376: Show transferred size in request summary instead of decompressed size https://github.com/MoonchildProductions/moebius/pull/93 - without: DOMContentLoaded and load --- .../client/locales/en-US/netmonitor.properties | 39 +++++++++++++++---- .../client/netmonitor/components/summary-button.js | 18 +++++---- devtools/client/netmonitor/netmonitor-view.js | 2 +- .../netmonitor/performance-statistics-view.js | 36 ++++++++++++----- devtools/client/netmonitor/selectors/index.js | 27 ++++++++++--- .../netmonitor/test/browser_net_charts-03.js | 45 ++++++++++++++-------- .../netmonitor/test/browser_net_charts-04.js | 16 +++++--- .../netmonitor/test/browser_net_charts-05.js | 10 +++-- .../netmonitor/test/browser_net_charts-07.js | 16 +++++--- .../netmonitor/test/browser_net_footer-summary.js | 13 ++++--- devtools/client/shared/widgets/Chart.jsm | 25 ++++++++++-- 11 files changed, 177 insertions(+), 70 deletions(-) diff --git a/devtools/client/locales/en-US/netmonitor.properties b/devtools/client/locales/en-US/netmonitor.properties index e6118ca9f..f07f38907 100644 --- a/devtools/client/locales/en-US/netmonitor.properties +++ b/devtools/client/locales/en-US/netmonitor.properties @@ -143,12 +143,12 @@ networkMenu.sortedDesc=Sorted descending # in the network table footer when there are no requests available. networkMenu.empty=No requests -# LOCALIZATION NOTE (networkMenu.summary): Semi-colon list of plural forms. +# LOCALIZATION NOTE (networkMenu.summary2): Semi-colon list of plural forms. # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals # This label is displayed in the network table footer providing concise # information about all requests. Parameters: #1 is the number of requests, -# #2 is the size, #3 is the number of seconds. -networkMenu.summary=One request, #2 KB, #3 s;#1 requests, #2 KB, #3 s +# #2 is the size, #3 is the transferred size, #4 is the number of seconds. +networkMenu.summary2=One request, #2 KB (transferred: #3 KB), #4 s;#1 requests, #2 KB (transferred: #3 KB), #4 s # LOCALIZATION NOTE (networkMenu.sizeB): This is the label displayed # in the network menu specifying the size of a request (in bytes). @@ -221,10 +221,22 @@ tableChart.unavailable=No data available # in pie or table charts specifying the size of a request (in kilobytes). charts.sizeKB=%S KB +# LOCALIZATION NOTE (charts.transferredSizeKB): This is the label displayed +# in pie or table charts specifying the size of a transferred request (in kilobytes). +charts.transferredSizeKB=%S KB + # LOCALIZATION NOTE (charts.totalS): This is the label displayed # in pie or table charts specifying the time for a request to finish (in seconds). charts.totalS=%S s +# LOCALIZATION NOTE (charts.totalSize): This is the label displayed +# in the performance analysis view for total requests size, in kilobytes. +charts.totalSize=Size: %S KB + +# LOCALIZATION NOTE (charts.totalTranferredSize): This is the label displayed +# in the performance analysis view for total transferred size, in kilobytes. +charts.totalTransferredSize=Transferred Size: %S KB + # LOCALIZATION NOTE (charts.cacheEnabled): This is the label displayed # in the performance analysis view for "cache enabled" charts. charts.cacheEnabled=Primed cache @@ -233,10 +245,6 @@ charts.cacheEnabled=Primed cache # in the performance analysis view for "cache disabled" charts. charts.cacheDisabled=Empty cache -# LOCALIZATION NOTE (charts.totalSize): This is the label displayed -# in the performance analysis view for total requests size, in kilobytes. -charts.totalSize=Size: %S KB - # LOCALIZATION NOTE (charts.totalSeconds): Semi-colon list of plural forms. # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals # This is the label displayed in the performance analysis view for the @@ -251,6 +259,23 @@ charts.totalCached=Cached responses: %S # in the performance analysis view for total requests. charts.totalCount=Total requests: %S +# LOCALIZATION NOTE (charts.size): This is the label displayed +# in the header column in the performance analysis view for size of the request. +charts.size=Size + +# LOCALIZATION NOTE (charts.type): This is the label displayed +# in the header column in the performance analysis view for type of request. +charts.type=Type + +# LOCALIZATION NOTE (charts.transferred): This is the label displayed +# in the header column in the performance analysis view for transferred +# size of the request. +charts.transferred=Transferred + +# LOCALIZATION NOTE (charts.time): This is the label displayed +# in the header column in the performance analysis view for time of request. +charts.time=Time + # LOCALIZATION NOTE (netRequest.headers): A label used for Headers tab # This tab displays list of HTTP headers netRequest.headers=Headers diff --git a/devtools/client/netmonitor/components/summary-button.js b/devtools/client/netmonitor/components/summary-button.js index 9465d3147..223552fbf 100644 --- a/devtools/client/netmonitor/components/summary-button.js +++ b/devtools/client/netmonitor/components/summary-button.js @@ -14,21 +14,25 @@ const { DOM, PropTypes } = require("devtools/client/shared/vendor/react"); const { connect } = require("devtools/client/shared/vendor/react-redux"); const { PluralForm } = require("devtools/shared/plural-form"); const { L10N } = require("../l10n"); -const { getSummary } = require("../selectors/index"); +const { + getDisplayedRequestsSummary +} = require("../selectors/index"); const { button, span } = DOM; function SummaryButton({ summary, - triggerSummary, + triggerSummary }) { - let { count, totalBytes, totalMillis } = summary; + let { count, contentSize, transferredSize, millis } = summary; const text = (count === 0) ? L10N.getStr("networkMenu.empty") : - PluralForm.get(count, L10N.getStr("networkMenu.summary")) + PluralForm.get(count, L10N.getStr("networkMenu.summary2")) .replace("#1", count) - .replace("#2", L10N.numberWithDecimals(totalBytes / 1024, + .replace("#2", L10N.numberWithDecimals(contentSize / 1024, CONTENT_SIZE_DECIMALS)) - .replace("#3", L10N.numberWithDecimals(totalMillis / 1000, + .replace("#3", L10N.numberWithDecimals(transferredSize / 1024, + CONTENT_SIZE_DECIMALS)) + .replace("#4", L10N.numberWithDecimals(millis / 1000, REQUEST_TIME_DECIMALS)); return button({ @@ -47,7 +51,7 @@ SummaryButton.propTypes = { module.exports = connect( (state) => ({ - summary: getSummary(state), + summary: getDisplayedRequestsSummary(state), }), (dispatch) => ({ triggerSummary: () => { diff --git a/devtools/client/netmonitor/netmonitor-view.js b/devtools/client/netmonitor/netmonitor-view.js index 8da5a2038..1f957db1b 100644 --- a/devtools/client/netmonitor/netmonitor-view.js +++ b/devtools/client/netmonitor/netmonitor-view.js @@ -233,7 +233,7 @@ var NetMonitorView = { // populating the statistics view. // • The response mime type is used for categorization. yield whenDataAvailable(requestsView, [ - "responseHeaders", "status", "contentSize", "mimeType", "totalTime" + "responseHeaders", "status", "contentSize", "transferredSize", "mimeType", "totalTime" ]); } catch (ex) { // Timed out while waiting for data. Continue with what we have. diff --git a/devtools/client/netmonitor/performance-statistics-view.js b/devtools/client/netmonitor/performance-statistics-view.js index c712c083d..38b98fb68 100644 --- a/devtools/client/netmonitor/performance-statistics-view.js +++ b/devtools/client/netmonitor/performance-statistics-view.js @@ -92,27 +92,35 @@ PerformanceStatisticsView.prototype = { let string = L10N.numberWithDecimals(value / 1024, CONTENT_SIZE_DECIMALS); return L10N.getFormatStr("charts.sizeKB", string); }, + transferredSize: value => { + let string = L10N.numberWithDecimals(value / 1024, CONTENT_SIZE_DECIMALS); + return L10N.getFormatStr("charts.transferredSizeKB", string); + }, time: value => { let string = L10N.numberWithDecimals(value / 1000, REQUEST_TIME_DECIMALS); return L10N.getFormatStr("charts.totalS", string); } }, _commonChartTotals: { + cached: total => { + return L10N.getFormatStr("charts.totalCached", total); + }, + count: total => { + return L10N.getFormatStr("charts.totalCount", total); + }, size: total => { let string = L10N.numberWithDecimals(total / 1024, CONTENT_SIZE_DECIMALS); return L10N.getFormatStr("charts.totalSize", string); }, + transferredSize: total => { + let string = L10N.numberWithDecimals(total / 1024, CONTENT_SIZE_DECIMALS); + return L10N.getFormatStr("charts.totalTransferredSize", string); + }, time: total => { let seconds = total / 1000; let string = L10N.numberWithDecimals(seconds, REQUEST_TIME_DECIMALS); return PluralForm.get(seconds, L10N.getStr("charts.totalSeconds")).replace("#1", string); - }, - cached: total => { - return L10N.getFormatStr("charts.totalCached", total); - }, - count: total => { - return L10N.getFormatStr("charts.totalCount", total); } }, @@ -136,6 +144,14 @@ PerformanceStatisticsView.prototype = { let chart = Chart.PieTable(document, { diameter: NETWORK_ANALYSIS_PIE_CHART_DIAMETER, title: L10N.getStr(title), + header: { + cached: "", + count: "", + label: L10N.getStr("charts.type"), + size: L10N.getStr("charts.size"), + transferredSize: L10N.getStr("charts.transferred"), + time: L10N.getStr("charts.time") + }, data: data, strings: strings, totals: totals, @@ -161,13 +177,14 @@ PerformanceStatisticsView.prototype = { * True if the cache is considered enabled, false for disabled. */ _sanitizeChartDataSource: function (items, emptyCache) { - let data = [ + const data = [ "html", "css", "js", "xhr", "fonts", "images", "media", "flash", "ws", "other" - ].map(e => ({ + ].map((type) => ({ cached: 0, count: 0, - label: e, + label: type, size: 0, + transferredSize: 0, time: 0 })); @@ -211,6 +228,7 @@ PerformanceStatisticsView.prototype = { if (emptyCache || !responseIsFresh(details)) { data[type].time += details.totalTime || 0; data[type].size += details.contentSize || 0; + data[type].transferredSize += details.transferredSize || 0; } else { data[type].cached++; } diff --git a/devtools/client/netmonitor/selectors/index.js b/devtools/client/netmonitor/selectors/index.js index 8cd6b6ffc..60d6007cd 100644 --- a/devtools/client/netmonitor/selectors/index.js +++ b/devtools/client/netmonitor/selectors/index.js @@ -13,7 +13,7 @@ const { createSelector } = require("devtools/client/shared/vendor/reselect"); * @param {array} items - an array of request items * @return {number} total bytes of requests */ -function getTotalBytesOfRequests(items) { +function getContentSizeOfRequests(items) { if (!items.length) { return 0; } @@ -27,6 +27,20 @@ function getTotalBytesOfRequests(items) { return result; } +function getTransferredSizeOfRequests(items) { + if (!items.length) { + return 0; + } + + let result = 0; + items.forEach((item) => { + let size = item.attachment.transferredSize; + result += (typeof size == "number") ? size : 0; + }); + + return result; +} + /** * Gets the total milliseconds for all requests. Returns null for an * empty set. @@ -34,7 +48,7 @@ function getTotalBytesOfRequests(items) { * @param {array} items - an array of request items * @return {object} total milliseconds for all requests */ -function getTotalMillisOfRequests(items) { +function getMillisOfRequests(items) { if (!items.length) { return null; } @@ -49,15 +63,16 @@ function getTotalMillisOfRequests(items) { return newest.attachment.endedMillis - oldest.attachment.startedMillis; } -const getSummary = createSelector( +const getDisplayedRequestsSummary = createSelector( (state) => state.requests.items, (requests) => ({ count: requests.length, - totalBytes: getTotalBytesOfRequests(requests), - totalMillis: getTotalMillisOfRequests(requests), + contentSize: getContentSizeOfRequests(requests), + transferredSize: getTransferredSizeOfRequests(requests), + millis: getMillisOfRequests(requests), }) ); module.exports = { - getSummary, + getDisplayedRequestsSummary, }; diff --git a/devtools/client/netmonitor/test/browser_net_charts-03.js b/devtools/client/netmonitor/test/browser_net_charts-03.js index c7d9b0c1a..4a655a8ca 100644 --- a/devtools/client/netmonitor/test/browser_net_charts-03.js +++ b/devtools/client/netmonitor/test/browser_net_charts-03.js @@ -33,6 +33,10 @@ add_task(function* () { totals: { label1: value => "Hello " + L10N.numberWithDecimals(value, 2), label2: value => "World " + L10N.numberWithDecimals(value, 2) + }, + header: { + label1: "label1header", + label2: "label2header", } }); @@ -51,39 +55,48 @@ add_task(function* () { is(title.getAttribute("value"), "Table title", "The title node displays the correct text."); - is(rows.length, 3, "There should be 3 table chart rows created."); + is(rows.length, 4, "There should be 3 table chart rows and a header created."); - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), - "A colored blob exists for the firt row."); is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "label1", - "The first column of the first row exists."); + "The first column of the header exists."); is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label2", + "The second column of the header exists."); + is(rows[0].querySelectorAll("span")[0].textContent, "label1header", + "The first column of the header displays the correct text."); + is(rows[0].querySelectorAll("span")[1].textContent, "label2header", + "The second column of the header displays the correct text."); + + ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"), + "A colored blob exists for the firt row."); + is(rows[1].querySelectorAll("span")[0].getAttribute("name"), "label1", + "The first column of the first row exists."); + is(rows[1].querySelectorAll("span")[1].getAttribute("name"), "label2", "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "1", + is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "1", "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), "11.1foo", + is(rows[1].querySelectorAll("label")[1].getAttribute("value"), "11.1foo", "The second column of the first row displays the correct text."); - ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"), + ok(rows[2].querySelector(".table-chart-row-box.chart-colored-blob"), "A colored blob exists for the second row."); - is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "label1", + is(rows[2].querySelectorAll("label")[0].getAttribute("name"), "label1", "The first column of the second row exists."); - is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label2", + is(rows[2].querySelectorAll("label")[1].getAttribute("name"), "label2", "The second column of the second row exists."); - is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "2", + is(rows[2].querySelectorAll("label")[0].getAttribute("value"), "2", "The first column of the second row displays the correct text."); - is(rows[1].querySelectorAll("label")[1].getAttribute("value"), "12.2bar", + is(rows[2].querySelectorAll("label")[1].getAttribute("value"), "12.2bar", "The second column of the first row displays the correct text."); - ok(rows[2].querySelector(".table-chart-row-box.chart-colored-blob"), + ok(rows[3].querySelector(".table-chart-row-box.chart-colored-blob"), "A colored blob exists for the third row."); - is(rows[2].querySelectorAll("label")[0].getAttribute("name"), "label1", + is(rows[3].querySelectorAll("label")[0].getAttribute("name"), "label1", "The first column of the third row exists."); - is(rows[2].querySelectorAll("label")[1].getAttribute("name"), "label2", + is(rows[3].querySelectorAll("label")[1].getAttribute("name"), "label2", "The second column of the third row exists."); - is(rows[2].querySelectorAll("label")[0].getAttribute("value"), "3", + is(rows[3].querySelectorAll("label")[0].getAttribute("value"), "3", "The first column of the third row displays the correct text."); - is(rows[2].querySelectorAll("label")[1].getAttribute("value"), "13.3baz", + is(rows[3].querySelectorAll("label")[1].getAttribute("value"), "13.3baz", "The second column of the third row displays the correct text."); is(sums.length, 2, "There should be 2 total summaries created."); diff --git a/devtools/client/netmonitor/test/browser_net_charts-04.js b/devtools/client/netmonitor/test/browser_net_charts-04.js index 0d150c409..921701ae5 100644 --- a/devtools/client/netmonitor/test/browser_net_charts-04.js +++ b/devtools/client/netmonitor/test/browser_net_charts-04.js @@ -22,6 +22,10 @@ add_task(function* () { totals: { label1: value => "Hello " + L10N.numberWithDecimals(value, 2), label2: value => "World " + L10N.numberWithDecimals(value, 2) + }, + header: { + label1: "", + label2: "" } }); @@ -40,17 +44,17 @@ add_task(function* () { is(title.getAttribute("value"), "Table title", "The title node displays the correct text."); - is(rows.length, 1, "There should be 1 table chart row created."); + is(rows.length, 2, "There should be 1 table chart row and a 1 header created."); - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), + ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"), "A colored blob exists for the firt row."); - is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", + is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "size", "The first column of the first row exists."); - is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", + is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label", "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", + is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "", "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), + is(rows[1].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"), "The second column of the first row displays the correct text."); diff --git a/devtools/client/netmonitor/test/browser_net_charts-05.js b/devtools/client/netmonitor/test/browser_net_charts-05.js index 00445b132..c444d2c65 100644 --- a/devtools/client/netmonitor/test/browser_net_charts-05.js +++ b/devtools/client/netmonitor/test/browser_net_charts-05.js @@ -33,6 +33,10 @@ add_task(function* () { totals: { size: value => "Hello " + L10N.numberWithDecimals(value, 2), label: value => "World " + L10N.numberWithDecimals(value, 2) + }, + header: { + label1: "", + label2: "" } }); @@ -53,9 +57,9 @@ add_task(function* () { ok(node.querySelector(".table-chart-container"), "A table chart was created successfully."); - is(rows.length, 3, "There should be 3 pie chart slices created."); - is(rows.length, 3, "There should be 3 table chart rows created."); - is(sums.length, 2, "There should be 2 total summaries created."); + is(rows.length, 4, "There should be 3 pie chart slices and 1 header created."); + is(rows.length, 4, "There should be 3 table chart rows and 1 header created."); + is(sums.length, 2, "There should be 2 total summaries and 1 header created."); yield teardown(monitor); }); diff --git a/devtools/client/netmonitor/test/browser_net_charts-07.js b/devtools/client/netmonitor/test/browser_net_charts-07.js index bb992e4eb..a655f258c 100644 --- a/devtools/client/netmonitor/test/browser_net_charts-07.js +++ b/devtools/client/netmonitor/test/browser_net_charts-07.js @@ -20,6 +20,10 @@ add_task(function* () { totals: { label1: value => "Hello " + L10N.numberWithDecimals(value, 2), label2: value => "World " + L10N.numberWithDecimals(value, 2) + }, + header: { + label1: "", + label2: "" } }); @@ -29,17 +33,17 @@ add_task(function* () { let rows = grid.querySelectorAll(".table-chart-row"); let sums = node.querySelectorAll(".table-chart-summary-label"); - is(rows.length, 1, "There should be 1 table chart row created."); + is(rows.length, 2, "There should be 1 table chart row and 1 header created."); - ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), + ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"), "A colored blob exists for the firt row."); - is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", + is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "size", "The first column of the first row exists."); - is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", + is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label", "The second column of the first row exists."); - is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", + is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "", "The first column of the first row displays the correct text."); - is(rows[0].querySelectorAll("label")[1].getAttribute("value"), + is(rows[1].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"), "The second column of the first row displays the correct text."); diff --git a/devtools/client/netmonitor/test/browser_net_footer-summary.js b/devtools/client/netmonitor/test/browser_net_footer-summary.js index 94bfa604b..8faa8470b 100644 --- a/devtools/client/netmonitor/test/browser_net_footer-summary.js +++ b/devtools/client/netmonitor/test/browser_net_footer-summary.js @@ -44,7 +44,7 @@ add_task(function* () { yield teardown(monitor); function testStatus() { - const { count, totalBytes, totalMillis } = getSummary(gStore.getState()); + const { count, contentSize, transferredSize, millis } = getSummary(gStore.getState()); let value = $("#requests-menu-network-summary-button").textContent; info("Current summary: " + value); @@ -57,13 +57,14 @@ add_task(function* () { return; } - info("Computed total bytes: " + totalBytes); - info("Computed total millis: " + totalMillis); + info("Computed total bytes: " + contentSize); + info("Computed total millis: " + millis); - is(value, PluralForm.get(count, L10N.getStr("networkMenu.summary")) + is(value, PluralForm.get(count, L10N.getStr("networkMenu.summary2")) .replace("#1", count) - .replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, 2)) - .replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, 2)) + .replace("#2", L10N.numberWithDecimals((contentSize || 0) / 1024, 2)) + .replace("#3", L10N.numberWithDecimals((transferredSize || 0) / 1024, 2)) + .replace("#4", L10N.numberWithDecimals((millis || 0) / 1000, 2)) , "The current summary text is incorrect."); } }); diff --git a/devtools/client/shared/widgets/Chart.jsm b/devtools/client/shared/widgets/Chart.jsm index 0894a62ca..0b7cb71fb 100644 --- a/devtools/client/shared/widgets/Chart.jsm +++ b/devtools/client/shared/widgets/Chart.jsm @@ -105,7 +105,7 @@ function PieTableChart(node, pie, table) { * - "mouseout", when the mouse leaves a slice or a row * - "click", when the mouse enters a slice or a row */ -function createPieTableChart(document, { title, diameter, data, strings, totals, sorted }) { +function createPieTableChart(document, { title, diameter, data, strings, totals, sorted, header }) { if (data && sorted) { data = data.slice().sort((a, b) => +(a.size < b.size)); } @@ -119,7 +119,8 @@ function createPieTableChart(document, { title, diameter, data, strings, totals, title: title, data: data, strings: strings, - totals: totals + totals: totals, + header: header, }); let container = document.createElement("hbox"); @@ -338,7 +339,7 @@ function createPieChart(document, { data, width, height, centerX, centerY, radiu * - "mouseout", when the mouse leaves a row * - "click", when the mouse clicks a row */ -function createTableChart(document, { title, data, strings, totals }) { +function createTableChart(document, { title, data, strings, totals, header }) { strings = strings || {}; totals = totals || {}; let isPlaceholder = false; @@ -371,6 +372,24 @@ function createTableChart(document, { title, data, strings, totals }) { tableNode.className = "plain table-chart-grid"; container.appendChild(tableNode); + const headerNode = document.createElement("div"); + headerNode.className = "table-chart-row"; + + const headerBoxNode = document.createElement("div"); + headerBoxNode.className = "table-chart-row-box"; + headerNode.appendChild(headerBoxNode); + + for (let [key, value] of Object.entries(header)) { + let headerLabelNode = document.createElement("span"); + headerLabelNode.className = "plain table-chart-row-label"; + headerLabelNode.setAttribute("name", key); + headerLabelNode.textContent = value; + + headerNode.appendChild(headerLabelNode); + } + + tableNode.appendChild(headerNode); + for (let rowInfo of data) { let rowNode = document.createElement("hbox"); rowNode.className = "table-chart-row"; -- cgit v1.2.3 From e59c00a5c59aefe2a408eb78509ef3afaf3658f8 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 1 Mar 2018 07:17:50 +0100 Subject: DevTools - Browser Console - restore sessions https://github.com/MoonchildProductions/moebius/pull/112 --- browser/base/content/browser.js | 2 +- browser/components/sessionstore/SessionStore.jsm | 25 +++++++++ devtools/bootstrap.js | 2 +- .../commandline/test/browser_cmd_commands.js | 2 +- devtools/client/devtools-startup.js | 4 +- devtools/client/framework/toolbox.js | 2 +- devtools/client/menus.js | 2 +- devtools/client/scratchpad/scratchpad.js | 2 +- .../test/browser_scratchpad_open_error_console.js | 2 +- devtools/client/webconsole/hudservice.js | 59 +++++++++++++++++----- devtools/client/webconsole/panel.js | 2 +- devtools/client/webconsole/test/browser.ini | 1 + devtools/client/webconsole/test/browser_console.js | 19 +------ .../webconsole/test/browser_console_restore.js | 30 +++++++++++ devtools/client/webconsole/test/head.js | 17 ++++++- .../webextensions/ext-c-backgroundPage.js | 4 +- .../mochitest/test_chrome_ext_background_page.html | 6 +-- 17 files changed, 135 insertions(+), 46 deletions(-) create mode 100644 devtools/client/webconsole/test/browser_console_restore.js diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 910dc4f68..f2f64d75d 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -7913,7 +7913,7 @@ var TabContextMenu = { Object.defineProperty(this, "HUDService", { get: function HUDService_getter() { let devtools = Cu.import("resource://devtools/shared/Loader.jsm", {}).devtools; - return devtools.require("devtools/client/webconsole/hudservice"); + return devtools.require("devtools/client/webconsole/hudservice").HUDService; }, configurable: true, enumerable: true diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 2f44b2af3..93e21357f 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -186,6 +186,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "ViewSourceBrowser", XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown", "resource://gre/modules/AsyncShutdown.jsm"); +Object.defineProperty(this, "HUDService", { + get: function HUDService_getter() { + let devtools = Cu.import("resource://devtools/shared/Loader.jsm", {}).devtools; + return devtools.require("devtools/client/webconsole/hudservice").HUDService; + }, + configurable: true, + enumerable: true +}); + /** * |true| if we are in debug mode, |false| otherwise. * Debug mode is controlled by preference browser.sessionstore.debug @@ -2570,10 +2579,16 @@ var SessionStoreInternal = { this._capClosedWindows(); } + // Scratchpad if (lastSessionState.scratchpads) { ScratchpadManager.restoreSession(lastSessionState.scratchpads); } + // The Browser Console + if (lastSessionState.browserConsole) { + HUDService.restoreBrowserConsoleSession(); + } + // Set data that persists between sessions this._recentCrashes = lastSessionState.session && lastSessionState.session.recentCrashes || 0; @@ -2931,6 +2946,7 @@ var SessionStoreInternal = { global: this._globalState.getState() }; + // Scratchpad if (Cu.isModuleLoaded("resource://devtools/client/scratchpad/scratchpad-manager.jsm")) { // get open Scratchpad window states too let scratchpads = ScratchpadManager.getSessionState(); @@ -2939,6 +2955,9 @@ var SessionStoreInternal = { } } + // The Browser Console + state.browserConsole = HUDService.getBrowserConsoleSessionState(); + // Persist the last session if we deferred restoring it if (LastSession.canRestore) { state.lastSessionState = LastSession.getState(); @@ -3290,9 +3309,15 @@ var SessionStoreInternal = { this.restoreWindow(aWindow, root.windows[0], aOptions); + // Scratchpad if (aState.scratchpads) { ScratchpadManager.restoreSession(aState.scratchpads); } + + // The Browser Console + if (aState.browserConsole) { + HUDService.restoreBrowserConsoleSession(); + } }, /** diff --git a/devtools/bootstrap.js b/devtools/bootstrap.js index bedca0c78..3c154fef4 100644 --- a/devtools/bootstrap.js +++ b/devtools/bootstrap.js @@ -187,7 +187,7 @@ function reload(event) { // HUDService is going to close it on unload. // Instead we have to manually toggle it. if (reopenBrowserConsole) { - let HUDService = devtools.require("devtools/client/webconsole/hudservice"); + let {HUDService} = devtools.require("devtools/client/webconsole/hudservice"); HUDService.toggleBrowserConsole(); } diff --git a/devtools/client/commandline/test/browser_cmd_commands.js b/devtools/client/commandline/test/browser_cmd_commands.js index 6c69034ec..78db77bfd 100644 --- a/devtools/client/commandline/test/browser_cmd_commands.js +++ b/devtools/client/commandline/test/browser_cmd_commands.js @@ -4,7 +4,7 @@ // Test various GCLI commands const TEST_URI = "data:text/html;charset=utf-8,gcli-commands"; -const HUDService = require("devtools/client/webconsole/hudservice"); +const {HUDService} = require("devtools/client/webconsole/hudservice"); // Use the old webconsole since pprint isn't working on new one (Bug 1304794) Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false); diff --git a/devtools/client/devtools-startup.js b/devtools/client/devtools-startup.js index 377ab6419..8f55184d2 100644 --- a/devtools/client/devtools-startup.js +++ b/devtools/client/devtools-startup.js @@ -75,9 +75,9 @@ DevToolsStartup.prototype = { this.initDevTools(); let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); - let hudservice = require("devtools/client/webconsole/hudservice"); + let { HUDService } = require("devtools/client/webconsole/hudservice"); let { console } = Cu.import("resource://gre/modules/Console.jsm", {}); - hudservice.toggleBrowserConsole().then(null, console.error); + HUDService.toggleBrowserConsole().then(null, console.error); } else { // the Browser Console was already open window.focus(); diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index 82d5d2915..926e30647 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -22,7 +22,7 @@ var {Task} = require("devtools/shared/task"); var {gDevTools} = require("devtools/client/framework/devtools"); var EventEmitter = require("devtools/shared/event-emitter"); var Telemetry = require("devtools/client/shared/telemetry"); -var HUDService = require("devtools/client/webconsole/hudservice"); +var { HUDService } = require("devtools/client/webconsole/hudservice"); var viewSource = require("devtools/client/shared/view-source"); var { attachThread, detachThread } = require("./attach-thread"); var Menu = require("devtools/client/framework/menu"); diff --git a/devtools/client/menus.js b/devtools/client/menus.js index 1aee85095..7e36839da 100644 --- a/devtools/client/menus.js +++ b/devtools/client/menus.js @@ -120,7 +120,7 @@ exports.menuitems = [ { id: "menu_browserConsole", l10nKey: "browserConsoleCmd", oncommand() { - let HUDService = require("devtools/client/webconsole/hudservice"); + let {HUDService} = require("devtools/client/webconsole/hudservice"); HUDService.openBrowserConsoleOrFocus(); }, key: { diff --git a/devtools/client/scratchpad/scratchpad.js b/devtools/client/scratchpad/scratchpad.js index 306b635df..b210e3906 100644 --- a/devtools/client/scratchpad/scratchpad.js +++ b/devtools/client/scratchpad/scratchpad.js @@ -81,7 +81,7 @@ loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true); loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true); loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/main", true); loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/main", true); -loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice"); +loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice", true); XPCOMUtils.defineLazyGetter(this, "REMOTE_TIMEOUT", () => Services.prefs.getIntPref("devtools.debugger.remote-timeout")); diff --git a/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js b/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js index 4da2a2daf..418bdfb56 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js @@ -2,7 +2,7 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -const HUDService = require("devtools/client/webconsole/hudservice"); +const {HUDService} = require("devtools/client/webconsole/hudservice"); function test() { diff --git a/devtools/client/webconsole/hudservice.js b/devtools/client/webconsole/hudservice.js index 46b4f2a13..beb592367 100644 --- a/devtools/client/webconsole/hudservice.js +++ b/devtools/client/webconsole/hudservice.js @@ -51,6 +51,23 @@ HUD_SERVICE.prototype = */ consoles: null, + _browerConsoleSessionState: false, + storeBrowserConsoleSessionState() { + this._browerConsoleSessionState = !!this.getBrowserConsole(); + }, + getBrowserConsoleSessionState() { + return this._browerConsoleSessionState; + }, + + /** + * Restore the Browser Console as provided by SessionStore. + */ + restoreBrowserConsoleSession: function HS_restoreBrowserConsoleSession() { + if (!HUDService.getBrowserConsole()) { + HUDService.toggleBrowserConsole(); + } + }, + /** * Assign a function to this property to listen for every request that * completes. Used by unit tests. The callback takes one argument: the HTTP @@ -647,6 +664,9 @@ BrowserConsole.prototype = extend(WebConsole.prototype, { return this._bc_init; } + // Only add the shutdown observer if we've opened a Browser Console window. + ShutdownObserver.init(); + this.ui._filterPrefsPrefix = BROWSER_CONSOLE_FILTER_PREFS_PREFIX; let window = this.iframeWindow; @@ -702,17 +722,32 @@ BrowserConsole.prototype = extend(WebConsole.prototype, { }, }); -const HUDService = new HUD_SERVICE(); +exports.HUDService = HUDService; -(() => { - let methods = ["openWebConsole", "openBrowserConsole", - "toggleBrowserConsole", "getOpenWebConsole", - "getBrowserConsole", "getHudByWindow", - "openBrowserConsoleOrFocus", "getHudReferenceById"]; - for (let method of methods) { - exports[method] = HUDService[method].bind(HUDService); - } +/** + * The ShutdownObserver listens for app shutdown and saves the current state + * of the Browser Console for session restore. + */ +var ShutdownObserver = { + _initialized: false, + init() { + if (this._initialized) { + return; + } + + Services.obs.addObserver(this, "quit-application-granted", false); + + this._initialized = true; + }, - exports.consoles = HUDService.consoles; - exports.lastFinishedRequest = HUDService.lastFinishedRequest; -})(); + observe(message, topic) { + if (topic == "quit-application-granted") { + HUDService.storeBrowserConsoleSessionState(); + this.uninit(); + } + }, + + uninit() { + Services.obs.removeObserver(this, "quit-application-granted"); + } +}; diff --git a/devtools/client/webconsole/panel.js b/devtools/client/webconsole/panel.js index 3e3a4f4b9..b692de681 100644 --- a/devtools/client/webconsole/panel.js +++ b/devtools/client/webconsole/panel.js @@ -8,7 +8,7 @@ const promise = require("promise"); -loader.lazyGetter(this, "HUDService", () => require("devtools/client/webconsole/hudservice")); +loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice", true); loader.lazyGetter(this, "EventEmitter", () => require("devtools/shared/event-emitter")); /** diff --git a/devtools/client/webconsole/test/browser.ini b/devtools/client/webconsole/test/browser.ini index 918411182..1c7913835 100644 --- a/devtools/client/webconsole/test/browser.ini +++ b/devtools/client/webconsole/test/browser.ini @@ -182,6 +182,7 @@ subsuite = clipboard [browser_console_optimized_out_vars.js] [browser_console_private_browsing.js] skip-if = e10s # Bug 1042253 - webconsole e10s tests +[browser_console_restore.js] [browser_console_server_logging.js] [browser_console_variables_view.js] [browser_console_variables_view_filter.js] diff --git a/devtools/client/webconsole/test/browser_console.js b/devtools/client/webconsole/test/browser_console.js index 7bd1ffdc2..4358ac0f1 100644 --- a/devtools/client/webconsole/test/browser_console.js +++ b/devtools/client/webconsole/test/browser_console.js @@ -22,7 +22,7 @@ const TEST_IMAGE = "http://example.com/browser/devtools/client/webconsole/" + add_task(function* () { yield loadTab(TEST_URI); - let opened = waitForConsole(); + let opened = waitForBrowserConsole(); let hud = HUDService.getBrowserConsole(); ok(!hud, "browser console is not open"); @@ -141,20 +141,3 @@ function consoleOpened(hud) { ], }); } - -function waitForConsole() { - let deferred = promise.defer(); - - Services.obs.addObserver(function observer(aSubject) { - Services.obs.removeObserver(observer, "web-console-created"); - aSubject.QueryInterface(Ci.nsISupportsString); - - let hud = HUDService.getBrowserConsole(); - ok(hud, "browser console is open"); - is(aSubject.data, hud.hudId, "notification hudId is correct"); - - executeSoon(() => deferred.resolve(hud)); - }, "web-console-created", false); - - return deferred.promise; -} diff --git a/devtools/client/webconsole/test/browser_console_restore.js b/devtools/client/webconsole/test/browser_console_restore.js new file mode 100644 index 000000000..fb08d9c70 --- /dev/null +++ b/devtools/client/webconsole/test/browser_console_restore.js @@ -0,0 +1,30 @@ +/* -*- 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/ */ + +// Check that the browser console gets session state is set correctly, and that +// it re-opens when restore is requested. + +"use strict"; + +add_task(function* () { + is(HUDService.getBrowserConsoleSessionState(), false, "Session state false by default"); + HUDService.storeBrowserConsoleSessionState(); + is(HUDService.getBrowserConsoleSessionState(), false, + "Session state still not true even after setting (since Browser Console is closed)"); + + yield HUDService.toggleBrowserConsole(); + HUDService.storeBrowserConsoleSessionState(); + is(HUDService.getBrowserConsoleSessionState(), true, + "Session state true (since Browser Console is opened)"); + + info("Closing the browser console and waiting for the session restore to reopen it") + yield HUDService.toggleBrowserConsole(); + + let opened = waitForBrowserConsole(); + HUDService.restoreBrowserConsoleSession(); + + info("Waiting for the console to open after session restore") + yield opened; +}); diff --git a/devtools/client/webconsole/test/head.js b/devtools/client/webconsole/test/head.js index 519cb78b0..2787933c4 100644 --- a/devtools/client/webconsole/test/head.js +++ b/devtools/client/webconsole/test/head.js @@ -12,7 +12,7 @@ Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtool var {Utils: WebConsoleUtils} = require("devtools/client/webconsole/utils"); var {Messages} = require("devtools/client/webconsole/console-output"); const asyncStorage = require("devtools/shared/async-storage"); -const HUDService = require("devtools/client/webconsole/hudservice"); +const {HUDService} = require("devtools/client/webconsole/hudservice"); // Services.prefs.setBoolPref("devtools.debugger.log", true); @@ -1842,3 +1842,18 @@ function getRenderedSource(root) { column: location.getAttribute("data-column"), } : null; } + +function waitForBrowserConsole() { + return new Promise(resolve => { + Services.obs.addObserver(function observer(subject) { + Services.obs.removeObserver(observer, "web-console-created"); + subject.QueryInterface(Ci.nsISupportsString); + + let hud = HUDService.getBrowserConsole(); + ok(hud, "browser console is open"); + is(subject.data, hud.hudId, "notification hudId is correct"); + + executeSoon(() => resolve(hud)); + }, "web-console-created"); + }); +} diff --git a/toolkit/components/webextensions/ext-c-backgroundPage.js b/toolkit/components/webextensions/ext-c-backgroundPage.js index b5074dd9a..ca446ce79 100644 --- a/toolkit/components/webextensions/ext-c-backgroundPage.js +++ b/toolkit/components/webextensions/ext-c-backgroundPage.js @@ -9,8 +9,8 @@ global.initializeBackgroundPage = (contentWindow) => { if (!alertDisplayedWarning) { require("devtools/client/framework/devtools-browser"); - let hudservice = require("devtools/client/webconsole/hudservice"); - hudservice.openBrowserConsoleOrFocus(); + let {HUDService} = require("devtools/client/webconsole/hudservice"); + HUDService.openBrowserConsoleOrFocus(); contentWindow.console.warn("alert() is not supported in background windows; please use console.log instead."); diff --git a/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html index 3c4774652..471c5339d 100644 --- a/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html +++ b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html @@ -66,14 +66,14 @@ add_task(function* testAlertNotShownInBackgroundWindow() { let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); require("devtools/client/framework/devtools-browser"); - let hudservice = require("devtools/client/webconsole/hudservice"); + let {HUDService} = require("devtools/client/webconsole/hudservice"); // And then double check that we have an actual browser console. - let haveConsole = !!hudservice.getBrowserConsole(); + let haveConsole = !!HUDService.getBrowserConsole(); ok(haveConsole, "Expected browser console to be open"); if (haveConsole) { - yield hudservice.toggleBrowserConsole(); + yield HUDService.toggleBrowserConsole(); } yield extension.unload(); -- cgit v1.2.3 From 46ecf68249ec70bbd68b57f92f9d48e5c95636b7 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 1 Mar 2018 08:36:32 +0100 Subject: DevTools - Browser Console - restore sessions (follow up) https://github.com/MoonchildProductions/moebius/pull/112 --- devtools/client/webconsole/hudservice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/client/webconsole/hudservice.js b/devtools/client/webconsole/hudservice.js index beb592367..3023b7bb3 100644 --- a/devtools/client/webconsole/hudservice.js +++ b/devtools/client/webconsole/hudservice.js @@ -722,6 +722,7 @@ BrowserConsole.prototype = extend(WebConsole.prototype, { }, }); +const HUDService = new HUD_SERVICE(); exports.HUDService = HUDService; /** -- cgit v1.2.3 From 228d252ab14f65f8433c8d53122a7d1e9429c23e Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 1 Mar 2018 09:02:37 +0100 Subject: DevTools - network - security (improvements) https://github.com/MoonchildProductions/moebius/pull/113 https://github.com/MoonchildProductions/moebius/pull/118 https://github.com/MoonchildProductions/moebius/pull/127 --- .../client/locales/en-US/netmonitor.properties | 31 +++++++ devtools/client/netmonitor/netmonitor-view.js | 2 + devtools/client/netmonitor/netmonitor.xul | 20 +++++ .../test/browser_net_security-details.js | 4 + devtools/shared/webconsole/network-helper.js | 27 ++++++ security/manager/ssl/nsISSLStatus.idl | 4 + security/manager/ssl/nsNSSCallbacks.cpp | 96 ++++++++++++++++++++++ security/manager/ssl/nsNSSIOLayer.cpp | 4 + security/manager/ssl/nsSSLStatus.cpp | 42 +++++++++- security/manager/ssl/nsSSLStatus.h | 2 + .../meta/navigation-timing/idlharness.html.ini | 6 -- toolkit/components/telemetry/Histograms.json | 31 ++++++- .../components/telemetry/histogram-whitelists.json | 4 - 13 files changed, 258 insertions(+), 15 deletions(-) diff --git a/devtools/client/locales/en-US/netmonitor.properties b/devtools/client/locales/en-US/netmonitor.properties index f07f38907..1f6f671c9 100644 --- a/devtools/client/locales/en-US/netmonitor.properties +++ b/devtools/client/locales/en-US/netmonitor.properties @@ -617,6 +617,37 @@ netmonitor.security.protocolVersion=Protocol version: # in the security tab describing the cipher suite used to secure this connection. netmonitor.security.cipherSuite=Cipher suite: +# LOCALIZATION NOTE (netmonitor.security.keaGroup): This is the label displayed +# in the security tab describing the key exchange group suite used to secure +# this connection. +netmonitor.security.keaGroup=Key Exchange Group: + +# LOCALIZATION NOTE (netmonitor.security.keaGroup.none): This is the label +# displayed in the security tab describing the case when no group was used. +netmonitor.security.keaGroup.none=none + +# LOCALIZATION NOTE (netmonitor.security.keaGroup.custom): This is the label +# displayed in the security tab describing the case when a custom group was used. +netmonitor.security.keaGroup.custom=custom + +# LOCALIZATION NOTE (netmonitor.security.keaGroup.unknown): This is the value +# displayed in the security tab describing an unknown group. +netmonitor.security.keaGroup.unknown=unknown group + +# LOCALIZATION NOTE (netmonitor.security.signatureScheme): This is the label +# displayed in the security tab describing the signature scheme used by for +# the server certificate in this connection. +netmonitor.security.signatureScheme=Signature Scheme: + +# LOCALIZATION NOTE (netmonitor.security.signatureScheme.none): This is the +# label displayed in the security tab describing the case when no signature +# was used. +netmonitor.security.signatureScheme.none=none + +# LOCALIZATION NOTE (netmonitor.security.signatureScheme.unknown): This is the +# value displayed in the security tab describing an unknown signature scheme. +netmonitor.security.signatureScheme.unknown=unknown signature scheme + # LOCALIZATION NOTE (netmonitor.security.hsts): This is the label displayed # in the security tab describing the usage of HTTP Strict Transport Security. netmonitor.security.hsts=HTTP Strict Transport Security: diff --git a/devtools/client/netmonitor/netmonitor-view.js b/devtools/client/netmonitor/netmonitor-view.js index 1f957db1b..19dd96ff1 100644 --- a/devtools/client/netmonitor/netmonitor-view.js +++ b/devtools/client/netmonitor/netmonitor-view.js @@ -1124,6 +1124,8 @@ NetworkDetailsView.prototype = { setValue("#security-protocol-version-value", securityInfo.protocolVersion); setValue("#security-ciphersuite-value", securityInfo.cipherSuite); + setValue("#security-keagroup-value", securityInfo.keaGroupName); + setValue("#security-signaturescheme-value", securityInfo.signatureSchemeName); // Host header let domain = getUriHostPort(url); diff --git a/devtools/client/netmonitor/netmonitor.xul b/devtools/client/netmonitor/netmonitor.xul index 8a0c60389..117ecf261 100644 --- a/devtools/client/netmonitor/netmonitor.xul +++ b/devtools/client/netmonitor/netmonitor.xul @@ -550,6 +550,26 @@ id="security-warning-cipher" data-localization="tooltiptext=netmonitor.security.warning.cipher" /> + + + + "); + // These two values can change. So only check they're not empty. + checkLabelNotEmpty("#security-keagroup-value"); + checkLabelNotEmpty("#security-signaturescheme-value"); + // Locale sensitive and varies between timezones. Cant't compare equality or // the test fails depending on which part of the world the test is executed. checkLabelNotEmpty("#security-cert-validity-begins"); diff --git a/devtools/shared/webconsole/network-helper.js b/devtools/shared/webconsole/network-helper.js index af6a2e55b..4e25fac26 100644 --- a/devtools/shared/webconsole/network-helper.js +++ b/devtools/shared/webconsole/network-helper.js @@ -63,6 +63,8 @@ const {components, Cc, Ci} = require("chrome"); loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const Services = require("Services"); +const { LocalizationHelper } = require("devtools/shared/l10n"); +const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties"); // The cache used in the `nsIURL` function. const gNSURLStore = new Map(); @@ -620,6 +622,31 @@ var NetworkHelper = { // Cipher suite. info.cipherSuite = SSLStatus.cipherName; + // Key exchange group name. + info.keaGroupName = SSLStatus.keaGroupName; + // Localise two special values. + if (info.keaGroupName == "none") { + info.keaGroupName = L10N.getStr("netmonitor.security.keaGroup.none"); + } + if (info.keaGroupName == "custom") { + info.keaGroupName = L10N.getStr("netmonitor.security.keaGroup.custom"); + } + if (info.keaGroupName == "unknown group") { + info.keaGroupName = L10N.getStr("netmonitor.security.keaGroup.unknown"); + } + + // Certificate signature scheme. + info.signatureSchemeName = SSLStatus.signatureSchemeName; + // Localise two special values. + if (info.signatureSchemeName == "none") { + info.signatureSchemeName = + L10N.getStr("netmonitor.security.signatureScheme.none"); + } + if (info.signatureSchemeName == "unknown signature") { + info.signatureSchemeName = + L10N.getStr("netmonitor.security.signatureScheme.unknown"); + } + // Protocol version. info.protocolVersion = this.formatSecurityProtocol(SSLStatus.protocolVersion); diff --git a/security/manager/ssl/nsISSLStatus.idl b/security/manager/ssl/nsISSLStatus.idl index f5c56a8cf..52cb1df30 100644 --- a/security/manager/ssl/nsISSLStatus.idl +++ b/security/manager/ssl/nsISSLStatus.idl @@ -15,6 +15,10 @@ interface nsISSLStatus : nsISupports { readonly attribute ACString cipherName; readonly attribute unsigned long keyLength; readonly attribute unsigned long secretKeyLength; + [must_use] + readonly attribute ACString keaGroupName; + [must_use] + readonly attribute ACString signatureSchemeName; const short SSL_VERSION_3 = 0; const short TLS_VERSION_1 = 1; diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp index e28760d5f..941101265 100644 --- a/security/manager/ssl/nsNSSCallbacks.cpp +++ b/security/manager/ssl/nsNSSCallbacks.cpp @@ -848,6 +848,99 @@ PK11PasswordPrompt(PK11SlotInfo* slot, PRBool /*retry*/, void* arg) return runnable->mResult; } +static nsCString +getKeaGroupName(uint32_t aKeaGroup) +{ + nsCString groupName; + switch (aKeaGroup) { + case ssl_grp_ec_secp256r1: + groupName = NS_LITERAL_CSTRING("P256"); + break; + case ssl_grp_ec_secp384r1: + groupName = NS_LITERAL_CSTRING("P384"); + break; + case ssl_grp_ec_secp521r1: + groupName = NS_LITERAL_CSTRING("P521"); + break; + case ssl_grp_ec_curve25519: + groupName = NS_LITERAL_CSTRING("x25519"); + break; + case ssl_grp_ffdhe_2048: + groupName = NS_LITERAL_CSTRING("FF 2048"); + break; + case ssl_grp_ffdhe_3072: + groupName = NS_LITERAL_CSTRING("FF 3072"); + break; + case ssl_grp_none: + groupName = NS_LITERAL_CSTRING("none"); + break; + case ssl_grp_ffdhe_custom: + groupName = NS_LITERAL_CSTRING("custom"); + break; + // All other groups are not enabled in Firefox. See namedGroups in + // nsNSSIOLayer.cpp. + default: + // This really shouldn't happen! + MOZ_ASSERT_UNREACHABLE("Invalid key exchange group."); + groupName = NS_LITERAL_CSTRING("unknown group"); + } + return groupName; +} + +static nsCString +getSignatureName(uint32_t aSignatureScheme) +{ + nsCString signatureName; + switch (aSignatureScheme) { + case ssl_sig_none: + signatureName = NS_LITERAL_CSTRING("none"); + break; + case ssl_sig_rsa_pkcs1_sha1: + signatureName = NS_LITERAL_CSTRING("RSA-PKCS1-SHA1"); + break; + case ssl_sig_rsa_pkcs1_sha256: + signatureName = NS_LITERAL_CSTRING("RSA-PKCS1-SHA256"); + break; + case ssl_sig_rsa_pkcs1_sha384: + signatureName = NS_LITERAL_CSTRING("RSA-PKCS1-SHA384"); + break; + case ssl_sig_rsa_pkcs1_sha512: + signatureName = NS_LITERAL_CSTRING("RSA-PKCS1-SHA512"); + break; + case ssl_sig_ecdsa_secp256r1_sha256: + signatureName = NS_LITERAL_CSTRING("ECDSA-P256-SHA256"); + break; + case ssl_sig_ecdsa_secp384r1_sha384: + signatureName = NS_LITERAL_CSTRING("ECDSA-P384-SHA384"); + break; + case ssl_sig_ecdsa_secp521r1_sha512: + signatureName = NS_LITERAL_CSTRING("ECDSA-P521-SHA512"); + break; + case ssl_sig_rsa_pss_sha256: + signatureName = NS_LITERAL_CSTRING("RSA-PSS-SHA256"); + break; + case ssl_sig_rsa_pss_sha384: + signatureName = NS_LITERAL_CSTRING("RSA-PSS-SHA384"); + break; + case ssl_sig_rsa_pss_sha512: + signatureName = NS_LITERAL_CSTRING("RSA-PSS-SHA512"); + break; + case ssl_sig_ecdsa_sha1: + signatureName = NS_LITERAL_CSTRING("ECDSA-SHA1"); + break; + case ssl_sig_rsa_pkcs1_sha1md5: + signatureName = NS_LITERAL_CSTRING("RSA-PKCS1-SHA1MD5"); + break; + // All other groups are not enabled in Firefox. See sEnabledSignatureSchemes + // in nsNSSIOLayer.cpp. + default: + // This really shouldn't happen! + MOZ_ASSERT_UNREACHABLE("Invalid signature scheme."); + signatureName = NS_LITERAL_CSTRING("unknown signature"); + } + return signatureName; +} + // call with shutdown prevention lock held static void PreliminaryHandshakeDone(PRFileDesc* fd) @@ -874,6 +967,9 @@ PreliminaryHandshakeDone(PRFileDesc* fd) status->mHaveCipherSuiteAndProtocol = true; status->mCipherSuite = channelInfo.cipherSuite; status->mProtocolVersion = channelInfo.protocolVersion & 0xFF; + status->mKeaGroup.Assign(getKeaGroupName(channelInfo.keaGroup)); + status->mSignatureSchemeName.Assign( + getSignatureName(channelInfo.signatureScheme)); infoObject->SetKEAUsed(channelInfo.keaType); infoObject->SetKEAKeyBits(channelInfo.keaKeyBits); infoObject->SetMACAlgorithmUsed(cipherInfo.macAlgorithm); diff --git a/security/manager/ssl/nsNSSIOLayer.cpp b/security/manager/ssl/nsNSSIOLayer.cpp index 8be215308..2d49540fb 100644 --- a/security/manager/ssl/nsNSSIOLayer.cpp +++ b/security/manager/ssl/nsNSSIOLayer.cpp @@ -2492,6 +2492,8 @@ loser: return nullptr; } +// Please change getSignatureName in nsNSSCallbacks.cpp when changing the list +// here. static const SSLSignatureScheme sEnabledSignatureSchemes[] = { ssl_sig_ecdsa_secp256r1_sha256, ssl_sig_ecdsa_secp384r1_sha384, @@ -2569,6 +2571,8 @@ nsSSLIOLayerSetOptions(PRFileDesc* fd, bool forSTARTTLS, } // Include a modest set of named groups. + // Please change getKeaGroupName in nsNSSCallbacks.cpp when changing the list + // here. const SSLNamedGroup namedGroups[] = { ssl_grp_ec_curve25519, ssl_grp_ec_secp256r1, ssl_grp_ec_secp384r1, ssl_grp_ec_secp521r1, ssl_grp_ffdhe_2048, ssl_grp_ffdhe_3072 diff --git a/security/manager/ssl/nsSSLStatus.cpp b/security/manager/ssl/nsSSLStatus.cpp index 1538b2aa7..7f9915cb2 100644 --- a/security/manager/ssl/nsSSLStatus.cpp +++ b/security/manager/ssl/nsSSLStatus.cpp @@ -76,6 +76,28 @@ nsSSLStatus::GetCipherName(nsACString& aCipherName) return NS_OK; } +NS_IMETHODIMP +nsSSLStatus::GetKeaGroupName(nsACString& aKeaGroup) +{ + if (!mHaveCipherSuiteAndProtocol) { + return NS_ERROR_NOT_AVAILABLE; + } + + aKeaGroup.Assign(mKeaGroup); + return NS_OK; +} + +NS_IMETHODIMP +nsSSLStatus::GetSignatureSchemeName(nsACString& aSignatureScheme) +{ + if (!mHaveCipherSuiteAndProtocol) { + return NS_ERROR_NOT_AVAILABLE; + } + + aSignatureScheme.Assign(mSignatureSchemeName); + return NS_OK; +} + NS_IMETHODIMP nsSSLStatus::GetProtocolVersion(uint16_t* aProtocolVersion) { @@ -194,6 +216,15 @@ nsSSLStatus::Read(nsIObjectInputStream* aStream) NS_ENSURE_SUCCESS(rv, rv); } + // Added in version 2 (see bug 1304923). + if (streamFormatVersion >= 2) { + rv = aStream->ReadCString(mKeaGroup); + NS_ENSURE_SUCCESS(rv, rv); + + rv = aStream->ReadCString(mSignatureSchemeName); + NS_ENSURE_SUCCESS(rv, rv); + } + return NS_OK; } @@ -201,7 +232,7 @@ NS_IMETHODIMP nsSSLStatus::Write(nsIObjectOutputStream* aStream) { // The current version of the binary stream format. - const uint8_t STREAM_FORMAT_VERSION = 1; + const uint8_t STREAM_FORMAT_VERSION = 2; nsresult rv = aStream->WriteCompoundObject(mServerCert, NS_GET_IID(nsIX509Cert), @@ -237,6 +268,13 @@ nsSSLStatus::Write(nsIObjectOutputStream* aStream) rv = aStream->Write16(mCertificateTransparencyStatus); NS_ENSURE_SUCCESS(rv, rv); + // Added in version 2. + rv = aStream->WriteStringZ(mKeaGroup.get()); + NS_ENSURE_SUCCESS(rv, rv); + + rv = aStream->WriteStringZ(mSignatureSchemeName.get()); + NS_ENSURE_SUCCESS(rv, rv); + return NS_OK; } @@ -300,6 +338,8 @@ nsSSLStatus::nsSSLStatus() , mProtocolVersion(0) , mCertificateTransparencyStatus(nsISSLStatus:: CERTIFICATE_TRANSPARENCY_NOT_APPLICABLE) +, mKeaGroup() +, mSignatureSchemeName() , mIsDomainMismatch(false) , mIsNotValidAtThisTime(false) , mIsUntrusted(false) diff --git a/security/manager/ssl/nsSSLStatus.h b/security/manager/ssl/nsSSLStatus.h index 2a8343407..74f9d0f01 100644 --- a/security/manager/ssl/nsSSLStatus.h +++ b/security/manager/ssl/nsSSLStatus.h @@ -50,6 +50,8 @@ public: uint16_t mCipherSuite; uint16_t mProtocolVersion; uint16_t mCertificateTransparencyStatus; + nsCString mKeaGroup; + nsCString mSignatureSchemeName; bool mIsDomainMismatch; bool mIsNotValidAtThisTime; diff --git a/testing/web-platform/meta/navigation-timing/idlharness.html.ini b/testing/web-platform/meta/navigation-timing/idlharness.html.ini index 4b43910f6..676f444a1 100644 --- a/testing/web-platform/meta/navigation-timing/idlharness.html.ini +++ b/testing/web-platform/meta/navigation-timing/idlharness.html.ini @@ -1,11 +1,5 @@ [idlharness.html] type: testharness - [PerformanceTiming interface: attribute secureConnectionStart] - expected: FAIL - - [PerformanceTiming interface: window.performance.timing must inherit property "secureConnectionStart" with the proper type (10)] - expected: FAIL - [Performance interface: existence and properties of interface object] expected: FAIL diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index aa66fbe14..45ad662c7 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1502,12 +1502,24 @@ "n_buckets": 50, "description": "HTTP page: DNS lookup time (ms)" }, - "HTTP_PAGE_TCP_CONNECTION": { + "HTTP_PAGE_TLS_HANDSHAKE": { + "alert_emails": ["necko@mozilla.com", "pmcmanus@mozilla.com"], + "bug_numbers": [772589], "expires_in_version": "never", "kind": "exponential", "high": 30000, "n_buckets": 50, - "description": "HTTP page: TCP connection setup (ms)" + "description": "HTTP page channel: After TCP SYN to Ready for HTTP (ms)" + + }, + "HTTP_PAGE_TCP_CONNECTION_2": { + "alert_emails": ["necko@mozilla.com", "pmcmanus@mozilla.com"], + "bug_numbers": [772589], + "expires_in_version": "never", + "kind": "exponential", + "high": 30000, + "n_buckets": 50, + "description": "HTTP page channel: TCP SYN to Ready for HTTP (ms)" }, "HTTP_PAGE_OPEN_TO_FIRST_SENT": { "expires_in_version": "never", @@ -1621,12 +1633,23 @@ "n_buckets": 50, "description": "HTTP subitem: DNS lookup time (ms)" }, - "HTTP_SUB_TCP_CONNECTION": { + "HTTP_SUB_TLS_HANDSHAKE": { + "alert_emails": ["necko@mozilla.com", "pmcmanus@mozilla.com"], + "bug_numbers": [772589], + "expires_in_version": "never", + "kind": "exponential", + "high": 30000, + "n_buckets": 50, + "description": "HTTP subitem channel: After TCP SYN to Ready for HTTP (ms)" + }, + "HTTP_SUB_TCP_CONNECTION_2": { + "alert_emails": ["necko@mozilla.com", "pmcmanus@mozilla.com"], + "bug_numbers": [772589], "expires_in_version": "never", "kind": "exponential", "high": 30000, "n_buckets": 50, - "description": "HTTP subitem: TCP connection setup (ms)" + "description": "HTTP subitem channel: TCP SYN to Ready for HTTP (ms)" }, "HTTP_SUB_OPEN_TO_FIRST_SENT": { "expires_in_version": "never", diff --git a/toolkit/components/telemetry/histogram-whitelists.json b/toolkit/components/telemetry/histogram-whitelists.json index 52db33192..486178199 100644 --- a/toolkit/components/telemetry/histogram-whitelists.json +++ b/toolkit/components/telemetry/histogram-whitelists.json @@ -333,7 +333,6 @@ "HTTP_PAGE_OPEN_TO_FIRST_RECEIVED", "HTTP_PAGE_OPEN_TO_FIRST_SENT", "HTTP_PAGE_REVALIDATION", - "HTTP_PAGE_TCP_CONNECTION", "HTTP_PROXY_TYPE", "HTTP_REQUEST_PER_CONN", "HTTP_REQUEST_PER_PAGE", @@ -359,7 +358,6 @@ "HTTP_SUB_OPEN_TO_FIRST_RECEIVED", "HTTP_SUB_OPEN_TO_FIRST_SENT", "HTTP_SUB_REVALIDATION", - "HTTP_SUB_TCP_CONNECTION", "HTTP_TRANSACTION_IS_SSL", "HTTP_TRANSACTION_USE_ALTSVC", "HTTP_TRANSACTION_USE_ALTSVC_OE", @@ -1167,7 +1165,6 @@ "HTTP_PAGE_OPEN_TO_FIRST_RECEIVED", "HTTP_PAGE_OPEN_TO_FIRST_SENT", "HTTP_PAGE_REVALIDATION", - "HTTP_PAGE_TCP_CONNECTION", "HTTP_PROXY_TYPE", "HTTP_REQUEST_PER_CONN", "HTTP_REQUEST_PER_PAGE", @@ -1193,7 +1190,6 @@ "HTTP_SUB_OPEN_TO_FIRST_RECEIVED", "HTTP_SUB_OPEN_TO_FIRST_SENT", "HTTP_SUB_REVALIDATION", - "HTTP_SUB_TCP_CONNECTION", "HTTP_TRANSACTION_IS_SSL", "HTTP_TRANSACTION_USE_ALTSVC", "HTTP_TRANSACTION_USE_ALTSVC_OE", -- cgit v1.2.3 From 644e9db1092df1477b1facc52cd3ee45ebd13040 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 1 Mar 2018 11:52:50 +0100 Subject: DevTools - network - implement the secureConnectionStart property for the PerformanceTiming https://github.com/MoonchildProductions/moebius/pull/116 ("/testing" and "/toolkit" in in the previous commit) --- .../client/locales/en-US/netmonitor.properties | 5 +++ devtools/client/netmonitor/netmonitor-view.js | 11 +++++- devtools/client/netmonitor/netmonitor.xul | 8 ++++ devtools/client/netmonitor/requests-menu-view.js | 2 +- .../test/browser_net_simple-request-data.js | 2 + devtools/client/themes/netmonitor.css | 6 +++ devtools/shared/webconsole/network-monitor.js | 35 ++++++++++++++++- dom/performance/PerformanceMainThread.cpp | 5 ++- dom/performance/PerformanceResourceTiming.h | 6 +-- dom/performance/PerformanceTiming.cpp | 44 ++++++++++++++++++++++ dom/performance/PerformanceTiming.h | 3 ++ dom/webidl/PerformanceTiming.webidl | 3 +- netwerk/base/nsISocketTransport.idl | 2 + netwerk/base/nsITimedChannel.idl | 2 + netwerk/base/nsLoadGroup.cpp | 13 ++++++- netwerk/ipc/NeckoMessageUtils.h | 2 + netwerk/protocol/http/Http2Session.cpp | 9 +++++ netwerk/protocol/http/HttpBaseChannel.cpp | 7 ++++ netwerk/protocol/http/HttpChannelChild.cpp | 1 + netwerk/protocol/http/HttpChannelParent.cpp | 1 + netwerk/protocol/http/NullHttpChannel.cpp | 8 ++++ netwerk/protocol/http/NullHttpTransaction.cpp | 24 ++++++++++++ netwerk/protocol/http/NullHttpTransaction.h | 4 ++ netwerk/protocol/http/TimingStruct.h | 1 + netwerk/protocol/http/nsHttpChannel.cpp | 9 +++++ netwerk/protocol/http/nsHttpChannel.h | 1 + netwerk/protocol/http/nsHttpConnection.cpp | 25 ++++++++++-- netwerk/protocol/http/nsHttpConnection.h | 6 +++ netwerk/protocol/http/nsHttpConnectionMgr.cpp | 5 +++ netwerk/protocol/http/nsHttpTransaction.cpp | 22 +++++++++++ netwerk/protocol/http/nsHttpTransaction.h | 3 ++ .../migrate-l10n/migrate/conf/bug1308500_1309191 | 1 + 32 files changed, 263 insertions(+), 13 deletions(-) diff --git a/devtools/client/locales/en-US/netmonitor.properties b/devtools/client/locales/en-US/netmonitor.properties index 1f6f671c9..021b56a2b 100644 --- a/devtools/client/locales/en-US/netmonitor.properties +++ b/devtools/client/locales/en-US/netmonitor.properties @@ -581,6 +581,11 @@ netmonitor.timings.blocked=Blocked: # in a "dns" state. netmonitor.timings.dns=DNS resolution: +# LOCALIZATION NOTE (netmonitor.timings.ssl): This is the label displayed +# in the network details timings tab identifying the amount of time spent +# in a "tls" handshake state. +netmonitor.timings.ssl=TLS setup: + # LOCALIZATION NOTE (netmonitor.timings.connect): This is the label displayed # in the network details timings tab identifying the amount of time spent # in a "connect" state. diff --git a/devtools/client/netmonitor/netmonitor-view.js b/devtools/client/netmonitor/netmonitor-view.js index 19dd96ff1..414b9ab8f 100644 --- a/devtools/client/netmonitor/netmonitor-view.js +++ b/devtools/client/netmonitor/netmonitor-view.js @@ -963,7 +963,7 @@ NetworkDetailsView.prototype = { if (!response) { return; } - let { blocked, dns, connect, send, wait, receive } = response.timings; + let { blocked, dns, connect, ssl, send, wait, receive } = response.timings; let tabboxWidth = $("#details-pane").getAttribute("width"); @@ -988,6 +988,11 @@ NetworkDetailsView.prototype = { $("#timings-summary-connect .requests-menu-timings-total") .setAttribute("value", L10N.getFormatStr("networkMenu.totalMS", connect)); + $("#timings-summary-ssl .requests-menu-timings-box") + .setAttribute("width", ssl * scale); + $("#timings-summary-ssl .requests-menu-timings-total") + .setAttribute("value", L10N.getFormatStr("networkMenu.totalMS", ssl)); + $("#timings-summary-send .requests-menu-timings-box") .setAttribute("width", send * scale); $("#timings-summary-send .requests-menu-timings-total") @@ -1007,6 +1012,8 @@ NetworkDetailsView.prototype = { .style.transform = "translateX(" + (scale * blocked) + "px)"; $("#timings-summary-connect .requests-menu-timings-box") .style.transform = "translateX(" + (scale * (blocked + dns)) + "px)"; + $("#timings-summary-ssl .requests-menu-timings-box") + .style.transform = "translateX(" + (scale * blocked) + "px)"; $("#timings-summary-send .requests-menu-timings-box") .style.transform = "translateX(" + (scale * (blocked + dns + connect)) + "px)"; @@ -1022,6 +1029,8 @@ NetworkDetailsView.prototype = { .style.transform = "translateX(" + (scale * blocked) + "px)"; $("#timings-summary-connect .requests-menu-timings-total") .style.transform = "translateX(" + (scale * (blocked + dns)) + "px)"; + $("#timings-summary-ssl .requests-menu-timings-total") + .style.transform = "translateX(" + (scale * blocked) + "px)"; $("#timings-summary-send .requests-menu-timings-total") .style.transform = "translateX(" + (scale * (blocked + dns + connect)) + "px)"; diff --git a/devtools/client/netmonitor/netmonitor.xul b/devtools/client/netmonitor/netmonitor.xul index 117ecf261..aa5c4d848 100644 --- a/devtools/client/netmonitor/netmonitor.xul +++ b/devtools/client/netmonitor/netmonitor.xul @@ -478,6 +478,14 @@ + +