From f0cf674d088243d0e597fac6581ee2793014044f Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Mon, 21 Oct 2013 01:56:00 +0300 Subject: [PATCH 01/23] Bug 921850 - Fix races in debugger client when connecting agressively r=past --- browser/devtools/framework/connect/connect.js | 9 ++++++++- toolkit/devtools/client/connection-manager.js | 14 +++++++++++-- toolkit/devtools/client/dbg-client.jsm | 20 +++++++++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/browser/devtools/framework/connect/connect.js b/browser/devtools/framework/connect/connect.js index ffb48ac1e2ea..e7d2b9eda824 100644 --- a/browser/devtools/framework/connect/connect.js +++ b/browser/devtools/framework/connect/connect.js @@ -54,7 +54,14 @@ function submit() { Services.prefs.setIntPref("devtools.debugger.remote-port", port); // Initiate the connection - let transport = debuggerSocketConnect(host, port); + let transport; + try { + transport = debuggerSocketConnect(host, port); + } catch(e) { + // Bug 921850: catch rare exception from debuggerSocketConnect + showError("unexpected"); + return; + } gClient = new DebuggerClient(transport); let delay = Services.prefs.getIntPref("devtools.debugger.remote-timeout"); gConnectionTimeout = setTimeout(handleConnectionTimeout, delay); diff --git a/toolkit/devtools/client/connection-manager.js b/toolkit/devtools/client/connection-manager.js index b187e8a7a4b9..a104f6e4db98 100644 --- a/toolkit/devtools/client/connection-manager.js +++ b/toolkit/devtools/client/connection-manager.js @@ -221,7 +221,17 @@ Connection.prototype = { if (!this.host) { transport = DebuggerServer.connectPipe(); } else { - transport = debuggerSocketConnect(this.host, this.port); + try { + transport = debuggerSocketConnect(this.host, this.port); + } catch (e) { + // In some cases, especially on Mac, the openOutputStream call in + // debuggerSocketConnect may throw NS_ERROR_NOT_INITIALIZED. + // It occurs when we connect agressively to the simulator, + // and keep trying to open a socket to the server being started in + // the simulator. + this._onDisconnected(); + return; + } } this._client = new DebuggerClient(transport); this._client.addOneTimeListener("closed", this._onDisconnected); @@ -244,7 +254,7 @@ Connection.prototype = { this._client = null; if (this._status == Connection.Status.CONNECTING && this.keepConnecting) { - setTimeout(() => this._clientConnect(), 0); + setTimeout(() => this._clientConnect(), 100); return; } diff --git a/toolkit/devtools/client/dbg-client.jsm b/toolkit/devtools/client/dbg-client.jsm index b9a0bb194681..2fd52e13d139 100644 --- a/toolkit/devtools/client/dbg-client.jsm +++ b/toolkit/devtools/client/dbg-client.jsm @@ -2200,8 +2200,24 @@ eventSource(EnvironmentClient.prototype); this.debuggerSocketConnect = function debuggerSocketConnect(aHost, aPort) { let s = socketTransportService.createTransport(null, 0, aHost, aPort, null); - let transport = new DebuggerTransport(s.openInputStream(0, 0, 0), - s.openOutputStream(0, 0, 0)); + // By default the CONNECT socket timeout is very long, 65535 seconds, + // so that if we race to be in CONNECT state while the server socket is still + // initializing, the connection is stuck in connecting state for 18.20 hours! + s.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT, 2); + + // openOutputStream may throw NS_ERROR_NOT_INITIALIZED if we hit some race + // where the nsISocketTransport gets shutdown in between its instantiation and + // the call to this method. + let transport; + try { + transport = new DebuggerTransport(s.openInputStream(0, 0, 0), + s.openOutputStream(0, 0, 0)); + } catch(e) { + let msg = e + ": " + e.stack; + Cu.reportError(msg); + dumpn(msg); + throw e; + } return transport; } From a15d662f38ea3a3d7acfc221099bd7bfadcfb17b Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Wed, 23 Oct 2013 10:44:20 +0200 Subject: [PATCH 02/23] bug 890985 - crash in nsStandardURL::SetSpec @ nsStandardURL::BuildNormalizedSpec r=glandium --- build/autoconf/arch.m4 | 24 +++++++++++++++++++++++- js/src/build/autoconf/arch.m4 | 24 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/build/autoconf/arch.m4 b/build/autoconf/arch.m4 index 508cb9776cc5..a351ac16bb9d 100644 --- a/build/autoconf/arch.m4 +++ b/build/autoconf/arch.m4 @@ -14,6 +14,7 @@ MOZ_THUMB_INTERWORK=toolchain-default MOZ_FPU=toolchain-default MOZ_FLOAT_ABI=toolchain-default MOZ_SOFT_FLOAT=toolchain-default +MOZ_ALIGN=toolchain-default MOZ_ARG_WITH_STRING(arch, [ --with-arch=[[type|toolchain-default]] @@ -32,6 +33,7 @@ if test -z "$MOZ_ARCH"; then MOZ_ARCH=armv7-a MOZ_FPU=vfp MOZ_FLOAT_ABI=softfp + MOZ_ALIGN=no ;; arm-Darwin) MOZ_ARCH=toolchain-default @@ -159,8 +161,28 @@ no) ;; esac +case "$MOZ_ALIGN" in +no) + align_flag="-mno-unaligned-access" + ;; +yes) + align_flag="-munaligned-access" + ;; +*) + align_flag="" + ;; +esac + +if test -n "$align_flag"; then + _SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $align_flag" + AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported) + AC_TRY_COMPILE([],[],,align_flag="") + CFLAGS="$_SAVE_CFLAGS" +fi + dnl Use echo to avoid accumulating space characters -all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag` +all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag` if test -n "$all_flags"; then _SAVE_CFLAGS="$CFLAGS" CFLAGS="$all_flags" diff --git a/js/src/build/autoconf/arch.m4 b/js/src/build/autoconf/arch.m4 index 508cb9776cc5..a351ac16bb9d 100644 --- a/js/src/build/autoconf/arch.m4 +++ b/js/src/build/autoconf/arch.m4 @@ -14,6 +14,7 @@ MOZ_THUMB_INTERWORK=toolchain-default MOZ_FPU=toolchain-default MOZ_FLOAT_ABI=toolchain-default MOZ_SOFT_FLOAT=toolchain-default +MOZ_ALIGN=toolchain-default MOZ_ARG_WITH_STRING(arch, [ --with-arch=[[type|toolchain-default]] @@ -32,6 +33,7 @@ if test -z "$MOZ_ARCH"; then MOZ_ARCH=armv7-a MOZ_FPU=vfp MOZ_FLOAT_ABI=softfp + MOZ_ALIGN=no ;; arm-Darwin) MOZ_ARCH=toolchain-default @@ -159,8 +161,28 @@ no) ;; esac +case "$MOZ_ALIGN" in +no) + align_flag="-mno-unaligned-access" + ;; +yes) + align_flag="-munaligned-access" + ;; +*) + align_flag="" + ;; +esac + +if test -n "$align_flag"; then + _SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $align_flag" + AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported) + AC_TRY_COMPILE([],[],,align_flag="") + CFLAGS="$_SAVE_CFLAGS" +fi + dnl Use echo to avoid accumulating space characters -all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag` +all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag` if test -n "$all_flags"; then _SAVE_CFLAGS="$CFLAGS" CFLAGS="$all_flags" From d5689dad95ae1cfd90e627b52a7dd75bed0f31de Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 23 Oct 2013 02:10:08 -0700 Subject: [PATCH 03/23] Bug 917072 - Move black box eyeball into sources toolbar; r=vporof --- .../devtools/debugger/debugger-controller.js | 7 +- browser/devtools/debugger/debugger-panes.js | 47 +++++---- browser/devtools/debugger/debugger.xul | 20 ++-- browser/devtools/debugger/test/browser.ini | 1 - .../test/browser_dbg_blackboxing-01.js | 17 ++-- .../test/browser_dbg_blackboxing-02.js | 11 +- .../test/browser_dbg_blackboxing-03.js | 11 +- .../test/browser_dbg_blackboxing-04.js | 12 +-- .../test/browser_dbg_blackboxing-05.js | 13 +-- .../test/browser_dbg_blackboxing-06.js | 31 +++--- .../test/browser_dbg_blackboxing-07.js | 66 ------------ .../debugger/test/browser_dbg_cmd-blackbox.js | 96 +++++++++++------- .../test/browser_dbg_pretty-print-10.js | 9 +- browser/devtools/debugger/test/head.js | 26 +++++ .../chrome/browser/devtools/debugger.dtd | 6 +- .../linux/devtools/debugger-blackbox.png | Bin 0 -> 1005 bytes browser/themes/linux/devtools/debugger.css | 54 +++------- browser/themes/linux/jar.mn | 1 + .../themes/osx/devtools/debugger-blackbox.png | Bin 0 -> 1005 bytes browser/themes/osx/devtools/debugger.css | 50 +++------ browser/themes/osx/jar.mn | 1 + .../windows/devtools/debugger-blackbox.png | Bin 0 -> 1005 bytes browser/themes/windows/devtools/debugger.css | 52 +++------- browser/themes/windows/jar.mn | 2 + 24 files changed, 213 insertions(+), 320 deletions(-) delete mode 100644 browser/devtools/debugger/test/browser_dbg_blackboxing-07.js create mode 100644 browser/themes/linux/devtools/debugger-blackbox.png create mode 100644 browser/themes/osx/devtools/debugger-blackbox.png create mode 100644 browser/themes/windows/devtools/debugger-blackbox.png diff --git a/browser/devtools/debugger/debugger-controller.js b/browser/devtools/debugger/debugger-controller.js index 4ca55120a5de..f6ca29d0d5f4 100644 --- a/browser/devtools/debugger/debugger-controller.js +++ b/browser/devtools/debugger/debugger-controller.js @@ -1156,8 +1156,13 @@ SourceScripts.prototype = { _onBlackBoxChange: function (aEvent, { url, isBlackBoxed }) { const item = DebuggerView.Sources.getItemByValue(url); if (item) { - DebuggerView.Sources.callMethod("checkItem", item.target, !isBlackBoxed); + if (isBlackBoxed) { + item.target.classList.add("black-boxed"); + } else { + item.target.classList.remove("black-boxed"); + } } + DebuggerView.Sources.updateToolbarButtonsState(); DebuggerView.maybeShowBlackBoxMessage(); }, diff --git a/browser/devtools/debugger/debugger-panes.js b/browser/devtools/debugger/debugger-panes.js index a8b76ffdd65b..96a2df05a96f 100644 --- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -19,7 +19,7 @@ function SourcesView() { this._onSourceSelect = this._onSourceSelect.bind(this); this._onSourceClick = this._onSourceClick.bind(this); this._onBreakpointRemoved = this._onBreakpointRemoved.bind(this); - this._onSourceCheck = this._onSourceCheck.bind(this); + this.toggleBlackBoxing = this.toggleBlackBoxing.bind(this); this._onStopBlackBoxing = this._onStopBlackBoxing.bind(this); this._onBreakpointClick = this._onBreakpointClick.bind(this); this._onBreakpointCheckboxClick = this._onBreakpointCheckboxClick.bind(this); @@ -28,7 +28,7 @@ function SourcesView() { this._onConditionalPopupHiding = this._onConditionalPopupHiding.bind(this); this._onConditionalTextboxInput = this._onConditionalTextboxInput.bind(this); this._onConditionalTextboxKeyPress = this._onConditionalTextboxKeyPress.bind(this); - this._updatePrettyPrintButtonState = this._updatePrettyPrintButtonState.bind(this); + this.updateToolbarButtonsState = this.updateToolbarButtonsState.bind(this); } SourcesView.prototype = Heritage.extend(WidgetMethods, { @@ -39,7 +39,6 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { dumpn("Initializing the SourcesView"); this.widget = new SideMenuWidget(document.getElementById("sources"), { - showItemCheckboxes: true, showArrows: true }); @@ -51,6 +50,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { this._cmPopup = document.getElementById("sourceEditorContextMenu"); this._cbPanel = document.getElementById("conditional-breakpoint-panel"); this._cbTextbox = document.getElementById("conditional-breakpoint-panel-textbox"); + this._blackBoxButton = document.getElementById("black-box"); this._stopBlackBoxButton = document.getElementById("black-boxed-message-button"); this._prettyPrintButton = document.getElementById("pretty-print"); @@ -62,7 +62,6 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { window.on(EVENTS.EDITOR_UNLOADED, this._onEditorUnload, false); this.widget.addEventListener("select", this._onSourceSelect, false); this.widget.addEventListener("click", this._onSourceClick, false); - this.widget.addEventListener("check", this._onSourceCheck, false); this._stopBlackBoxButton.addEventListener("click", this._onStopBlackBoxing, false); this._cbPanel.addEventListener("popupshowing", this._onConditionalPopupShowing, false); this._cbPanel.addEventListener("popupshown", this._onConditionalPopupShown, false); @@ -86,7 +85,6 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { window.off(EVENTS.EDITOR_UNLOADED, this._onEditorUnload, false); this.widget.removeEventListener("select", this._onSourceSelect, false); this.widget.removeEventListener("click", this._onSourceClick, false); - this.widget.removeEventListener("check", this._onSourceCheck, false); this._stopBlackBoxButton.removeEventListener("click", this._onStopBlackBoxing, false); this._cbPanel.removeEventListener("popupshowing", this._onConditionalPopupShowing, false); this._cbPanel.removeEventListener("popupshowing", this._onConditionalPopupShown, false); @@ -702,22 +700,23 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { document.title = L10N.getFormatStr("DebuggerWindowScriptTitle", script); DebuggerView.maybeShowBlackBoxMessage(); - this._updatePrettyPrintButtonState(); + this.updateToolbarButtonsState(); }, /** - * Enable or disable the pretty print button depending on whether the selected - * source is black boxed or not and check or uncheck it depending on if the - * selected source is already pretty printed or not. + * Update the checked/unchecked and enabled/disabled states of the buttons in + * the sources toolbar based on the currently selected source's state. */ - _updatePrettyPrintButtonState: function() { + updateToolbarButtonsState: function() { const { source } = this.selectedItem.attachment; const sourceClient = gThreadClient.source(source); if (sourceClient.isBlackBoxed) { this._prettyPrintButton.setAttribute("disabled", true); + this._blackBoxButton.setAttribute("checked", true); } else { this._prettyPrintButton.removeAttribute("disabled"); + this._blackBoxButton.removeAttribute("checked"); } if (sourceClient.isPrettyPrinted) { @@ -736,26 +735,30 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { }, /** - * The check listener for the sources container. + * Toggle the black boxed state of the selected source. */ - _onSourceCheck: function({ detail: { checked }, target }) { - const shouldBlackBox = !checked; + toggleBlackBoxing: function() { + const { source } = this.selectedItem.attachment; + const sourceClient = gThreadClient.source(source); + const shouldBlackBox = !sourceClient.isBlackBoxed; - // Be optimistic that the (un-)black boxing will succeed and enable/disable - // the pretty print button immediately. Then, once we actually get the - // results from the server, make sure that it is in the correct state again - // by calling `_updatePrettyPrintButtonState`. + // Be optimistic that the (un-)black boxing will succeed, so enable/disable + // the pretty print button and check/uncheck the black box button + // immediately. Then, once we actually get the results from the server, make + // sure that it is in the correct state again by calling + // `updateToolbarButtonsState`. if (shouldBlackBox) { this._prettyPrintButton.setAttribute("disabled", true); + this._blackBoxButton.setAttribute("checked", true); } else { this._prettyPrintButton.removeAttribute("disabled"); + this._blackBoxButton.removeAttribute("checked"); } - const { source } = this.getItemForElement(target).attachment; DebuggerController.SourceScripts.blackBox(source, shouldBlackBox) - .then(this._updatePrettyPrintButtonState, - this._updatePrettyPrintButtonState); + .then(this.updateToolbarButtonsState, + this.updateToolbarButtonsState); }, /** @@ -763,7 +766,9 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { */ _onStopBlackBoxing: function() { let sourceForm = this.selectedItem.attachment.source; - DebuggerController.SourceScripts.blackBox(sourceForm, false); + DebuggerController.SourceScripts.blackBox(sourceForm, false) + .then(this.updateToolbarButtonsState, + this.updateToolbarButtonsState); }, /** diff --git a/browser/devtools/debugger/debugger.xul b/browser/devtools/debugger/debugger.xul index 2e118b916f05..0dbb1b43b100 100644 --- a/browser/devtools/debugger/debugger.xul +++ b/browser/devtools/debugger/debugger.xul @@ -32,6 +32,8 @@ + - { + return toggleBlackBoxing(gPanel).then(aSource => { ok(aSource.isBlackBoxed, "The source should be black boxed now."); - ok(!checkbox.checked, "The checkbox should no longer be checked."); + ok(bbButton.checked, "The checkbox should no longer be checked."); }); - - checkbox.click(); - return finished; } function testBlackBoxReload() { return reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(() => { - const checkbox = gDebugger.document.querySelector(".side-menu-widget-item-checkbox"); - ok(checkbox, "Should get the checkbox for black boxing the source."); - ok(!checkbox.checked, "Should still be black boxed."); + const bbButton = getBlackBoxButton(gPanel); + ok(bbButton.checked, "Should still be black boxed."); }); } diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js index 9c44ff27c854..3f1e395b5b9f 100644 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js @@ -31,12 +31,9 @@ function test() { } function testBlackBoxSource() { - let finished = waitForThreadEvents(gPanel, "blackboxchange").then(aSource => { + return toggleBlackBoxing(gPanel).then(aSource => { ok(aSource.isBlackBoxed, "The source should be black boxed now."); }); - - getBlackBoxCheckbox(BLACKBOXME_URL).click(); - return finished; } function testBlackBoxStack() { @@ -53,12 +50,6 @@ function testBlackBoxStack() { return finished; } -function getBlackBoxCheckbox(aUrl) { - return gDebugger.document.querySelector( - ".side-menu-widget-item[tooltiptext=\"" + aUrl + "\"] " + - ".side-menu-widget-item-checkbox"); -} - registerCleanupFunction(function() { gTab = null; gDebuggee = null; diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js index 5ab8675fb1be..e935e895afdf 100644 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js @@ -40,7 +40,7 @@ function testBlackBoxStack() { } function testBlackBoxSource() { - let finished = waitForThreadEvents(gPanel, "blackboxchange").then(aSource => { + return toggleBlackBoxing(gPanel, BLACKBOXME_URL).then(aSource => { ok(aSource.isBlackBoxed, "The source should be black boxed now."); is(gFrames.itemCount, 3, @@ -48,15 +48,6 @@ function testBlackBoxSource() { is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 1, "And one of them should be the combined black boxed frames."); }); - - getBlackBoxCheckbox(BLACKBOXME_URL).click(); - return finished; -} - -function getBlackBoxCheckbox(aUrl) { - return gDebugger.document.querySelector( - ".side-menu-widget-item[tooltiptext=\"" + aUrl + "\"] " + - ".side-menu-widget-item-checkbox"); } registerCleanupFunction(function() { diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js index 72a3d05e42ca..9c43e542fe0d 100644 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js @@ -32,9 +32,9 @@ function test() { function blackBoxSources() { let finished = waitForThreadEvents(gPanel, "blackboxchange", 3); - getBlackBoxCheckbox(EXAMPLE_URL + "code_blackboxing_one.js").click(); - getBlackBoxCheckbox(EXAMPLE_URL + "code_blackboxing_two.js").click(); - getBlackBoxCheckbox(EXAMPLE_URL + "code_blackboxing_three.js").click(); + toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_one.js"); + toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_two.js"); + toggleBlackBoxing(gPanel, EXAMPLE_URL + "code_blackboxing_three.js"); return finished; } @@ -52,12 +52,6 @@ function testBlackBoxStack() { return finished; } -function getBlackBoxCheckbox(aUrl) { - return gDebugger.document.querySelector( - ".side-menu-widget-item[tooltiptext=\"" + aUrl + "\"] " + - ".side-menu-widget-item-checkbox"); -} - registerCleanupFunction(function() { gTab = null; gDebuggee = null; diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-05.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-05.js index 879e278c35b8..e6a2d3dba6f2 100644 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-05.js +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-05.js @@ -21,7 +21,7 @@ function test() { waitForSourceShown(gPanel, ".coffee") .then(testSourceEditorShown) - .then(blackBoxSource) + .then(toggleBlackBoxing.bind(null, gPanel)) .then(testBlackBoxMessageShown) .then(clickStopBlackBoxingButton) .then(testSourceEditorShownAgain) @@ -37,12 +37,6 @@ function testSourceEditorShown() { "The first item in the deck should be selected (the source editor)."); } -function blackBoxSource() { - let finished = waitForThreadEvents(gPanel, "blackboxchange"); - getAnyBlackBoxCheckbox().click(); - return finished; -} - function testBlackBoxMessageShown() { is(gDeck.selectedIndex, "1", "The second item in the deck should be selected (the black box message)."); @@ -59,11 +53,6 @@ function testSourceEditorShownAgain() { "The first item in the deck should be selected again (the source editor)."); } -function getAnyBlackBoxCheckbox() { - return gDebugger.document.querySelector( - ".side-menu-widget-item .side-menu-widget-item-checkbox"); -} - function getEditorBlackboxMessageButton() { return gDebugger.document.getElementById("black-boxed-message-button"); } diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-06.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-06.js index 4637f26bbc91..a3e649d07fe2 100644 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-06.js +++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-06.js @@ -2,7 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ /** - * Test that clicking the black box checkbox doesn't select that source. + * Test that clicking the black box checkbox when paused doesn't re-select the + * currently paused frame's source. */ const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html"; @@ -18,35 +19,35 @@ function test() { gDebugger = gPanel.panelWin; gSources = gDebugger.DebuggerView.Sources; - waitForSourceShown(gPanel, ".js") + waitForSourceAndCaretAndScopes(gPanel, ".html", 21) .then(testBlackBox) - .then(() => closeDebuggerAndFinish(gPanel)) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) .then(null, aError => { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); }); + + gDebuggee.runTest(); }); } function testBlackBox() { const selectedUrl = gSources.selectedValue; - const checkbox = getDifferentBlackBoxCheckbox(selectedUrl); - ok(checkbox, "We should be able to grab a different checkbox."); - let finished = waitForThreadEvents(gPanel, "blackboxchange").then(() => { - is(selectedUrl, gSources.selectedValue, - "The same source should still be selected."); + let finished = waitForSourceShown(gPanel, "blackboxme.js").then(() => { + const newSelectedUrl = gSources.selectedValue; + isnot(selectedUrl, newSelectedUrl, + "Should not have the same url selected."); + + return toggleBlackBoxing(gPanel).then(() => { + is(gSources.selectedValue, newSelectedUrl, + "The selected source did not change."); + }); }); - checkbox.click(); + gSources.selectedIndex = 0; return finished; } -function getDifferentBlackBoxCheckbox(aUrl) { - return gDebugger.document.querySelector( - ".side-menu-widget-item:not([tooltiptext=\"" + aUrl + "\"]) " + - ".side-menu-widget-item-checkbox"); -} - registerCleanupFunction(function() { gTab = null; gDebuggee = null; diff --git a/browser/devtools/debugger/test/browser_dbg_blackboxing-07.js b/browser/devtools/debugger/test/browser_dbg_blackboxing-07.js deleted file mode 100644 index dacc04c889dc..000000000000 --- a/browser/devtools/debugger/test/browser_dbg_blackboxing-07.js +++ /dev/null @@ -1,66 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Test that clicking the black box checkbox when paused doesn't re-select the - * currently paused frame's source. - */ - -const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html"; - -let gTab, gDebuggee, gPanel, gDebugger; -let gSources; - -function test() { - initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { - gTab = aTab; - gDebuggee = aDebuggee; - gPanel = aPanel; - gDebugger = gPanel.panelWin; - gSources = gDebugger.DebuggerView.Sources; - - waitForSourceAndCaretAndScopes(gPanel, ".html", 21) - .then(testBlackBox) - .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) - .then(null, aError => { - ok(false, "Got an error: " + aError.message + "\n" + aError.stack); - }); - - gDebuggee.runTest(); - }); -} - -function testBlackBox() { - const selectedUrl = gSources.selectedValue; - - let finished = waitForSourceShown(gPanel, "blackboxme.js").then(() => { - const newSelectedUrl = gSources.selectedValue; - isnot(selectedUrl, newSelectedUrl, - "Should not have the same url selected."); - - let finished = waitForThreadEvents(gPanel, "blackboxchange").then(() => { - is(gSources.selectedValue, newSelectedUrl, - "The selected source did not change."); - }); - - getBlackBoxCheckbox(newSelectedUrl).click() - return finished; - }); - - gSources.selectedIndex = 0; - return finished; -} - -function getBlackBoxCheckbox(aUrl) { - return gDebugger.document.querySelector( - ".side-menu-widget-item[tooltiptext=\"" + aUrl + "\"] " + - ".side-menu-widget-item-checkbox"); -} - -registerCleanupFunction(function() { - gTab = null; - gDebuggee = null; - gPanel = null; - gDebugger = null; - gSources = null; -}); diff --git a/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js b/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js index fcc9ab9ee9b9..42da74d0e2db 100644 --- a/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js +++ b/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js @@ -46,69 +46,95 @@ function waitForDebuggerSources() { } function testBlackBoxSource() { - return cmd("dbg blackbox " + BLACKBOXME_URL).then(() => { - const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL); - ok(!checkbox.checked, - "Should be able to black box a specific source."); + return Task.spawn(function* () { + yield cmd("dbg blackbox " + BLACKBOXME_URL); + + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXME_URL); + ok(bbButton.checked, + "Should be able to black box a specific source."); }); } function testUnBlackBoxSource() { - return cmd("dbg unblackbox " + BLACKBOXME_URL).then(() => { - const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL); - ok(checkbox.checked, - "Should be able to stop black boxing a specific source."); + return Task.spawn(function* () { + yield cmd("dbg unblackbox " + BLACKBOXME_URL); + + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXME_URL); + ok(!bbButton.checked, + "Should be able to stop black boxing a specific source."); }); } function testBlackBoxGlob() { - return cmd("dbg blackbox --glob *blackboxing_t*.js", 2, - [/blackboxing_three\.js/g, /blackboxing_two\.js/g]).then(() => { - ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked, - "blackboxme should not be black boxed because it doesn't match the glob."); - ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked, - "blackbox_one should not be black boxed because it doesn't match the glob."); + return Task.spawn(function* () { + yield cmd("dbg blackbox --glob *blackboxing_t*.js", 2, + [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); - ok(!getBlackBoxCheckbox(BLACKBOXTWO_URL).checked, - "blackbox_two should be black boxed because it matches the glob."); - ok(!getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked, + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXME_URL); + ok(!bbButton.checked, + "blackboxme should not be black boxed because it doesn't match the glob."); + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXONE_URL); + ok(!bbButton.checked, + "blackbox_one should not be black boxed because it doesn't match the glob."); + + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTWO_URL); + ok(bbButton.checked, + "blackbox_two should be black boxed because it matches the glob."); + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTHREE_URL); + ok(bbButton.checked, "blackbox_three should be black boxed because it matches the glob."); }); } function testUnBlackBoxGlob() { - return cmd("dbg unblackbox --glob *blackboxing_t*.js", 2).then(() => { - ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked, - "blackbox_two should be un-black boxed because it matches the glob."); - ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked, + return Task.spawn(function* () { + yield cmd("dbg unblackbox --glob *blackboxing_t*.js", 2); + + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTWO_URL); + ok(!bbButton.checked, + "blackbox_two should be un-black boxed because it matches the glob."); + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTHREE_URL); + ok(!bbButton.checked, "blackbox_three should be un-black boxed because it matches the glob."); }); } function testBlackBoxInvert() { - return cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3, - [/blackboxing_three\.js/g, /blackboxing_two\.js/g]).then(() => { - ok(!getBlackBoxCheckbox(BLACKBOXME_URL).checked, + return Task.spawn(function* () { + yield cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3, + [/blackboxing_three\.js/g, /blackboxing_two\.js/g]); + + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXME_URL); + ok(bbButton.checked, "blackboxme should be black boxed because it doesn't match the glob."); - ok(!getBlackBoxCheckbox(BLACKBOXONE_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXONE_URL); + ok(bbButton.checked, "blackbox_one should be black boxed because it doesn't match the glob."); - ok(!getBlackBoxCheckbox(TEST_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, TEST_URL); + ok(bbButton.checked, "TEST_URL should be black boxed because it doesn't match the glob."); - ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTWO_URL); + ok(!bbButton.checked, "blackbox_two should not be black boxed because it matches the glob."); - ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXTHREE_URL); + ok(!bbButton.checked, "blackbox_three should not be black boxed because it matches the glob."); }); } function testUnBlackBoxInvert() { - return cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3).then(() => { - ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked, + return Task.spawn(function* () { + yield cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3); + + let bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXME_URL); + ok(!bbButton.checked, "blackboxme should be un-black boxed because it does not match the glob."); - ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, BLACKBOXONE_URL); + ok(!bbButton.checked, "blackbox_one should be un-black boxed because it does not match the glob."); - ok(getBlackBoxCheckbox(TEST_URL).checked, + bbButton = yield selectSourceAndGetBlackBoxButton(gPanel, TEST_URL); + ok(!bbButton.checked, "TEST_URL should be un-black boxed because it doesn't match the glob."); }); } @@ -126,9 +152,3 @@ function cmd(aTyped, aEventRepeat = 1, aOutput = "") { helpers.audit(gOptions, [{ setup: aTyped, output: aOutput, exec: {} }]) ]); } - -function getBlackBoxCheckbox(url) { - return gDebugger.document.querySelector( - ".side-menu-widget-item[tooltiptext=\"" + url + "\"] " + - ".side-menu-widget-item-checkbox"); -} diff --git a/browser/devtools/debugger/test/browser_dbg_pretty-print-10.js b/browser/devtools/debugger/test/browser_dbg_pretty-print-10.js index 7ac029db1ffa..9037e41287fd 100644 --- a/browser/devtools/debugger/test/browser_dbg_pretty-print-10.js +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-10.js @@ -22,8 +22,7 @@ function test() { waitForSourceShown(gPanel, "code_ugly.js") .then(testSourceIsUgly) - .then(blackBoxSource) - .then(waitForThreadEvents.bind(null, gPanel, "blackboxchange")) + .then(toggleBlackBoxing.bind(null, gPanel)) .then(clickPrettyPrintButton) .then(testSourceIsStillUgly) .then(() => closeDebuggerAndFinish(gPanel)) @@ -38,12 +37,6 @@ function testSourceIsUgly() { "The source shouldn't be pretty printed yet."); } -function blackBoxSource() { - const checkbox = gDebugger.document.querySelector( - ".selected .side-menu-widget-item-checkbox"); - checkbox.click(); -} - function clickPrettyPrintButton() { gDebugger.document.getElementById("pretty-print").click(); } diff --git a/browser/devtools/debugger/test/head.js b/browser/devtools/debugger/test/head.js index d9f98b1f5f8b..f02257d1f2d3 100644 --- a/browser/devtools/debugger/test/head.js +++ b/browser/devtools/debugger/test/head.js @@ -523,3 +523,29 @@ function resumeDebuggerThenCloseAndFinish(aPanel, aFlags = {}) { thread.resume(() => closeDebuggerAndFinish(aPanel, aFlags).then(deferred.resolve)); return deferred.promise; } + +function getBlackBoxButton(aPanel) { + return aPanel.panelWin.document.getElementById("black-box"); +} + +function toggleBlackBoxing(aPanel, aSource = null) { + function clickBlackBoxButton() { + getBlackBoxButton(aPanel).click(); + } + + const blackBoxChanged = waitForThreadEvents(aPanel, "blackboxchange"); + + if (aSource) { + aPanel.panelWin.DebuggerView.Sources.selectedValue = aSource; + ensureSourceIs(aPanel, aSource, true).then(clickBlackBoxButton); + } else { + clickBlackBoxButton(); + } + return blackBoxChanged; +} + +function selectSourceAndGetBlackBoxButton(aPanel, aSource) { + aPanel.panelWin.DebuggerView.Sources.selectedValue = aSource; + return ensureSourceIs(aPanel, aSource, true) + .then(getBlackBoxButton.bind(null, aPanel)); +} diff --git a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd index e39e61234fb4..947140c9f3dc 100644 --- a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd +++ b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd @@ -33,8 +33,12 @@ - the button that opens up an options context menu for the debugger UI. --> + + + + - button that pretty prints the selected source. --> - - - - - + diff --git a/mobile/android/themes/core/aboutAddons.css b/mobile/android/themes/core/aboutAddons.css index a14d32366cbb..6f7fc2d20ddb 100644 --- a/mobile/android/themes/core/aboutAddons.css +++ b/mobile/android/themes/core/aboutAddons.css @@ -2,15 +2,6 @@ * 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/. */ -.inner { - background-color: #eef2f5; - min-height: 3.8em; - padding: 0.5em; - - /* make room for the favicon */ - -moz-margin-start: 4.5em; -} - .details { width: 100%; } @@ -33,14 +24,6 @@ bottom: -3px; } -#browse-title { - margin-top: 1em; - background-image: url("chrome://browser/skin/images/chevron.png"); - background-size: 8px 20px; - background-position: right; - background-repeat: no-repeat; -} - #header-button { background-image: url("chrome://browser/skin/images/amo-logo.png"), url("chrome://browser/skin/images/chevron.png"); background-size: 20px 20px, 8px 20px; diff --git a/mobile/android/themes/core/aboutApps.css b/mobile/android/themes/core/aboutApps.css index d4bf7be269f4..b4e55bc00270 100644 --- a/mobile/android/themes/core/aboutApps.css +++ b/mobile/android/themes/core/aboutApps.css @@ -7,16 +7,20 @@ } #header-button { - background-image: url("chrome://browser/skin/images/marketplace-logo.png"); + background-image: url("chrome://browser/skin/images/marketplace-logo.png"), url("chrome://browser/skin/images/chevron.png"); + background-size: 32px 32px, 8px 20px; + background-position: left, right 0.5em center; + -moz-padding-start: 2.5em; } #main-container { - margin: 1em; - padding: 1em; - border-radius: 10px; - border: 1px solid grey; - background-color: white; - width: calc(100% - 4em); + padding: 2em; + background-color: #EEF2F5; + border-bottom: 1px solid #BAC2AC; +} + +.hidden { + display: none; } .spacer { @@ -44,12 +48,3 @@ .app div { pointer-events: none; } - -#noapps { - padding: 1em; - text-align: center; -} - -.hidden { - display: none; -} diff --git a/mobile/android/themes/core/aboutBase.css b/mobile/android/themes/core/aboutBase.css index 7881dad24997..b7b71856b588 100644 --- a/mobile/android/themes/core/aboutBase.css +++ b/mobile/android/themes/core/aboutBase.css @@ -65,6 +65,15 @@ body { background-image: none; } +.inner { + background-color: #eef2f5; + min-height: 3.8em; + padding: 0.5em; + + /* make room for the favicon */ + -moz-margin-start: 4.5em; +} + /* Icons */ body[dir="ltr"] .icon { left: 1.35em; @@ -132,3 +141,11 @@ body[dir="ltr"] .icon { overflow: hidden; flex: 1; } + +#browse-title { + margin-top: 1em; + background-image: url("chrome://browser/skin/images/chevron.png"); + background-size: 8px 20px; + background-position: right; + background-repeat: no-repeat; +} From 5179afc10a76ac1024be4df49b7266e1f7e56ed9 Mon Sep 17 00:00:00 2001 From: Ratnadeep Debnath Date: Wed, 23 Oct 2013 14:49:51 +0300 Subject: [PATCH 06/23] Bug 923281 - Console filter output does not match source filenames; r=msucan --- browser/devtools/webconsole/test/browser.ini | 4 + .../browser_webconsole_log_file_filter.js | 80 +++++++++++++++++++ .../test-bug_923281_console_log_filter.html | 12 +++ .../webconsole/test/test-bug_923281_test1.js | 5 ++ .../webconsole/test/test-bug_923281_test2.js | 4 + browser/devtools/webconsole/webconsole.js | 2 +- 6 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js create mode 100644 browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html create mode 100644 browser/devtools/webconsole/test/test-bug_923281_test1.js create mode 100644 browser/devtools/webconsole/test/test-bug_923281_test2.js diff --git a/browser/devtools/webconsole/test/browser.ini b/browser/devtools/webconsole/test/browser.ini index a595f16a01f7..a45f7859a4a4 100644 --- a/browser/devtools/webconsole/test/browser.ini +++ b/browser/devtools/webconsole/test/browser.ini @@ -94,6 +94,9 @@ support-files = test_bug_770099_violation.html test_bug_770099_violation.html^headers^ testscript.js + test-bug_923281_console_log_filter.html + test-bug_923281_test1.js + test-bug_923281_test2.js [browser_bug664688_sandbox_update_after_navigation.js] [browser_bug_638949_copy_link_location.js] @@ -231,3 +234,4 @@ support-files = [browser_webconsole_property_provider.js] [browser_webconsole_scratchpad_panel_link.js] [browser_webconsole_view_source.js] +[browser_webconsole_log_file_filter.js] diff --git a/browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js b/browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js new file mode 100644 index 000000000000..fcb31780382d --- /dev/null +++ b/browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js @@ -0,0 +1,80 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that the text filter box works to filter based on filenames +// where the logs were generated. + +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html"; + +let hud; + +function test() { + addTab(TEST_URI); + browser.addEventListener("load", function onLoad() { + browser.removeEventListener("load", onLoad, true); + openConsole(null, consoleOpened); + }, true); +} + +function consoleOpened(aHud) { + hud = aHud; + let console = content.console; + console.log("sentinel log"); + waitForMessages({ + webconsole: hud, + messages: [{ + text: "sentinel log", + category: CATEGORY_WEBDEV, + severity: SEVERITY_LOG + }], + }).then(testLiveFilteringOnSearchStrings); +} + +function testLiveFilteringOnSearchStrings() { + is(hud.outputNode.children.length, 4, "number of messages"); + + setStringFilter("random"); + is(countMessageNodes(), 1, "the log nodes not containing string " + + "\"random\" are hidden"); + + setStringFilter("test2.js"); + is(countMessageNodes(), 2, "show only log nodes containing string " + + "\"test2.js\" or log nodes created from files with filename " + + "containing \"test2.js\" as substring."); + + setStringFilter("test1"); + is(countMessageNodes(), 2, "show only log nodes containing string " + + "\"test1\" or log nodes created from files with filename " + + "containing \"test1\" as substring."); + + setStringFilter(""); + is(countMessageNodes(), 4, "show all log nodes on setting filter string " + + "as \"\"."); + + finishTest(); +} + +function countMessageNodes() { + let outputNode = hud.outputNode; + + let messageNodes = outputNode.querySelectorAll(".message"); + content.console.log(messageNodes.length); + let displayedMessageNodes = 0; + let view = hud.iframeWindow; + for (let i = 0; i < messageNodes.length; i++) { + let computedStyle = view.getComputedStyle(messageNodes[i], null); + if (computedStyle.display !== "none") { + displayedMessageNodes++; + } + } + + return displayedMessageNodes; +} + +function setStringFilter(aValue) +{ + hud.ui.filterBox.value = aValue; + hud.ui.adjustVisibilityOnSearchStringChange(); +} + diff --git a/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html b/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html new file mode 100644 index 000000000000..f2d650a5d94f --- /dev/null +++ b/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html @@ -0,0 +1,12 @@ + + + + + Console test + + + + + + diff --git a/browser/devtools/webconsole/test/test-bug_923281_test1.js b/browser/devtools/webconsole/test/test-bug_923281_test1.js new file mode 100644 index 000000000000..81342a437688 --- /dev/null +++ b/browser/devtools/webconsole/test/test-bug_923281_test1.js @@ -0,0 +1,5 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +console.log("Sample log."); +console.log("This log should be filtered when filtered for test2.js."); diff --git a/browser/devtools/webconsole/test/test-bug_923281_test2.js b/browser/devtools/webconsole/test/test-bug_923281_test2.js new file mode 100644 index 000000000000..f523103cd1b7 --- /dev/null +++ b/browser/devtools/webconsole/test/test-bug_923281_test2.js @@ -0,0 +1,4 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +console.log("This is a random text."); diff --git a/browser/devtools/webconsole/webconsole.js b/browser/devtools/webconsole/webconsole.js index 6094cf106ac1..3636bd904803 100644 --- a/browser/devtools/webconsole/webconsole.js +++ b/browser/devtools/webconsole/webconsole.js @@ -873,7 +873,7 @@ WebConsoleFrame.prototype = { let node = nodes[i]; // hide nodes that match the strings - let text = node.clipboardText; + let text = node.textContent; // if the text matches the words in aSearchString... if (this.stringMatchesFilters(text, searchString)) { From a891a3b3da3d746fa5c653a9a724d8a593721946 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 11 Oct 2013 13:26:15 -0400 Subject: [PATCH 07/23] bug 923795 - Add condition to MozParam to detect top 2 (or N) position r=gavin --- mobile/locales/en-US/searchplugins/yahoo.xml | 2 +- toolkit/components/search/nsSearchService.js | 40 +++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/mobile/locales/en-US/searchplugins/yahoo.xml b/mobile/locales/en-US/searchplugins/yahoo.xml index 3fd2b1567f27..e5412fcd74f3 100644 --- a/mobile/locales/en-US/searchplugins/yahoo.xml +++ b/mobile/locales/en-US/searchplugins/yahoo.xml @@ -11,7 +11,7 @@ - + http://search.yahoo.com/ diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js index 15f96eb09702..6583c8975129 100644 --- a/toolkit/components/search/nsSearchService.js +++ b/toolkit/components/search/nsSearchService.js @@ -909,7 +909,33 @@ EngineURL.prototype = { this.mozparams[aObj.name] = aObj; }, + reevalMozParams: function(engine) { + for (let param of this.params) { + let mozparam = this.mozparams[param.name]; + if (mozparam && mozparam.positionDependent) { + // the condition is a string in the form of "topN", extract N as int + let positionStr = mozparam.condition.slice("top".length); + let position = parseInt(positionStr, 10); + let engines; + try { + // This will throw if we're not initialized yet (which shouldn't happen), just + // ignore and move on with the false Value (checking isInitialized also throws) + // XXX + engines = Services.search.getVisibleEngines({}); + } catch (ex) { + LOG("reevalMozParams called before search service initialization!?"); + break; + } + let index = engines.map((e) => e.wrappedJSObject).indexOf(engine.wrappedJSObject); + let isTopN = index > -1 && (index + 1) <= position; + param.value = isTopN ? mozparam.trueValue : mozparam.falseValue; + } + } + }, + getSubmission: function SRCH_EURL_getSubmission(aSearchTerms, aEngine, aPurpose) { + this.reevalMozParams(aEngine); + var url = ParamSubstitution(this.template, aSearchTerms, aEngine); // Default to an empty string if the purpose is not provided so that default purpose params // (purpose="") work consistently rather than having to define "null" and "" purposes. @@ -1647,7 +1673,8 @@ Engine.prototype = { // We only support MozParams for default search engines this._isDefault) { var value; - switch (param.getAttribute("condition")) { + let condition = param.getAttribute("condition"); + switch (condition) { case "purpose": url.addParam(param.getAttribute("name"), param.getAttribute("value"), @@ -1677,6 +1704,17 @@ Engine.prototype = { "condition": "pref"}); } catch (e) { } break; + default: + if (condition && condition.startsWith("top")) { + url.addParam(param.getAttribute("name"), param.getAttribute("falseValue")); + let mozparam = {"name": param.getAttribute("name"), + "falseValue": param.getAttribute("falseValue"), + "trueValue": param.getAttribute("trueValue"), + "condition": condition, + "positionDependent": true}; + url._addMozParam(mozparam); + } + break; } } } From 965e44f08aaccb32b697e51dd3f5ac92b8e34028 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Wed, 23 Oct 2013 14:58:06 +0200 Subject: [PATCH 08/23] Bug 918612 - Stop masking the underlying Sqlite VFS version in the Telemetry VFS. r=bent --- storage/src/TelemetryVFS.cpp | 71 ++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/storage/src/TelemetryVFS.cpp b/storage/src/TelemetryVFS.cpp index 6b4aff41940e..bcdacd7cee10 100644 --- a/storage/src/TelemetryVFS.cpp +++ b/storage/src/TelemetryVFS.cpp @@ -15,6 +15,12 @@ #include "mozilla/dom/quota/QuotaObject.h" #include "mozilla/IOInterposer.h" +// The last VFS version for which this file has been updated. +#define LAST_KNOWN_VFS_VERSION 3 + +// The last io_methods version for which this file has been updated. +#define LAST_KNOWN_IOMETHODS_VERSION 3 + /** * This preference is a workaround to allow users/sysadmins to identify * that the profile exists on an NFS share whose implementation @@ -400,10 +406,11 @@ xOpen(sqlite3_vfs* vfs, const char *zName, sqlite3_file* pFile, sqlite3_io_methods *pNew = new sqlite3_io_methods; const sqlite3_io_methods *pSub = p->pReal->pMethods; memset(pNew, 0, sizeof(*pNew)); - // If you update this version number, you must add appropriate IO methods - // for any methods added in the version change. - pNew->iVersion = 3; - MOZ_ASSERT(pNew->iVersion >= pSub->iVersion); + // If the io_methods version is higher than the last known one, you should + // update this VFS adding appropriate IO methods for any methods added in + // the version change. + pNew->iVersion = pSub->iVersion; + MOZ_ASSERT(pNew->iVersion <= LAST_KNOWN_IOMETHODS_VERSION); pNew->xClose = xClose; pNew->xRead = xRead; pNew->xWrite = xWrite; @@ -416,19 +423,23 @@ xOpen(sqlite3_vfs* vfs, const char *zName, sqlite3_file* pFile, pNew->xFileControl = xFileControl; pNew->xSectorSize = xSectorSize; pNew->xDeviceCharacteristics = xDeviceCharacteristics; - // Methods added in version 2. - pNew->xShmMap = pSub->xShmMap ? xShmMap : 0; - pNew->xShmLock = pSub->xShmLock ? xShmLock : 0; - pNew->xShmBarrier = pSub->xShmBarrier ? xShmBarrier : 0; - pNew->xShmUnmap = pSub->xShmUnmap ? xShmUnmap : 0; - // Methods added in version 3. - // SQLite 3.7.17 calls these methods without checking for nullptr first, - // so we always define them. Verify that we're not going to call - // nullptrs, though. - MOZ_ASSERT(pSub->xFetch); - pNew->xFetch = xFetch; - MOZ_ASSERT(pSub->xUnfetch); - pNew->xUnfetch = xUnfetch; + if (pNew->iVersion >= 2) { + // Methods added in version 2. + pNew->xShmMap = pSub->xShmMap ? xShmMap : 0; + pNew->xShmLock = pSub->xShmLock ? xShmLock : 0; + pNew->xShmBarrier = pSub->xShmBarrier ? xShmBarrier : 0; + pNew->xShmUnmap = pSub->xShmUnmap ? xShmUnmap : 0; + } + if (pNew->iVersion >= 3) { + // Methods added in version 3. + // SQLite 3.7.17 calls these methods without checking for nullptr first, + // so we always define them. Verify that we're not going to call + // nullptrs, though. + MOZ_ASSERT(pSub->xFetch); + pNew->xFetch = xFetch; + MOZ_ASSERT(pSub->xUnfetch); + pNew->xUnfetch = xUnfetch; + } pFile->pMethods = pNew; } return rc; @@ -572,10 +583,11 @@ sqlite3_vfs* ConstructTelemetryVFS() sqlite3_vfs *tvfs = new ::sqlite3_vfs; memset(tvfs, 0, sizeof(::sqlite3_vfs)); - // If you update this version number, you must add appropriate VFS methods - // for any methods added in the version change. - tvfs->iVersion = 3; - MOZ_ASSERT(vfs->iVersion == tvfs->iVersion); + // If the VFS version is higher than the last known one, you should update + // this VFS adding appropriate methods for any methods added in the version + // change. + tvfs->iVersion = vfs->iVersion; + MOZ_ASSERT(vfs->iVersion <= LAST_KNOWN_VFS_VERSION); tvfs->szOsFile = sizeof(telemetry_file) - sizeof(sqlite3_file) + vfs->szOsFile; tvfs->mxPathname = vfs->mxPathname; tvfs->zName = "telemetry-vfs"; @@ -592,13 +604,16 @@ sqlite3_vfs* ConstructTelemetryVFS() tvfs->xSleep = xSleep; tvfs->xCurrentTime = xCurrentTime; tvfs->xGetLastError = xGetLastError; - // Methods added in version 2. - tvfs->xCurrentTimeInt64 = xCurrentTimeInt64; - // Methods added in version 3. - tvfs->xSetSystemCall = xSetSystemCall; - tvfs->xGetSystemCall = xGetSystemCall; - tvfs->xNextSystemCall = xNextSystemCall; - + if (tvfs->iVersion >= 2) { + // Methods added in version 2. + tvfs->xCurrentTimeInt64 = xCurrentTimeInt64; + } + if (tvfs->iVersion >= 3) { + // Methods added in version 3. + tvfs->xSetSystemCall = xSetSystemCall; + tvfs->xGetSystemCall = xGetSystemCall; + tvfs->xNextSystemCall = xNextSystemCall; + } return tvfs; } From 2cb38a923132e9817b4a8a428e88ed42ff7ea0a0 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 23 Oct 2013 14:16:39 +0100 Subject: [PATCH 09/23] Bug 918007 - Factor out method to enable/disable buttons (r=sriram) --- mobile/android/base/BrowserToolbar.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index 565417a308cd..c3b59737f573 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -1564,12 +1564,17 @@ public class BrowserToolbar extends GeckoRelativeLayout } } - public void updateBackButton(boolean enabled) { - Drawable drawable = mBack.getDrawable(); - if (drawable != null) - drawable.setAlpha(enabled ? 255 : 77); + public void setButtonEnabled(ImageButton button, boolean enabled) { + final Drawable drawable = button.getDrawable(); + if (drawable != null) { + drawable.setAlpha(enabled ? 255 : 61); + } - mBack.setEnabled(enabled); + button.setEnabled(enabled); + } + + public void updateBackButton(boolean enabled) { + setButtonEnabled(mBack, enabled); } public void updateForwardButton(final boolean enabled) { From 94e4f98514c93885b5930b2827b88f32d254927c Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 23 Oct 2013 14:16:44 +0100 Subject: [PATCH 10/23] Bug 918007 - Disable toolbar elements while in editing mode on tablets (r=sriram) --- mobile/android/base/BrowserToolbar.java | 43 ++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index c3b59737f573..e32a5ebc7c59 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -1275,6 +1275,41 @@ public class BrowserToolbar extends GeckoRelativeLayout }); } + /** + * Disables and dims all toolbar elements which are not + * related to editing mode. + */ + private void updateChildrenForEditing() { + // This is for the tablet UI only + if (!HardwareUtils.isTablet()) { + return; + } + + // Disable toolbar elemens while in editing mode + final boolean enabled = !mIsEditing; + + // This alpha value has to be in sync with the one used + // in setButtonEnabled(). + final float alpha = (enabled ? 1.0f : 0.24f); + + mTabs.setEnabled(enabled); + ViewHelper.setAlpha(mTabsCounter, alpha); + mMenu.setEnabled(enabled); + ViewHelper.setAlpha(mMenuIcon, alpha); + + final int actionItemsCount = mActionItemBar.getChildCount(); + for (int i = 0; i < actionItemsCount; i++) { + mActionItemBar.getChildAt(i).setEnabled(enabled); + } + ViewHelper.setAlpha(mActionItemBar, alpha); + + final Tab tab = Tabs.getInstance().getSelectedTab(); + if (tab != null) { + setButtonEnabled(mBack, enabled && tab.canDoBack()); + setButtonEnabled(mForward, enabled && tab.canDoForward()); + } + } + /** * Returns whether or not the URL bar is in editing mode (url bar is expanded, hiding the new * tab button). Note that selection state is independent of editing mode. @@ -1291,6 +1326,8 @@ public class BrowserToolbar extends GeckoRelativeLayout mUrlEditText.setText(url != null ? url : ""); mIsEditing = true; + updateChildrenForEditing(); + if (mStartEditingListener != null) { mStartEditingListener.onStartEditing(); } @@ -1403,6 +1440,8 @@ public class BrowserToolbar extends GeckoRelativeLayout } mIsEditing = false; + updateChildrenForEditing(); + if (mStopEditingListener != null) { mStopEditingListener.onStopEditing(); } @@ -1567,6 +1606,8 @@ public class BrowserToolbar extends GeckoRelativeLayout public void setButtonEnabled(ImageButton button, boolean enabled) { final Drawable drawable = button.getDrawable(); if (drawable != null) { + // This alpha value has to be in sync with the one used + // in updateChildrenForEditing(). drawable.setAlpha(enabled ? 255 : 61); } @@ -1583,7 +1624,7 @@ public class BrowserToolbar extends GeckoRelativeLayout // Save the state on the forward button so that we can skip animations // when there's nothing to change - mForward.setEnabled(enabled); + setButtonEnabled(mForward, enabled); if (mForward.getVisibility() != View.VISIBLE) return; From 82b18180a56b45fe77ee9a279ae9bdd5ae434715 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Sat, 19 Oct 2013 21:03:30 +0200 Subject: [PATCH 11/23] Bug 927108 - Fix certified app actor installation r=paul --- toolkit/devtools/apps/tests/Makefile.in | 2 ++ .../apps/tests/data/app-certified.zip | Bin 0 -> 501 bytes .../apps/tests/test_webapps_actor.html | 20 ++++++++++++++++++ toolkit/devtools/server/actors/webapps.js | 7 ------ 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 toolkit/devtools/apps/tests/data/app-certified.zip diff --git a/toolkit/devtools/apps/tests/Makefile.in b/toolkit/devtools/apps/tests/Makefile.in index 54620e6bd3f7..c062823117fc 100644 --- a/toolkit/devtools/apps/tests/Makefile.in +++ b/toolkit/devtools/apps/tests/Makefile.in @@ -14,7 +14,9 @@ MOCHITEST_DATA_FILES = \ data/app-redirect.zip \ data/app-updated.zip \ data/app.zip \ + data/app-certified.zip \ $(NULL) + MOCHITEST_DATA_DEST = $(MOCHITEST_DEST)/data INSTALL_TARGETS += MOCHITEST_DATA endif diff --git a/toolkit/devtools/apps/tests/data/app-certified.zip b/toolkit/devtools/apps/tests/data/app-certified.zip new file mode 100644 index 0000000000000000000000000000000000000000..3dbdedb8cafbc21377cecd74db25d8bea24cdda6 GIT binary patch literal 501 zcmWIWW@Zs#U|`^2IFdTgi7D`)iaU@O3&dOuG7On{DXA5D86~+np&^_M%pVri2ZC^E z1vdjD%L`@(1~9QX(C4JT-bx*h&=VRb&u)CYsWEV6r)HU%>P%J3m1SnX45V~UrB0qQ zKPdC~(ghD@#7v4`5-=$$X3>O*fCa}>7xPbK)MA;<#1H^?N&{1X^TH1+W~Tw2Q4hrY zK&Rv;=4Ga(7MJLirzRy96oB0`VSj882&1{j^sFJ*VFMnAi+7g`%yQnHepYms_|>p% z$3+~`s+>#9{pVizY5!wBLxY!aGQUMZVI`Nkg7KRuub5=P;+b1JrNhN*4<725U+Hl1 zdC{qf_oP1GJyAS4{Nj< Date: Sat, 19 Oct 2013 21:14:44 +0200 Subject: [PATCH 12/23] Bug 920481 - Ensure flushing jar cache when updating an app. r=paul --- toolkit/devtools/server/actors/webapps.js | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/toolkit/devtools/server/actors/webapps.js b/toolkit/devtools/server/actors/webapps.js index 5ab3cb822d4c..4cb07d49893b 100644 --- a/toolkit/devtools/server/actors/webapps.js +++ b/toolkit/devtools/server/actors/webapps.js @@ -418,12 +418,41 @@ WebappsActor.prototype = { zipFile.moveTo(installDir, "application.zip"); let origin = "app://" + id; + let manifestURL = origin + "/manifest.webapp"; + + // Refresh application.zip content (e.g. reinstall app), as done here: + // http://hg.mozilla.org/mozilla-central/annotate/aaefec5d34f8/dom/apps/src/Webapps.jsm#l1125 + // Do it in parent process for the simulator + let jar = installDir.clone(); + jar.append("application.zip"); + Services.obs.notifyObservers(jar, "flush-cache-entry", null); + + // And then in app content process + // This function will be evaluated in the scope of the content process + // frame script. That will flush the jar cache for this app and allow + // loading fresh updated resources if we reload its document. + let FlushFrameScript = function (path) { + let jar = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + jar.initWithPath(path); + let obs = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + obs.notifyObservers(jar, "flush-cache-entry", null); + }; + for each (let frame in self._appFrames()) { + if (frame.getAttribute("mozapp") == manifestURL) { + let mm = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; + mm.loadFrameScript("data:," + + encodeURIComponent("(" + FlushFrameScript.toString() + ")" + + "('" + jar.path + "')"), false); + } + } // Create a fake app object with the minimum set of properties we need. let app = { origin: origin, installOrigin: origin, - manifestURL: origin + "/manifest.webapp", + manifestURL: manifestURL, appStatus: appType, receipts: aReceipts, } From 3d0405de6366262b76de40af23fea07d346a24ae Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Sat, 19 Oct 2013 21:14:47 +0200 Subject: [PATCH 13/23] Bug 920481 - Call BrowserTabActor.reload when the app is updated to refresh the app. r=paul --- .../devtools/app-manager/content/projects.js | 30 ++++++++++++------- toolkit/devtools/apps/app-actor-front.js | 21 +++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/browser/devtools/app-manager/content/projects.js b/browser/devtools/app-manager/content/projects.js index f2f9ad980d3e..d2791e561916 100644 --- a/browser/devtools/app-manager/content/projects.js +++ b/browser/devtools/app-manager/content/projects.js @@ -14,7 +14,7 @@ const {AppProjects} = require("devtools/app-manager/app-projects"); const {AppValidator} = require("devtools/app-manager/app-validator"); const {Services} = Cu.import("resource://gre/modules/Services.jsm"); const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm"); -const {installHosted, installPackaged, getTargetForApp} = require("devtools/app-actor-front"); +const {installHosted, installPackaged, getTargetForApp, reloadApp} = require("devtools/app-actor-front"); const {EventEmitter} = Cu.import("resource:///modules/devtools/shared/event-emitter.js"); const promise = require("sdk/core/promise"); @@ -174,16 +174,26 @@ let UI = { return this.install(project); } }) - .then( - () => { + .then(() => { button.disabled = false; - }, - (res) => { - button.disabled = false; - let message = res.error + ": " + res.message; - alert(message); - this.connection.log(message); - }); + // Finally try to reload the app if it is already opened + this.reload(project); + }, + (res) => { + button.disabled = false; + let message = res.error + ": " + res.message; + alert(message); + this.connection.log(message); + }); + }, + + reload: function (project) { + return reloadApp(this.connection.client, + this.listTabsResponse.webappsActor, + this._getProjectManifestURL(project)). + then(() => { + this.connection.log("App reloaded"); + }); }, remove: function(location, event) { diff --git a/toolkit/devtools/apps/app-actor-front.js b/toolkit/devtools/apps/app-actor-front.js index 30bbb08ec86d..aef75a7790c5 100644 --- a/toolkit/devtools/apps/app-actor-front.js +++ b/toolkit/devtools/apps/app-actor-front.js @@ -240,3 +240,24 @@ function getTargetForApp(client, webappsActor, manifestURL) { } exports.getTargetForApp = getTargetForApp; +function reloadApp(client, webappsActor, manifestURL) { + let deferred = promise.defer(); + getTargetForApp(client, + webappsActor, + manifestURL). + then((target) => { + // Request the ContentAppActor to reload the app + let request = { + to: target.form.actor, + type: "reload", + manifestURL: manifestURL + }; + client.request(request, (res) => { + deferred.resolve(); + }); + }, () => { + deferred.reject("Not running"); + }); + return deferred.promise; +} +exports.reloadApp = reloadApp; From 11a5db9242d57f64d811c19443349784bef4a1aa Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Wed, 23 Oct 2013 10:13:53 -0400 Subject: [PATCH 14/23] Bug 848671 - Intermittent testBookmark | bookmark added successfully - got false, expected true, r=lucasr, f=adriant --- mobile/android/base/tests/testBookmark.java.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/tests/testBookmark.java.in b/mobile/android/base/tests/testBookmark.java.in index 3d332884e498..35c959d6570d 100644 --- a/mobile/android/base/tests/testBookmark.java.in +++ b/mobile/android/base/tests/testBookmark.java.in @@ -13,8 +13,6 @@ public class testBookmark extends AboutHomeTest { private static String BOOKMARK_URL; private static int WAIT_FOR_BOOKMARKED_TIMEOUT = 10000; - Navigation nav; - @Override protected int getTestType() { return TEST_MOCHITEST; @@ -22,7 +20,6 @@ public class testBookmark extends AboutHomeTest { public void testBookmark() { BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); - nav = new Navigation(mDevice); runAboutHomeTest(); runMenuTest(); } @@ -70,7 +67,7 @@ public class testBookmark extends AboutHomeTest { // Bookmark a page for the test loadUrl(BOOKMARK_URL); waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); - nav.bookmark(); + toggleBookmark(); mAsserter.is(waitForText(StringHelper.BOOKMARK_ADDED_LABEL), true, "bookmark added successfully"); } @@ -78,7 +75,7 @@ public class testBookmark extends AboutHomeTest { // Go back to the page we bookmarked loadUrl(BOOKMARK_URL); waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); - nav.bookmark(); + toggleBookmark(); mAsserter.is(waitForText(StringHelper.BOOKMARK_REMOVED_LABEL), true, "bookmark removed successfully"); } } From 248e190c71deecd37923101a55ae6bd241205ec8 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 23 Oct 2013 15:55:34 +0100 Subject: [PATCH 15/23] Backed out changeset 0117133ba8ef (bug 918007) --- mobile/android/base/BrowserToolbar.java | 43 +------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index e32a5ebc7c59..c3b59737f573 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -1275,41 +1275,6 @@ public class BrowserToolbar extends GeckoRelativeLayout }); } - /** - * Disables and dims all toolbar elements which are not - * related to editing mode. - */ - private void updateChildrenForEditing() { - // This is for the tablet UI only - if (!HardwareUtils.isTablet()) { - return; - } - - // Disable toolbar elemens while in editing mode - final boolean enabled = !mIsEditing; - - // This alpha value has to be in sync with the one used - // in setButtonEnabled(). - final float alpha = (enabled ? 1.0f : 0.24f); - - mTabs.setEnabled(enabled); - ViewHelper.setAlpha(mTabsCounter, alpha); - mMenu.setEnabled(enabled); - ViewHelper.setAlpha(mMenuIcon, alpha); - - final int actionItemsCount = mActionItemBar.getChildCount(); - for (int i = 0; i < actionItemsCount; i++) { - mActionItemBar.getChildAt(i).setEnabled(enabled); - } - ViewHelper.setAlpha(mActionItemBar, alpha); - - final Tab tab = Tabs.getInstance().getSelectedTab(); - if (tab != null) { - setButtonEnabled(mBack, enabled && tab.canDoBack()); - setButtonEnabled(mForward, enabled && tab.canDoForward()); - } - } - /** * Returns whether or not the URL bar is in editing mode (url bar is expanded, hiding the new * tab button). Note that selection state is independent of editing mode. @@ -1326,8 +1291,6 @@ public class BrowserToolbar extends GeckoRelativeLayout mUrlEditText.setText(url != null ? url : ""); mIsEditing = true; - updateChildrenForEditing(); - if (mStartEditingListener != null) { mStartEditingListener.onStartEditing(); } @@ -1440,8 +1403,6 @@ public class BrowserToolbar extends GeckoRelativeLayout } mIsEditing = false; - updateChildrenForEditing(); - if (mStopEditingListener != null) { mStopEditingListener.onStopEditing(); } @@ -1606,8 +1567,6 @@ public class BrowserToolbar extends GeckoRelativeLayout public void setButtonEnabled(ImageButton button, boolean enabled) { final Drawable drawable = button.getDrawable(); if (drawable != null) { - // This alpha value has to be in sync with the one used - // in updateChildrenForEditing(). drawable.setAlpha(enabled ? 255 : 61); } @@ -1624,7 +1583,7 @@ public class BrowserToolbar extends GeckoRelativeLayout // Save the state on the forward button so that we can skip animations // when there's nothing to change - setButtonEnabled(mForward, enabled); + mForward.setEnabled(enabled); if (mForward.getVisibility() != View.VISIBLE) return; From 63991a5029264514d3ab1b2c164df2f7ae3c305e Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 23 Oct 2013 15:56:00 +0100 Subject: [PATCH 16/23] Backed out changeset 2d8cdd7baa58 (bug 918007) for test failures on a CLOSED TREE --- mobile/android/base/BrowserToolbar.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index c3b59737f573..565417a308cd 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -1564,17 +1564,12 @@ public class BrowserToolbar extends GeckoRelativeLayout } } - public void setButtonEnabled(ImageButton button, boolean enabled) { - final Drawable drawable = button.getDrawable(); - if (drawable != null) { - drawable.setAlpha(enabled ? 255 : 61); - } - - button.setEnabled(enabled); - } - public void updateBackButton(boolean enabled) { - setButtonEnabled(mBack, enabled); + Drawable drawable = mBack.getDrawable(); + if (drawable != null) + drawable.setAlpha(enabled ? 255 : 77); + + mBack.setEnabled(enabled); } public void updateForwardButton(final boolean enabled) { From 1df19015c84f8e7192358da8605abde984af9273 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 23 Oct 2013 16:14:35 +0100 Subject: [PATCH 17/23] Backed out changeset 1864e27d5ee4 (bug 920481) --- .../devtools/app-manager/content/projects.js | 30 +++++++------------ toolkit/devtools/apps/app-actor-front.js | 21 ------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/browser/devtools/app-manager/content/projects.js b/browser/devtools/app-manager/content/projects.js index d2791e561916..f2f9ad980d3e 100644 --- a/browser/devtools/app-manager/content/projects.js +++ b/browser/devtools/app-manager/content/projects.js @@ -14,7 +14,7 @@ const {AppProjects} = require("devtools/app-manager/app-projects"); const {AppValidator} = require("devtools/app-manager/app-validator"); const {Services} = Cu.import("resource://gre/modules/Services.jsm"); const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm"); -const {installHosted, installPackaged, getTargetForApp, reloadApp} = require("devtools/app-actor-front"); +const {installHosted, installPackaged, getTargetForApp} = require("devtools/app-actor-front"); const {EventEmitter} = Cu.import("resource:///modules/devtools/shared/event-emitter.js"); const promise = require("sdk/core/promise"); @@ -174,26 +174,16 @@ let UI = { return this.install(project); } }) - .then(() => { + .then( + () => { button.disabled = false; - // Finally try to reload the app if it is already opened - this.reload(project); - }, - (res) => { - button.disabled = false; - let message = res.error + ": " + res.message; - alert(message); - this.connection.log(message); - }); - }, - - reload: function (project) { - return reloadApp(this.connection.client, - this.listTabsResponse.webappsActor, - this._getProjectManifestURL(project)). - then(() => { - this.connection.log("App reloaded"); - }); + }, + (res) => { + button.disabled = false; + let message = res.error + ": " + res.message; + alert(message); + this.connection.log(message); + }); }, remove: function(location, event) { diff --git a/toolkit/devtools/apps/app-actor-front.js b/toolkit/devtools/apps/app-actor-front.js index aef75a7790c5..30bbb08ec86d 100644 --- a/toolkit/devtools/apps/app-actor-front.js +++ b/toolkit/devtools/apps/app-actor-front.js @@ -240,24 +240,3 @@ function getTargetForApp(client, webappsActor, manifestURL) { } exports.getTargetForApp = getTargetForApp; -function reloadApp(client, webappsActor, manifestURL) { - let deferred = promise.defer(); - getTargetForApp(client, - webappsActor, - manifestURL). - then((target) => { - // Request the ContentAppActor to reload the app - let request = { - to: target.form.actor, - type: "reload", - manifestURL: manifestURL - }; - client.request(request, (res) => { - deferred.resolve(); - }); - }, () => { - deferred.reject("Not running"); - }); - return deferred.promise; -} -exports.reloadApp = reloadApp; From f7d2621ce92c961f8cb07d1d122eb8f849c0da13 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 23 Oct 2013 16:15:02 +0100 Subject: [PATCH 18/23] Backed out changeset 54da01870611 (bug 920481) for test_webapps_actor.html timeouts on a CLOSED TREE --- toolkit/devtools/server/actors/webapps.js | 31 +---------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/toolkit/devtools/server/actors/webapps.js b/toolkit/devtools/server/actors/webapps.js index 4cb07d49893b..5ab3cb822d4c 100644 --- a/toolkit/devtools/server/actors/webapps.js +++ b/toolkit/devtools/server/actors/webapps.js @@ -418,41 +418,12 @@ WebappsActor.prototype = { zipFile.moveTo(installDir, "application.zip"); let origin = "app://" + id; - let manifestURL = origin + "/manifest.webapp"; - - // Refresh application.zip content (e.g. reinstall app), as done here: - // http://hg.mozilla.org/mozilla-central/annotate/aaefec5d34f8/dom/apps/src/Webapps.jsm#l1125 - // Do it in parent process for the simulator - let jar = installDir.clone(); - jar.append("application.zip"); - Services.obs.notifyObservers(jar, "flush-cache-entry", null); - - // And then in app content process - // This function will be evaluated in the scope of the content process - // frame script. That will flush the jar cache for this app and allow - // loading fresh updated resources if we reload its document. - let FlushFrameScript = function (path) { - let jar = Components.classes["@mozilla.org/file/local;1"] - .createInstance(Components.interfaces.nsILocalFile); - jar.initWithPath(path); - let obs = Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService); - obs.notifyObservers(jar, "flush-cache-entry", null); - }; - for each (let frame in self._appFrames()) { - if (frame.getAttribute("mozapp") == manifestURL) { - let mm = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; - mm.loadFrameScript("data:," + - encodeURIComponent("(" + FlushFrameScript.toString() + ")" + - "('" + jar.path + "')"), false); - } - } // Create a fake app object with the minimum set of properties we need. let app = { origin: origin, installOrigin: origin, - manifestURL: manifestURL, + manifestURL: origin + "/manifest.webapp", appStatus: appType, receipts: aReceipts, } From 100a83a95af301ba81b8885e86fba712b526dd3e Mon Sep 17 00:00:00 2001 From: Brandon Benvie Date: Fri, 18 Oct 2013 12:28:40 -0700 Subject: [PATCH 19/23] Bug 862849 - Remove __iterator__ use from the devtools. r=vp --- browser/devtools/debugger/CmdDebugger.jsm | 4 ++-- browser/devtools/debugger/debugger-panes.js | 22 ++++++++--------- browser/devtools/debugger/debugger-toolbar.js | 2 +- .../browser_dbg_breakpoints-contextmenu.js | 24 +++++++++---------- .../devtools/netmonitor/netmonitor-view.js | 4 ++-- .../test/browser_scratchpad_inspect.js | 6 ++--- .../devtools/shared/widgets/VariablesView.jsm | 16 ++++++------- .../devtools/shared/widgets/ViewHelpers.jsm | 12 +++++----- browser/devtools/webconsole/test/head.js | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/browser/devtools/debugger/CmdDebugger.jsm b/browser/devtools/debugger/CmdDebugger.jsm index 3f910d7dce87..59231e23eebf 100644 --- a/browser/devtools/debugger/CmdDebugger.jsm +++ b/browser/devtools/debugger/CmdDebugger.jsm @@ -37,8 +37,8 @@ function getAllBreakpoints(dbg) { let sources = dbg._view.Sources; let { trimUrlLength: trim } = dbg.panelWin.SourceUtils; - for (let source in sources) { - for (let { attachment: breakpoint } in source) { + for (let source of sources) { + for (let { attachment: breakpoint } of source) { breakpoints.push({ url: source.value, label: source.label + ":" + breakpoint.line, diff --git a/browser/devtools/debugger/debugger-panes.js b/browser/devtools/debugger/debugger-panes.js index 96a2df05a96f..31a555f7ddcd 100644 --- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -232,8 +232,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { * The corresponding breakpoints if found, an empty array otherwise. */ getOtherBreakpoints: function(aLocation = {}, aStore = []) { - for (let source in this) { - for (let breakpointItem in source) { + for (let source of this) { + for (let breakpointItem of source) { let { url, line } = breakpointItem.attachment; if (url != aLocation.url || line != aLocation.line) { aStore.push(breakpointItem); @@ -1369,7 +1369,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, { */ switchExpression: function(aVar, aExpression) { let expressionItem = - [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0]; + [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression if it's going to be empty or a duplicate. if (!aExpression || this.getAllStrings().indexOf(aExpression) != -1) { @@ -1395,7 +1395,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, { */ deleteExpression: function(aVar) { let expressionItem = - [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0]; + [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression. this.remove(expressionItem); @@ -2027,7 +2027,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, { _createGlobalResultsUI: function(aGlobalResults) { let i = 0; - for (let sourceResults in aGlobalResults) { + for (let sourceResults of aGlobalResults) { if (i++ == 0) { this._createSourceResultsUI(sourceResults); } else { @@ -2152,7 +2152,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, { /** * An object containing all source results, grouped by source location. - * Iterable via "for (let [location, sourceResults] in globalResults) { }". + * Iterable via "for (let [location, sourceResults] of globalResults) { }". */ function GlobalResults() { this._store = []; @@ -2179,7 +2179,7 @@ GlobalResults.prototype = { /** * An object containing all the matched lines for a specific source. - * Iterable via "for (let [lineNumber, lineResults] in sourceResults) { }". + * Iterable via "for (let [lineNumber, lineResults] of sourceResults) { }". * * @param string aUrl * The target source url. @@ -2320,7 +2320,7 @@ SourceResults.prototype = { /** * An object containing all the matches for a specific line. - * Iterable via "for (let chunk in lineResults) { }". + * Iterable via "for (let chunk of lineResults) { }". * * @param number aLine * The target line in the source. @@ -2465,9 +2465,9 @@ LineResults.prototype = { /** * A generator-iterator over the global, source or line results. */ -GlobalResults.prototype.__iterator__ = -SourceResults.prototype.__iterator__ = -LineResults.prototype.__iterator__ = function() { +GlobalResults.prototype.iterator = +SourceResults.prototype.iterator = +LineResults.prototype.iterator = function() { for (let item of this._store) { yield item; } diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 00416ad16891..4ce4f7620325 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -615,7 +615,7 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, { // Update the context menu to show the currently selected stackframe item // as a checked entry. - for (let otherItem in this) { + for (let otherItem of this) { if (otherItem != stackframeItem) { otherItem.attachment.popup.menuitem.removeAttribute("checked"); } else { diff --git a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js index 838c45e2794e..1212e4fe85cb 100644 --- a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js @@ -107,8 +107,8 @@ function test() { } function initialChecks() { - for (let source in gSources) { - for (let breakpoint in source) { + for (let source of gSources) { + for (let breakpoint of source) { ok(gBreakpoints._getAdded(breakpoint.attachment), "All breakpoint items should have corresponding promises (1)."); ok(!gBreakpoints._getRemoving(breakpoint.attachment), @@ -223,8 +223,8 @@ function test() { is(!!selectedBreakpoint.attachment.disabled, false, "The targetted breakpoint should not have been disabled (" + aIndex + ")."); - for (let source in gSources) { - for (let otherBreakpoint in source) { + for (let source of gSources) { + for (let otherBreakpoint of source) { if (otherBreakpoint != selectedBreakpoint) { ok(!gBreakpoints._getAdded(otherBreakpoint.attachment), "There should be no breakpoint client for a disabled breakpoint (9)."); @@ -235,8 +235,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 4).then(() => { - for (let source in gSources) { - for (let someBreakpoint in source) { + for (let source of gSources) { + for (let someBreakpoint of source) { ok(gBreakpoints._getAdded(someBreakpoint.attachment), "There should be a breakpoint client for all enabled breakpoints (11)."); is(someBreakpoint.attachment.disabled, false, @@ -245,8 +245,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => { - for (let source in gSources) { - for (let someBreakpoint in source) { + for (let source of gSources) { + for (let someBreakpoint of source) { ok(!gBreakpoints._getAdded(someBreakpoint.attachment), "There should be no breakpoint client for a disabled breakpoint (13)."); is(someBreakpoint.attachment.disabled, true, @@ -255,8 +255,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 5).then(() => { - for (let source in gSources) { - for (let someBreakpoint in source) { + for (let source of gSources) { + for (let someBreakpoint of source) { ok(gBreakpoints._getAdded(someBreakpoint.attachment), "There should be a breakpoint client for all enabled breakpoints (15)."); is(someBreakpoint.attachment.disabled, false, @@ -293,8 +293,8 @@ function test() { ok(!gSources._selectedBreakpointItem, "There should be no breakpoint available after removing all breakpoints."); - for (let source in gSources) { - for (let otherBreakpoint in source) { + for (let source of gSources) { + for (let otherBreakpoint of source) { ok(false, "It's a trap!"); } } diff --git a/browser/devtools/netmonitor/netmonitor-view.js b/browser/devtools/netmonitor/netmonitor-view.js index e139e201e6ab..1732d2348857 100644 --- a/browser/devtools/netmonitor/netmonitor-view.js +++ b/browser/devtools/netmonitor/netmonitor-view.js @@ -1007,7 +1007,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { // Apply CSS transforms to each waterfall in this container totalTime // accurately translate and resize as needed. - for (let { target, attachment } in this) { + for (let { target, attachment } of this) { let timingsNode = $(".requests-menu-timings", target); let startCapNode = $(".requests-menu-timings-cap.start", target); let endCapNode = $(".requests-menu-timings-cap.end", target); @@ -1143,7 +1143,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { * Reapplies the current waterfall background on all request items. */ _flushWaterfallBackgrounds: function() { - for (let { target } in this) { + for (let { target } of this) { let waterfallNode = $(".requests-menu-waterfall", target); waterfallNode.style.backgroundImage = this._cachedWaterfallBackground; } diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js index b4e81a9916c4..1f1b5651757e 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js @@ -28,9 +28,9 @@ function runTests() let found = false; - outer: for (let scope in sidebar.variablesView) { - for (let [, obj] in scope) { - for (let [, prop] in obj) { + outer: for (let scope of sidebar.variablesView) { + for (let [, obj] of scope) { + for (let [, prop] of obj) { if (prop.name == "a" && prop.value == "foobarBug636725") { found = true; break outer; diff --git a/browser/devtools/shared/widgets/VariablesView.jsm b/browser/devtools/shared/widgets/VariablesView.jsm index 68d44ba3d438..8ace2f7538ba 100644 --- a/browser/devtools/shared/widgets/VariablesView.jsm +++ b/browser/devtools/shared/widgets/VariablesView.jsm @@ -55,7 +55,7 @@ const STR = Services.strings.createBundle(DBG_STRINGS_URI); /** * A tree view for inspecting scopes, objects and properties. - * Iterable via "for (let [id, scope] in instance) { }". + * Iterable via "for (let [id, scope] of instance) { }". * Requires the devtools common.css and debugger.css skin stylesheets. * * To allow replacing variable or property values in this view, provide an @@ -1092,7 +1092,7 @@ VariablesView.getterOrSetterDeleteCallback = function(aItem) { /** * A Scope is an object holding Variable instances. - * Iterable via "for (let [name, variable] in instance) { }". + * Iterable via "for (let [name, variable] of instance) { }". * * @param VariablesView aView * The view to contain this scope. @@ -2042,7 +2042,7 @@ DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_batchItems", Array); /** * A Variable is a Scope holding Property instances. - * Iterable via "for (let [name, property] in instance) { }". + * Iterable via "for (let [name, property] of instance) { }". * * @param Scope aScope * The scope to contain this variable. @@ -2826,7 +2826,7 @@ Variable.prototype = Heritage.extend(Scope.prototype, { /** * A Property is a Variable holding additional child Property instances. - * Iterable via "for (let [name, property] in instance) { }". + * Iterable via "for (let [name, property] of instance) { }". * * @param Variable aVar * The variable to contain this property. @@ -2887,10 +2887,10 @@ Property.prototype = Heritage.extend(Variable.prototype, { /** * A generator-iterator over the VariablesView, Scopes, Variables and Properties. */ -VariablesView.prototype.__iterator__ = -Scope.prototype.__iterator__ = -Variable.prototype.__iterator__ = -Property.prototype.__iterator__ = function() { +VariablesView.prototype.iterator = +Scope.prototype.iterator = +Variable.prototype.iterator = +Property.prototype.iterator = function() { for (let item of this._store) { yield item; } diff --git a/browser/devtools/shared/widgets/ViewHelpers.jsm b/browser/devtools/shared/widgets/ViewHelpers.jsm index 44aa32485d52..1fd478e5d112 100644 --- a/browser/devtools/shared/widgets/ViewHelpers.jsm +++ b/browser/devtools/shared/widgets/ViewHelpers.jsm @@ -405,7 +405,7 @@ ViewHelpers.Prefs.prototype = { /** * A generic Item is used to describe children present in a Widget. * The label, value and description properties are necessarily strings. - * Iterable via "for (let childItem in parentItem) { }". + * Iterable via "for (let childItem of parentItem) { }". * * @param object aOwnerView * The owner view creating this item. @@ -513,7 +513,7 @@ Item.prototype = { if (aItem.finalize) { aItem.finalize(aItem); } - for (let childItem in aItem) { + for (let childItem of aItem) { aItem.remove(childItem); } @@ -557,7 +557,7 @@ Item.prototype = { /** * Some generic Widget methods handling Item instances. - * Iterable via "for (let childItem in wrappedView) { }". + * Iterable via "for (let childItem of wrappedView) { }". * * Usage: * function MyView() { @@ -1517,7 +1517,7 @@ this.WidgetMethods = { if (aItem.finalize) { aItem.finalize(aItem); } - for (let childItem in aItem) { + for (let childItem of aItem) { aItem.remove(childItem); } @@ -1642,8 +1642,8 @@ this.WidgetMethods = { /** * A generator-iterator over all the items in this container. */ -Item.prototype.__iterator__ = -WidgetMethods.__iterator__ = function() { +Item.prototype.iterator = +WidgetMethods.iterator = function() { for (let [, item] of this._itemsByElement) { yield item; } diff --git a/browser/devtools/webconsole/test/head.js b/browser/devtools/webconsole/test/head.js index 526d8a3c02df..43fd4dcdd860 100644 --- a/browser/devtools/webconsole/test/head.js +++ b/browser/devtools/webconsole/test/head.js @@ -447,7 +447,7 @@ function findVariableViewProperties(aView, aRules, aOptions) function finder(aRules, aVar, aPromises) { - for (let [id, prop] in aVar) { + for (let [id, prop] of aVar) { for (let rule of aRules) { let matcher = matchVariablesViewProperty(prop, rule, aOptions); aPromises.push(matcher.then(onMatch.bind(null, prop, rule))); From 3941da6c8067a13df6f0293b88347de6fa0bd593 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 23 Oct 2013 19:05:41 +0200 Subject: [PATCH 20/23] Bug 928630 - Wait for the initial window's delayed startup to be finished before restoring a session; r=smacleod --- .../sessionstore/src/SessionStore.jsm | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/browser/components/sessionstore/src/SessionStore.jsm b/browser/components/sessionstore/src/SessionStore.jsm index ec09cf0de6c1..7464bf6e4a5b 100644 --- a/browser/components/sessionstore/src/SessionStore.jsm +++ b/browser/components/sessionstore/src/SessionStore.jsm @@ -350,6 +350,10 @@ let SessionStoreInternal = { // See bug 516755. _disabledForMultiProcess: false, + // Promise that is resolved when we're ready to initialize + // and restore the session. + _promiseReadyForInitialization: null, + /** * A promise fulfilled once initialization is complete. */ @@ -870,13 +874,33 @@ let SessionStoreInternal = { return; } + // The very first window that is opened creates a promise that is then + // re-used by all subsequent windows. The promise will be used to tell + // when we're ready for initialization. + if (!this._promiseReadyForInitialization) { + let deferred = Promise.defer(); + + // Wait for the given window's delayed startup to be finished. + Services.obs.addObserver(function obs(subject, topic) { + if (aWindow == subject) { + Services.obs.removeObserver(obs, topic); + deferred.resolve(); + } + }, "browser-delayed-startup-finished", false); + + // We are ready for initialization as soon as the session file has been + // read from disk and the initial window's delayed startup has finished. + this._promiseReadyForInitialization = + Promise.all([deferred.promise, gSessionStartup.onceInitialized]); + } + // We can't call this.onLoad since initialization // hasn't completed, so we'll wait until it is done. // Even if additional windows are opened and wait // for initialization as well, the first opened // window should execute first, and this.onLoad // will be called with the initialState. - gSessionStartup.onceInitialized.then(() => { + this._promiseReadyForInitialization.then(() => { if (aWindow.closed) { return; } From cd2ba67f77f17f7aac3a4782f47c91470a8fb152 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Wed, 23 Oct 2013 21:46:47 +0200 Subject: [PATCH 21/23] Bug 928349 - Add a build-time setting to use only the JavaScript API for downloads, and enable it in Firefox for Desktop. r=enn --- browser/app/profile/firefox.js | 6 ---- .../downloads/src/DownloadsCommon.jsm | 22 +++++--------- .../downloads/src/DownloadsStartup.js | 30 +++++-------------- browser/components/nsBrowserGlue.js | 3 -- browser/confvars.sh | 2 ++ configure.in | 5 ++++ .../mixedcontent/test_bug383369.html | 7 +++-- .../downloads/nsDownloadManager.cpp | 21 +++++++++++++ toolkit/components/downloads/test/moz.build | 8 +++-- .../test/unit/head_download_manager.js | 9 +++--- toolkit/forgetaboutsite/ForgetAboutSite.jsm | 7 +++-- .../test/unit/head_forgetaboutsite.js | 11 +++++++ .../test/unit/test_removeDataFromDomain.js | 12 ++++++++ ...st_removeDataFromDomain_activeDownloads.js | 4 +++ .../downloads/DownloadTaskbarProgress.jsm | 9 ------ .../chrome/test_taskbarprogress_service.xul | 6 ++++ .../mozapps/downloads/tests/chrome/utils.js | 9 +++--- uriloader/exthandler/tests/moz.build | 5 +++- 18 files changed, 104 insertions(+), 72 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 1ae1f785d1b6..22e8fadb0881 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -365,12 +365,6 @@ pref("browser.download.manager.quitBehavior", 0); pref("browser.download.manager.scanWhenDone", true); pref("browser.download.manager.resumeOnWakeDelay", 10000); -// Enables the asynchronous Downloads API in the Downloads Panel. -pref("browser.download.useJSTransfer", true); - -// This allows disabling the Downloads Panel in favor of the old interface. -pref("browser.download.useToolkitUI", false); - // This allows disabling the animated notifications shown by // the Downloads Indicator when a download starts or completes. pref("browser.download.animateNotifications", true); diff --git a/browser/components/downloads/src/DownloadsCommon.jsm b/browser/components/downloads/src/DownloadsCommon.jsm index 45ea0a3da013..2fbb8dcb32d3 100644 --- a/browser/components/downloads/src/DownloadsCommon.jsm +++ b/browser/components/downloads/src/DownloadsCommon.jsm @@ -235,15 +235,12 @@ this.DownloadsCommon = { }, /** - * Indicates whether we should show the full Download Manager window interface - * instead of the simplified panel interface. The behavior of downloads - * across browsing session is consistent with the selected interface. + * Indicates that we should show the simplified panel interface instead of the + * full Download Manager window interface. The code associated with the + * Download Manager window interface will be removed in bug 899110. */ get useToolkitUI() { - try { - return Services.prefs.getBoolPref("browser.download.useToolkitUI"); - } catch (ex) { } return false; }, @@ -570,17 +567,12 @@ XPCOMUtils.defineLazyGetter(DownloadsCommon, "isWinVistaOrHigher", function () { }); /** - * Returns true if we should hook the panel to the JavaScript API for downloads - * instead of the nsIDownloadManager back-end. In order for the logic to work - * properly, this value never changes during the execution of the application, - * even if the underlying preference value has changed. A restart is required - * for the change to take effect. + * Returns true to indicate that we should hook the panel to the JavaScript API + * for downloads instead of the nsIDownloadManager back-end. The code + * associated with nsIDownloadManager will be removed in bug 899110. */ XPCOMUtils.defineLazyGetter(DownloadsCommon, "useJSTransfer", function () { - try { - return Services.prefs.getBoolPref("browser.download.useJSTransfer"); - } catch (ex) { } - return false; + return true; }); //////////////////////////////////////////////////////////////////////////////// diff --git a/browser/components/downloads/src/DownloadsStartup.js b/browser/components/downloads/src/DownloadsStartup.js index c46039d73956..7a0a1a995a16 100644 --- a/browser/components/downloads/src/DownloadsStartup.js +++ b/browser/components/downloads/src/DownloadsStartup.js @@ -93,29 +93,13 @@ DownloadsStartup.prototype = { .registerFactory(kDownloadsUICid, "", kDownloadsUIContractId, null); - // If the integration preference is enabled, override Toolkit's - // nsITransfer implementation with the one from the JavaScript API for - // downloads. This should be used only by developers while testing new - // code that uses the JavaScript API, and will eventually be removed - // when nsIDownloadManager will not be available anymore (bug 851471). - let useJSTransfer = false; - try { - // For performance reasons, we don't want to load the DownloadsCommon - // module during startup, so we read the preference value directly. - useJSTransfer = - Services.prefs.getBoolPref("browser.download.useJSTransfer"); - } catch (ex) { } - if (useJSTransfer) { - Components.manager.QueryInterface(Ci.nsIComponentRegistrar) - .registerFactory(kTransferCid, "", - kTransferContractId, null); - } else { - // The other notifications are handled internally by the JavaScript - // API for downloads, no need to observe when that API is enabled. - for (let topic of kObservedTopics) { - Services.obs.addObserver(this, topic, true); - } - } + // Override Toolkit's nsITransfer implementation with the one from the + // JavaScript API for downloads. This will eventually be removed when + // nsIDownloadManager will not be available anymore (bug 851471). The + // old code in this module will be removed in bug 899110. + Components.manager.QueryInterface(Ci.nsIComponentRegistrar) + .registerFactory(kTransferCid, "", + kTransferContractId, null); break; case "sessionstore-windows-restored": diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index efb2e60525c5..4c1fa14be982 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -1420,9 +1420,6 @@ BrowserGlue.prototype = { } this._setPersist(toolbarResource, currentsetResource, currentset); } - - Services.prefs.clearUserPref("browser.download.useToolkitUI"); - Services.prefs.clearUserPref("browser.library.useNewDownloadsView"); } #ifdef XP_WIN diff --git a/browser/confvars.sh b/browser/confvars.sh index b053088df427..1f2a0dcad12f 100755 --- a/browser/confvars.sh +++ b/browser/confvars.sh @@ -61,3 +61,5 @@ fi MOZ_WEBGL_CONFORMANT=1 # Enable navigator.mozPay MOZ_PAY=1 +MOZ_JSDOWNLOADS=1 + diff --git a/configure.in b/configure.in index 42b120e69082..68de12cd93d2 100644 --- a/configure.in +++ b/configure.in @@ -8342,6 +8342,11 @@ AC_SUBST(MOZ_POST_DSO_LIB_COMMAND) AC_SUBST(MOZ_POST_PROGRAM_COMMAND) AC_SUBST(MOZ_LINKER_EXTRACT) +AC_SUBST(MOZ_JSDOWNLOADS) +if test -n "$MOZ_JSDOWNLOADS"; then + AC_DEFINE(MOZ_JSDOWNLOADS) +fi + dnl ======================================================== dnl = Mac bundle name prefix dnl ======================================================== diff --git a/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html b/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html index 3ea3d8162db1..159a65064e50 100644 --- a/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html +++ b/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html @@ -46,8 +46,11 @@ var useJSTransfer = false; try { - useJSTransfer = prefs.getBoolPref("useJSTransfer"); - } catch (ex) { } + // This method throws an exception if the old Download Manager is disabled. + Services.downloads.activeDownloadCount; + } catch (ex) { + useJSTransfer = true; + } if (useJSTransfer) { var Downloads = SpecialPowers.Cu.import("resource://gre/modules/Downloads.jsm").Downloads; diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp index f835cfb0494f..7433c66cb207 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ b/toolkit/components/downloads/nsDownloadManager.cpp @@ -40,6 +40,7 @@ #ifdef XP_WIN #include +#include "nsWindowsHelpers.h" #ifdef DOWNLOAD_SCANNER #include "nsDownloadScanner.h" #endif @@ -937,7 +938,25 @@ nsDownloadManager::Init() getter_AddRefs(mBundle)); NS_ENSURE_SUCCESS(rv, rv); +#if defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN) + + // When MOZ_JSDOWNLOADS is defined on a non-Windows platform, this component + // is always disabled and we can safely omit the initialization code. + mUseJSTransfer = true; + +#else + +#if defined(MOZ_JSDOWNLOADS) && defined(XP_WIN) + // When MOZ_JSDOWNLOADS is defined on Windows, this component is disabled + // unless we are running in Windows Metro. The conversion of Windows Metro + // to use the JavaScript API for downloads is tracked in bug 906042. + mUseJSTransfer = !IsRunningInWindowsMetro(); +#else + // When MOZ_JSDOWNLOADS is undefined, we still check the preference that can + // be used to enable the JavaScript API during the migration process. mUseJSTransfer = Preferences::GetBool(PREF_BD_USEJSTRANSFER, false); +#endif + if (mUseJSTransfer) return NS_OK; @@ -1008,6 +1027,8 @@ nsDownloadManager::Init() if (history) (void)history->AddObserver(this, true); +#endif // defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN) + return NS_OK; } diff --git a/toolkit/components/downloads/test/moz.build b/toolkit/components/downloads/test/moz.build index 577ebbe372ae..4ac07e348c8a 100644 --- a/toolkit/components/downloads/test/moz.build +++ b/toolkit/components/downloads/test/moz.build @@ -4,8 +4,10 @@ # 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/. -TEST_DIRS += ['browser'] - MODULE = 'test_dm' -XPCSHELL_TESTS_MANIFESTS += ['schema_migration/xpcshell.ini', 'unit/xpcshell.ini'] +if not CONFIG['MOZ_JSDOWNLOADS']: + TEST_DIRS += ['browser'] + XPCSHELL_TESTS_MANIFESTS += ['schema_migration/xpcshell.ini'] + +XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] diff --git a/toolkit/components/downloads/test/unit/head_download_manager.js b/toolkit/components/downloads/test/unit/head_download_manager.js index 3729e25cf801..8ce96665b0ae 100644 --- a/toolkit/components/downloads/test/unit/head_download_manager.js +++ b/toolkit/components/downloads/test/unit/head_download_manager.js @@ -243,9 +243,10 @@ do_register_cleanup(function() { function oldDownloadManagerDisabled() { try { - if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) { - return true; - } - } catch (ex) { } + // This method throws an exception if the old Download Manager is disabled. + Services.downloads.activeDownloadCount; + } catch (ex) { + return true; + } return false; } \ No newline at end of file diff --git a/toolkit/forgetaboutsite/ForgetAboutSite.jsm b/toolkit/forgetaboutsite/ForgetAboutSite.jsm index f4e14e09e225..9555804bfea5 100644 --- a/toolkit/forgetaboutsite/ForgetAboutSite.jsm +++ b/toolkit/forgetaboutsite/ForgetAboutSite.jsm @@ -98,8 +98,11 @@ this.ForgetAboutSite = { // Downloads let useJSTransfer = false; try { - useJSTransfer = Services.prefs.getBoolPref("browser.download.useJSTransfer"); - } catch(ex) { } + // This method throws an exception if the old Download Manager is disabled. + Services.downloads.activeDownloadCount; + } catch (ex) { + useJSTransfer = true; + } if (useJSTransfer) { Task.spawn(function() { diff --git a/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js b/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js index b158e888ff1b..cb78f4cc75ea 100644 --- a/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js +++ b/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js @@ -30,3 +30,14 @@ function cleanUp() } } cleanUp(); + +function oldDownloadManagerDisabled() +{ + try { + // This method throws an exception if the old Download Manager is disabled. + Services.downloads.activeDownloadCount; + } catch (ex) { + return true; + } + return false; +} diff --git a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js index 26c2234e444f..a7553259375d 100644 --- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js @@ -445,6 +445,10 @@ function test_cookie_not_cleared_with_uri_contains_domain() // Download Manager function test_download_history_cleared_with_direct_match() { + if (oldDownloadManagerDisabled()) { + return; + } + const TEST_URI = "http://mozilla.org/foo"; add_download(TEST_URI, false); ForgetAboutSite.removeDataFromDomain("mozilla.org"); @@ -453,6 +457,10 @@ function test_download_history_cleared_with_direct_match() function test_download_history_cleared_with_subdomain() { + if (oldDownloadManagerDisabled()) { + return; + } + const TEST_URI = "http://www.mozilla.org/foo"; add_download(TEST_URI, false); ForgetAboutSite.removeDataFromDomain("mozilla.org"); @@ -461,6 +469,10 @@ function test_download_history_cleared_with_subdomain() function test_download_history_not_cleared_with_active_direct_match() { + if (oldDownloadManagerDisabled()) { + return; + } + // Tests that downloads marked as active in the db are not deleted from the db const TEST_URI = "http://mozilla.org/foo"; add_download(TEST_URI, true); diff --git a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js index 66639bce6e04..cae9bc7cf8d9 100644 --- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js @@ -82,6 +82,10 @@ function makeGUID() { function run_test() { + if (oldDownloadManagerDisabled()) { + return; + } + // We add this data to the database first, but we cannot instantiate the // download manager service, otherwise these downloads will not be placed in // the active downloads array. diff --git a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm index ba88879571f2..407a5a8dcc36 100644 --- a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm +++ b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm @@ -117,15 +117,6 @@ var DownloadTaskbarProgressUpdater = } this._initialized = true; - // Taskbar progress is disabled until this component is updated to use the - // asynchronous JavaScript API for downloads. - try { - if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) { - DownloadTaskbarProgressUpdater = null; - return; - } - } catch (ex) { } - if (kTaskbarIDWin in Cc) { this._taskbar = Cc[kTaskbarIDWin].getService(Ci.nsIWinTaskbar); if (!this._taskbar.available) { diff --git a/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul b/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul index 6f990987b67b..bff26034b13d 100644 --- a/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul +++ b/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul @@ -29,6 +29,12 @@ let DownloadTaskbarProgress, TaskbarService, observerService, wwatch, chromeWind let gGen = null; function test() { + var dmui = getDMUI(); + if (!dmui) { + todo(false, "skip test for toolkit download manager UI"); + return; + } + let isWin7OrHigher = false; try { let version = Cc["@mozilla.org/system-info;1"] diff --git a/toolkit/mozapps/downloads/tests/chrome/utils.js b/toolkit/mozapps/downloads/tests/chrome/utils.js index f56949e26b90..a2db011bde1e 100644 --- a/toolkit/mozapps/downloads/tests/chrome/utils.js +++ b/toolkit/mozapps/downloads/tests/chrome/utils.js @@ -23,10 +23,11 @@ Components.utils.import("resource://gre/modules/Services.jsm"); function getDMUI() { try { - if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) { - return false; - } - } catch (ex) { } + // This method throws an exception if the old Download Manager is disabled. + Services.downloads.activeDownloadCount; + } catch (ex) { + return false; + } if (Components.classesByID["{7dfdf0d1-aff6-4a34-bad1-d0fe74601642}"]) return Components.classesByID["{7dfdf0d1-aff6-4a34-bad1-d0fe74601642}"]. getService(Ci.nsIDownloadManagerUI); diff --git a/uriloader/exthandler/tests/moz.build b/uriloader/exthandler/tests/moz.build index 9e206f121fd8..56a67c08eb31 100644 --- a/uriloader/exthandler/tests/moz.build +++ b/uriloader/exthandler/tests/moz.build @@ -14,7 +14,10 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] #FIXME/bug 575918: out-of-process xpcshell is broken on OS X if CONFIG['OS_ARCH'] != 'Darwin': - XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini'] + # The encoding test is already implemented in the Downloads API by a set of + # test cases with the string "content_encoding" in their names. + if not CONFIG['MOZ_JSDOWNLOADS']: + XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini'] sources = [ 'WriteArgument', From fdab1bd8483fcacfaafca657f4d8d6d15e4d2751 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Wed, 23 Oct 2013 13:19:58 -0700 Subject: [PATCH 22/23] Backed out changeset 69ebfb936442 (bug 862849) for bc orange on a CLOSED TREE. --HG-- extra : amend_source : 0fbcba6a47f79369df9628f3ca1aa2ebf02a6efa --- browser/devtools/debugger/CmdDebugger.jsm | 4 ++-- browser/devtools/debugger/debugger-panes.js | 22 ++++++++--------- browser/devtools/debugger/debugger-toolbar.js | 2 +- .../browser_dbg_breakpoints-contextmenu.js | 24 +++++++++---------- .../devtools/netmonitor/netmonitor-view.js | 4 ++-- .../test/browser_scratchpad_inspect.js | 6 ++--- .../devtools/shared/widgets/VariablesView.jsm | 16 ++++++------- .../devtools/shared/widgets/ViewHelpers.jsm | 12 +++++----- browser/devtools/webconsole/test/head.js | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/browser/devtools/debugger/CmdDebugger.jsm b/browser/devtools/debugger/CmdDebugger.jsm index 59231e23eebf..3f910d7dce87 100644 --- a/browser/devtools/debugger/CmdDebugger.jsm +++ b/browser/devtools/debugger/CmdDebugger.jsm @@ -37,8 +37,8 @@ function getAllBreakpoints(dbg) { let sources = dbg._view.Sources; let { trimUrlLength: trim } = dbg.panelWin.SourceUtils; - for (let source of sources) { - for (let { attachment: breakpoint } of source) { + for (let source in sources) { + for (let { attachment: breakpoint } in source) { breakpoints.push({ url: source.value, label: source.label + ":" + breakpoint.line, diff --git a/browser/devtools/debugger/debugger-panes.js b/browser/devtools/debugger/debugger-panes.js index 31a555f7ddcd..96a2df05a96f 100644 --- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -232,8 +232,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { * The corresponding breakpoints if found, an empty array otherwise. */ getOtherBreakpoints: function(aLocation = {}, aStore = []) { - for (let source of this) { - for (let breakpointItem of source) { + for (let source in this) { + for (let breakpointItem in source) { let { url, line } = breakpointItem.attachment; if (url != aLocation.url || line != aLocation.line) { aStore.push(breakpointItem); @@ -1369,7 +1369,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, { */ switchExpression: function(aVar, aExpression) { let expressionItem = - [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0]; + [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression if it's going to be empty or a duplicate. if (!aExpression || this.getAllStrings().indexOf(aExpression) != -1) { @@ -1395,7 +1395,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, { */ deleteExpression: function(aVar) { let expressionItem = - [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0]; + [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0]; // Remove the watch expression. this.remove(expressionItem); @@ -2027,7 +2027,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, { _createGlobalResultsUI: function(aGlobalResults) { let i = 0; - for (let sourceResults of aGlobalResults) { + for (let sourceResults in aGlobalResults) { if (i++ == 0) { this._createSourceResultsUI(sourceResults); } else { @@ -2152,7 +2152,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, { /** * An object containing all source results, grouped by source location. - * Iterable via "for (let [location, sourceResults] of globalResults) { }". + * Iterable via "for (let [location, sourceResults] in globalResults) { }". */ function GlobalResults() { this._store = []; @@ -2179,7 +2179,7 @@ GlobalResults.prototype = { /** * An object containing all the matched lines for a specific source. - * Iterable via "for (let [lineNumber, lineResults] of sourceResults) { }". + * Iterable via "for (let [lineNumber, lineResults] in sourceResults) { }". * * @param string aUrl * The target source url. @@ -2320,7 +2320,7 @@ SourceResults.prototype = { /** * An object containing all the matches for a specific line. - * Iterable via "for (let chunk of lineResults) { }". + * Iterable via "for (let chunk in lineResults) { }". * * @param number aLine * The target line in the source. @@ -2465,9 +2465,9 @@ LineResults.prototype = { /** * A generator-iterator over the global, source or line results. */ -GlobalResults.prototype.iterator = -SourceResults.prototype.iterator = -LineResults.prototype.iterator = function() { +GlobalResults.prototype.__iterator__ = +SourceResults.prototype.__iterator__ = +LineResults.prototype.__iterator__ = function() { for (let item of this._store) { yield item; } diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 4ce4f7620325..00416ad16891 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -615,7 +615,7 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, { // Update the context menu to show the currently selected stackframe item // as a checked entry. - for (let otherItem of this) { + for (let otherItem in this) { if (otherItem != stackframeItem) { otherItem.attachment.popup.menuitem.removeAttribute("checked"); } else { diff --git a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js index 1212e4fe85cb..838c45e2794e 100644 --- a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js @@ -107,8 +107,8 @@ function test() { } function initialChecks() { - for (let source of gSources) { - for (let breakpoint of source) { + for (let source in gSources) { + for (let breakpoint in source) { ok(gBreakpoints._getAdded(breakpoint.attachment), "All breakpoint items should have corresponding promises (1)."); ok(!gBreakpoints._getRemoving(breakpoint.attachment), @@ -223,8 +223,8 @@ function test() { is(!!selectedBreakpoint.attachment.disabled, false, "The targetted breakpoint should not have been disabled (" + aIndex + ")."); - for (let source of gSources) { - for (let otherBreakpoint of source) { + for (let source in gSources) { + for (let otherBreakpoint in source) { if (otherBreakpoint != selectedBreakpoint) { ok(!gBreakpoints._getAdded(otherBreakpoint.attachment), "There should be no breakpoint client for a disabled breakpoint (9)."); @@ -235,8 +235,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 4).then(() => { - for (let source of gSources) { - for (let someBreakpoint of source) { + for (let source in gSources) { + for (let someBreakpoint in source) { ok(gBreakpoints._getAdded(someBreakpoint.attachment), "There should be a breakpoint client for all enabled breakpoints (11)."); is(someBreakpoint.attachment.disabled, false, @@ -245,8 +245,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => { - for (let source of gSources) { - for (let someBreakpoint of source) { + for (let source in gSources) { + for (let someBreakpoint in source) { ok(!gBreakpoints._getAdded(someBreakpoint.attachment), "There should be no breakpoint client for a disabled breakpoint (13)."); is(someBreakpoint.attachment.disabled, true, @@ -255,8 +255,8 @@ function test() { } waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 5).then(() => { - for (let source of gSources) { - for (let someBreakpoint of source) { + for (let source in gSources) { + for (let someBreakpoint in source) { ok(gBreakpoints._getAdded(someBreakpoint.attachment), "There should be a breakpoint client for all enabled breakpoints (15)."); is(someBreakpoint.attachment.disabled, false, @@ -293,8 +293,8 @@ function test() { ok(!gSources._selectedBreakpointItem, "There should be no breakpoint available after removing all breakpoints."); - for (let source of gSources) { - for (let otherBreakpoint of source) { + for (let source in gSources) { + for (let otherBreakpoint in source) { ok(false, "It's a trap!"); } } diff --git a/browser/devtools/netmonitor/netmonitor-view.js b/browser/devtools/netmonitor/netmonitor-view.js index 1732d2348857..e139e201e6ab 100644 --- a/browser/devtools/netmonitor/netmonitor-view.js +++ b/browser/devtools/netmonitor/netmonitor-view.js @@ -1007,7 +1007,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { // Apply CSS transforms to each waterfall in this container totalTime // accurately translate and resize as needed. - for (let { target, attachment } of this) { + for (let { target, attachment } in this) { let timingsNode = $(".requests-menu-timings", target); let startCapNode = $(".requests-menu-timings-cap.start", target); let endCapNode = $(".requests-menu-timings-cap.end", target); @@ -1143,7 +1143,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, { * Reapplies the current waterfall background on all request items. */ _flushWaterfallBackgrounds: function() { - for (let { target } of this) { + for (let { target } in this) { let waterfallNode = $(".requests-menu-waterfall", target); waterfallNode.style.backgroundImage = this._cachedWaterfallBackground; } diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js index 1f1b5651757e..b4e81a9916c4 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js @@ -28,9 +28,9 @@ function runTests() let found = false; - outer: for (let scope of sidebar.variablesView) { - for (let [, obj] of scope) { - for (let [, prop] of obj) { + outer: for (let scope in sidebar.variablesView) { + for (let [, obj] in scope) { + for (let [, prop] in obj) { if (prop.name == "a" && prop.value == "foobarBug636725") { found = true; break outer; diff --git a/browser/devtools/shared/widgets/VariablesView.jsm b/browser/devtools/shared/widgets/VariablesView.jsm index 8ace2f7538ba..68d44ba3d438 100644 --- a/browser/devtools/shared/widgets/VariablesView.jsm +++ b/browser/devtools/shared/widgets/VariablesView.jsm @@ -55,7 +55,7 @@ const STR = Services.strings.createBundle(DBG_STRINGS_URI); /** * A tree view for inspecting scopes, objects and properties. - * Iterable via "for (let [id, scope] of instance) { }". + * Iterable via "for (let [id, scope] in instance) { }". * Requires the devtools common.css and debugger.css skin stylesheets. * * To allow replacing variable or property values in this view, provide an @@ -1092,7 +1092,7 @@ VariablesView.getterOrSetterDeleteCallback = function(aItem) { /** * A Scope is an object holding Variable instances. - * Iterable via "for (let [name, variable] of instance) { }". + * Iterable via "for (let [name, variable] in instance) { }". * * @param VariablesView aView * The view to contain this scope. @@ -2042,7 +2042,7 @@ DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_batchItems", Array); /** * A Variable is a Scope holding Property instances. - * Iterable via "for (let [name, property] of instance) { }". + * Iterable via "for (let [name, property] in instance) { }". * * @param Scope aScope * The scope to contain this variable. @@ -2826,7 +2826,7 @@ Variable.prototype = Heritage.extend(Scope.prototype, { /** * A Property is a Variable holding additional child Property instances. - * Iterable via "for (let [name, property] of instance) { }". + * Iterable via "for (let [name, property] in instance) { }". * * @param Variable aVar * The variable to contain this property. @@ -2887,10 +2887,10 @@ Property.prototype = Heritage.extend(Variable.prototype, { /** * A generator-iterator over the VariablesView, Scopes, Variables and Properties. */ -VariablesView.prototype.iterator = -Scope.prototype.iterator = -Variable.prototype.iterator = -Property.prototype.iterator = function() { +VariablesView.prototype.__iterator__ = +Scope.prototype.__iterator__ = +Variable.prototype.__iterator__ = +Property.prototype.__iterator__ = function() { for (let item of this._store) { yield item; } diff --git a/browser/devtools/shared/widgets/ViewHelpers.jsm b/browser/devtools/shared/widgets/ViewHelpers.jsm index 1fd478e5d112..44aa32485d52 100644 --- a/browser/devtools/shared/widgets/ViewHelpers.jsm +++ b/browser/devtools/shared/widgets/ViewHelpers.jsm @@ -405,7 +405,7 @@ ViewHelpers.Prefs.prototype = { /** * A generic Item is used to describe children present in a Widget. * The label, value and description properties are necessarily strings. - * Iterable via "for (let childItem of parentItem) { }". + * Iterable via "for (let childItem in parentItem) { }". * * @param object aOwnerView * The owner view creating this item. @@ -513,7 +513,7 @@ Item.prototype = { if (aItem.finalize) { aItem.finalize(aItem); } - for (let childItem of aItem) { + for (let childItem in aItem) { aItem.remove(childItem); } @@ -557,7 +557,7 @@ Item.prototype = { /** * Some generic Widget methods handling Item instances. - * Iterable via "for (let childItem of wrappedView) { }". + * Iterable via "for (let childItem in wrappedView) { }". * * Usage: * function MyView() { @@ -1517,7 +1517,7 @@ this.WidgetMethods = { if (aItem.finalize) { aItem.finalize(aItem); } - for (let childItem of aItem) { + for (let childItem in aItem) { aItem.remove(childItem); } @@ -1642,8 +1642,8 @@ this.WidgetMethods = { /** * A generator-iterator over all the items in this container. */ -Item.prototype.iterator = -WidgetMethods.iterator = function() { +Item.prototype.__iterator__ = +WidgetMethods.__iterator__ = function() { for (let [, item] of this._itemsByElement) { yield item; } diff --git a/browser/devtools/webconsole/test/head.js b/browser/devtools/webconsole/test/head.js index 43fd4dcdd860..526d8a3c02df 100644 --- a/browser/devtools/webconsole/test/head.js +++ b/browser/devtools/webconsole/test/head.js @@ -447,7 +447,7 @@ function findVariableViewProperties(aView, aRules, aOptions) function finder(aRules, aVar, aPromises) { - for (let [id, prop] of aVar) { + for (let [id, prop] in aVar) { for (let rule of aRules) { let matcher = matchVariablesViewProperty(prop, rule, aOptions); aPromises.push(matcher.then(onMatch.bind(null, prop, rule))); From 9e21571433bb9e4baf434d794b3967fc70f80556 Mon Sep 17 00:00:00 2001 From: Anton Kovalyov Date: Wed, 23 Oct 2013 14:57:13 -0700 Subject: [PATCH 23/23] Bug 919706 - Localize search UI. r=robcee --- browser/devtools/sourceeditor/codemirror/README | 5 +++-- .../devtools/sourceeditor/codemirror/search/search.js | 10 +++++++--- browser/devtools/sourceeditor/editor.js | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/browser/devtools/sourceeditor/codemirror/README b/browser/devtools/sourceeditor/codemirror/README index cd0efe13bbce..f7828c5a7875 100644 --- a/browser/devtools/sourceeditor/codemirror/README +++ b/browser/devtools/sourceeditor/codemirror/README @@ -18,8 +18,9 @@ To confirm the functionality run mochitests for the following components: The sourceeditor component contains imported CodeMirror tests [3]. Some tests were commented out because we don't use that functionality within -Firefox (for example Ruby editing mode). Other than that, we don't have -any Mozilla-specific patches applied to CodeMirror itself. +Firefox (for example Ruby editing mode). The search addon (search.js) +was slightly modified to make search UI localizable. Other than that, +we don't have any Mozilla-specific patches applied to CodeMirror itself. # Addons diff --git a/browser/devtools/sourceeditor/codemirror/search/search.js b/browser/devtools/sourceeditor/codemirror/search/search.js index c30922df4f0b..9bfbe7ef3728 100644 --- a/browser/devtools/sourceeditor/codemirror/search/search.js +++ b/browser/devtools/sourceeditor/codemirror/search/search.js @@ -45,12 +45,16 @@ var isRE = query.match(/^\/(.*)\/([a-z]*)$/); return isRE ? new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i") : query; } - var queryDialog = - 'Search: (Use /re/ syntax for regexp search)'; + var queryDialog; function doSearch(cm, rev) { + if (!queryDialog) { + queryDialog = cm.l10n('findCmd.promptMessage') + + ' '; + } + var state = getSearchState(cm); if (state.query) return findNext(cm, rev); - dialog(cm, queryDialog, "Search for:", function(query) { + dialog(cm, queryDialog, cm.l10n('findCmd.promptMessage'), function(query) { cm.operation(function() { if (!query || state.query) return; state.query = parseQuery(query); diff --git a/browser/devtools/sourceeditor/editor.js b/browser/devtools/sourceeditor/editor.js index ecf1ff52fa02..544851a75fb0 100644 --- a/browser/devtools/sourceeditor/editor.js +++ b/browser/devtools/sourceeditor/editor.js @@ -207,6 +207,10 @@ Editor.prototype = { cm.on("gutterClick", (cm, line) => this.emit("gutterClick", line)); cm.on("cursorActivity", (cm) => this.emit("cursorActivity")); + win.CodeMirror.defineExtension("l10n", (name) => { + return L10N.GetStringFromName(name); + }); + doc.defaultView.controllers.insertControllerAt(0, controller(this, doc.defaultView)); this.container = env;