Backout 2a6310e0ed9a (bug 781186) and 64bc6b0e9127 (bug 773732) for causing bug 780198 and bug 782179
☠☠ backed out by 618652af63c9 ☠ ☠
authorEd Morley <emorley@mozilla.com>
Wed, 15 Aug 2012 13:30:09 +0100
changeset 102322 3b46b03dff5c999ab08a1258ac1fad9f0790ed34
parent 102321 1340cabb01d1e65977faa717a6a797cbc7a68c4a
child 102338 a0bddf5fcb910de63170f62868f567fe86995e00
push id23278
push useremorley@mozilla.com
push dateWed, 15 Aug 2012 12:30:27 +0000
treeherdermozilla-central@3b46b03dff5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs781186, 773732, 780198, 782179
milestone17.0a1
backs out2a6310e0ed9adacdfba048a0a08b25a732d8f71c
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 2a6310e0ed9a (bug 781186) and 64bc6b0e9127 (bug 773732) for causing bug 780198 and bug 782179
browser/devtools/debugger/debugger-controller.js
browser/devtools/debugger/debugger-view.js
browser/devtools/debugger/test/Makefile.in
browser/devtools/debugger/test/browser_dbg_location-changes-new.js
browser/devtools/debugger/test/browser_dbg_reload-same-script.js
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -904,21 +904,16 @@ SourceScripts.prototype = {
   _onNewScript: function SS__onNewScript(aNotification, aPacket) {
     // Ignore scripts generated from 'clientEvaluate' packets.
     if (aPacket.url == "debugger eval code") {
       return;
     }
 
     this._addScript({ url: aPacket.url, startLine: aPacket.startLine }, true);
 
-    // Select the script if it's the preferred one.
-    if (aPacket.url === DebuggerView.Scripts.preferredScriptUrl) {
-      DebuggerView.Scripts.selectScript(aPacket.url);
-    }
-
     // If there are any stored breakpoints for this script, display them again,
     // both in the editor and the pane.
     for each (let breakpoint in DebuggerController.Breakpoints.store) {
       if (breakpoint.location.url == aPacket.url) {
         DebuggerController.Breakpoints.displayBreakpoint(breakpoint);
       }
     }
   },
@@ -927,24 +922,16 @@ SourceScripts.prototype = {
    * Handler for the thread client's scriptsadded notification.
    */
   _onScriptsAdded: function SS__onScriptsAdded() {
     for each (let script in this.activeThread.cachedScripts) {
       this._addScript(script, false);
     }
     DebuggerView.Scripts.commitScripts();
     DebuggerController.Breakpoints.updatePaneBreakpoints();
-
-    // Select the preferred script if one exists, the first entry otherwise.
-    let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl;
-    if (preferredScriptUrl && DebuggerView.Scripts.contains(preferredScriptUrl)) {
-      DebuggerView.Scripts.selectScript(preferredScriptUrl);
-    } else {
-      DebuggerView.Scripts.selectIndex(0);
-    }
   },
 
   /**
    * Handler for the thread client's scriptscleared notification.
    */
   _onScriptsCleared: function SS__onScriptsCleared() {
     DebuggerView.Scripts.empty();
     DebuggerView.Breakpoints.emptyText();
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -241,26 +241,16 @@ ScriptsView.prototype = {
     }
     if (this._scripts.getElementsByAttribute("label", aLabel).length > 0) {
       return true;
     }
     return false;
   },
 
   /**
-   * Selects the script with the specified index from the list.
-   *
-   * @param number aIndex
-   *        The script index.
-   */
-  selectIndex: function DVS_selectIndex(aIndex) {
-    this._scripts.selectedIndex = aIndex;
-  },
-
-  /**
    * Selects the script with the specified URL from the list.
    *
    * @param string aUrl
    *        The script URL.
    */
   selectScript: function DVS_selectScript(aUrl) {
     for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
       if (this._scripts.getItemAtIndex(i).value == aUrl) {
@@ -289,23 +279,16 @@ ScriptsView.prototype = {
    * @return string | null
    */
   get selected() {
     return this._scripts.selectedItem ?
            this._scripts.selectedItem.value : null;
   },
 
   /**
-   * Gets the most recently selected script url.
-   * @return string | null
-   */
-  get preferredScriptUrl()
-    this._preferredScriptUrl ? this._preferredScriptUrl : null,
-
-  /**
    * Returns the list of labels in the scripts container.
    * @return array
    */
   get scriptLabels() {
     let labels = [];
     for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
       labels.push(this._scripts.getItemAtIndex(i).label);
     }
@@ -363,17 +346,17 @@ ScriptsView.prototype = {
     // Find the target position in the menulist and insert the script there.
     for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
       if (this._scripts.getItemAtIndex(i).label > aLabel) {
         this._createScriptElement(aLabel, aScript, i);
         return;
       }
     }
     // The script is alphabetically the last one.
-    this._createScriptElement(aLabel, aScript, -1);
+    this._createScriptElement(aLabel, aScript, -1, true);
   },
 
   /**
    * Adds all the prepared scripts to the scripts container.
    * If a script already exists (was previously added), nothing happens.
    */
   commitScripts: function DVS_commitScripts() {
     let newScripts = this._tmpScripts;
@@ -383,45 +366,53 @@ ScriptsView.prototype = {
       return;
     }
     newScripts.sort(function(a, b) {
       return a.label.toLowerCase() > b.label.toLowerCase();
     });
 
     for (let i = 0, l = newScripts.length; i < l; i++) {
       let item = newScripts[i];
-      this._createScriptElement(item.label, item.script, -1);
+      this._createScriptElement(item.label, item.script, -1, true);
     }
   },
 
   /**
    * Creates a custom script element and adds it to the scripts container.
    * If the script with the specified label already exists, nothing happens.
    *
    * @param string aLabel
    *        The simplified script location to be shown.
    * @param string aScript
    *        The source script.
    * @param number aIndex
    *        The index where to insert to new script in the container.
    *        Pass -1 to append the script at the end.
+   * @param boolean aSelectIfEmptyFlag
+   *        True to set the newly created script as the currently selected item
+   *        if there are no other existing scripts in the container.
    */
-  _createScriptElement: function DVS__createScriptElement(aLabel, aScript, aIndex)
+  _createScriptElement: function DVS__createScriptElement(
+    aLabel, aScript, aIndex, aSelectIfEmptyFlag)
   {
     // Make sure we don't duplicate anything.
     if (aLabel == "null" || this.containsLabel(aLabel) || this.contains(aScript.url)) {
       return;
     }
 
     let scriptItem =
       aIndex == -1 ? this._scripts.appendItem(aLabel, aScript.url)
                    : this._scripts.insertItemAt(aIndex, aLabel, aScript.url);
 
     scriptItem.setAttribute("tooltiptext", aScript.url);
     scriptItem.setUserData("sourceScript", aScript, null);
+
+    if (this._scripts.itemCount == 1 && aSelectIfEmptyFlag) {
+      this._scripts.selectedItem = scriptItem;
+    }
   },
 
   /**
    * Gets the entered file, line and token entered in the searchbox.
    *
    * @return array
    *         A [file, line, token] array.
    */
@@ -447,17 +438,16 @@ ScriptsView.prototype = {
    */
   _onScriptsChange: function DVS__onScriptsChange() {
     let selectedItem = this._scripts.selectedItem;
     if (!selectedItem) {
       return;
     }
 
     this._preferredScript = selectedItem;
-    this._preferredScriptUrl = selectedItem.value;
     this._scripts.setAttribute("tooltiptext", selectedItem.value);
     DebuggerController.SourceScripts.showScript(selectedItem.getUserData("sourceScript"));
   },
 
   /**
    * The search listener for the scripts search box.
    */
   _onScriptsSearch: function DVS__onScriptsSearch(e) {
--- a/browser/devtools/debugger/test/Makefile.in
+++ b/browser/devtools/debugger/test/Makefile.in
@@ -30,26 +30,24 @@ MOCHITEST_BROWSER_TESTS = \
 	browser_dbg_propertyview-04.js \
 	browser_dbg_propertyview-05.js \
 	browser_dbg_propertyview-06.js \
 	browser_dbg_propertyview-07.js \
 	browser_dbg_propertyview-08.js \
 	browser_dbg_propertyview-09.js \
 	browser_dbg_propertyview-10.js \
 	browser_dbg_propertyview-edit.js \
-	browser_dbg_reload-same-script.js \
 	browser_dbg_panesize.js \
 	browser_dbg_panesize-inner.js \
 	browser_dbg_stack-01.js \
 	browser_dbg_stack-02.js \
 	browser_dbg_stack-03.js \
 	browser_dbg_stack-04.js \
 	browser_dbg_stack-05.js \
 	browser_dbg_location-changes.js \
-	browser_dbg_location-changes-new.js \
 	browser_dbg_location-changes-blank.js \
 	browser_dbg_script-switching.js \
 	browser_dbg_scripts-sorting.js \
 	browser_dbg_scripts-searching-01.js \
 	browser_dbg_scripts-searching-02.js \
 	browser_dbg_pause-resume.js \
 	browser_dbg_update-editor-mode.js \
 	$(warning browser_dbg_select-line.js temporarily disabled due to oranges, see bug 726609) \
deleted file mode 100644
--- a/browser/devtools/debugger/test/browser_dbg_location-changes-new.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/**
- * Make sure that changing the tab location URL to a page with other scripts works.
- */
-
-var gPane = null;
-var gTab = null;
-var gDebuggee = null;
-var gDebugger = null;
-
-function test()
-{
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.contentWindow;
-
-    testSimpleCall();
-  });
-}
-
-function testSimpleCall() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-    Services.tm.currentThread.dispatch({
-      run: function() {
-        var frames = gDebugger.DebuggerView.StackFrames._frames,
-            childNodes = frames.childNodes;
-
-        is(gDebugger.DebuggerController.activeThread.state, "paused",
-          "Should only be getting stack frames while paused.");
-
-        is(frames.querySelectorAll(".dbg-stackframe").length, 1,
-          "Should have only one frame.");
-
-        is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
-          "All children should be frames.");
-
-        isnot(gDebugger.DebuggerView.Scripts.selected, null,
-          "There should be a selected script.");
-        isnot(gDebugger.editor.getText().length, 0,
-          "The source editor should have some text displayed.");
-
-        testLocationChange();
-      }
-    }, 0);
-  });
-
-  gDebuggee.simpleCall();
-}
-
-function testLocationChange()
-{
-  gDebugger.DebuggerController.activeThread.resume(function() {
-    gDebugger.DebuggerController.client.addOneTimeListener("tabNavigated", function(aEvent, aPacket) {
-      ok(true, "tabNavigated event was fired.");
-      gDebugger.DebuggerController.client.addOneTimeListener("tabAttached", function(aEvent, aPacket) {
-        ok(true, "Successfully reattached to the tab again.");
-
-        // Wait for the initial resume...
-        gDebugger.gClient.addOneTimeListener("resumed", function() {
-          isnot(gDebugger.DebuggerView.Scripts.selected, null,
-            "There should be a selected script.");
-          isnot(gDebugger.editor.getText().length, 0,
-            "The source editor should have some text displayed.");
-
-          let menulist = gDebugger.DebuggerView.Scripts._scripts;
-          let noScripts = gDebugger.L10N.getStr("noScriptsText");
-          isnot(menulist.getAttribute("label"), noScripts,
-            "The menulist should not display a notice that there are no scripts availalble.");
-          isnot(menulist.getAttribute("tooltiptext"), "",
-            "The menulist should have a tooltip text attributed.");
-
-          closeDebuggerAndFinish();
-        });
-      });
-    });
-    content.location = EXAMPLE_URL + "browser_dbg_iframes.html";
-  });
-}
-
-registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
-  gTab = null;
-  gDebuggee = null;
-  gDebugger = null;
-});
deleted file mode 100644
--- a/browser/devtools/debugger/test/browser_dbg_reload-same-script.js
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/**
- * Tests if the same script is shown after a page is reloaded.
- */
-
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
-let gView = null;
-
-function test()
-{
-  let step = 0;
-  let scriptShown = false;
-  let scriptShownUrl = null;
-  let resumed = false;
-  let testStarted = false;
-
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.contentWindow;
-    gView = gDebugger.DebuggerView;
-    resumed = true;
-
-    executeSoon(startTest);
-  });
-
-  function onScriptShown(aEvent)
-  {
-    scriptShown = aEvent.detail.url.indexOf("-01.js") != -1;
-    scriptShownUrl = aEvent.detail.url;
-    executeSoon(startTest);
-  }
-
-  function onUlteriorScriptShown(aEvent)
-  {
-    scriptShownUrl = aEvent.detail.url;
-    executeSoon(testScriptShown);
-  }
-
-  window.addEventListener("Debugger:ScriptShown", onScriptShown);
-
-  function startTest()
-  {
-    if (scriptShown && resumed && !testStarted) {
-      window.removeEventListener("Debugger:ScriptShown", onScriptShown);
-      window.addEventListener("Debugger:ScriptShown", onUlteriorScriptShown);
-      testStarted = true;
-      Services.tm.currentThread.dispatch({ run: performTest }, 0);
-    }
-  }
-
-  function finishTest()
-  {
-    if (scriptShown && resumed && testStarted) {
-      window.removeEventListener("Debugger:ScriptShown", onUlteriorScriptShown);
-      closeDebuggerAndFinish();
-    }
-  }
-
-  function performTest()
-  {
-    testCurrentScript("-01.js", step);
-    step = 1;
-    reloadPage();
-  }
-
-  function testScriptShown()
-  {
-    if (step === 1) {
-      testCurrentScript("-01.js", step);
-      step = 2;
-      reloadPage();
-    }
-    else if (step === 2) {
-      testCurrentScript("-01.js", step);
-      step = 3;
-      gView.Scripts.selectScript(gView.Scripts.scriptLocations[1]);
-    }
-    else if (step === 3) {
-      testCurrentScript("-02.js", step);
-      step = 4;
-      reloadPage();
-    }
-    else if (step === 4) {
-      testCurrentScript("-02.js", step);
-      finishTest();
-    }
-  }
-
-  function testCurrentScript(part, step)
-  {
-    info("Currently preferred script: " + gView.Scripts.preferredScriptUrl);
-    info("Currently selected script: " + gView.Scripts.selected);
-
-    isnot(gView.Scripts.preferredScriptUrl.indexOf(part), -1,
-      "The preferred script url wasn't set correctly. (" + step + ")");
-    isnot(gView.Scripts.selected.indexOf(part), -1,
-      "The selected script isn't the correct one. (" + step + ")");
-    is(gView.Scripts.selected, scriptShownUrl,
-      "The shown script is not the the correct one. (" + step + ")");
-  }
-
-  function reloadPage()
-  {
-    executeSoon(function() {
-      gDebuggee.location.reload();
-    });
-  }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-    gView = null;
-  });
-}