Bug 782877 - Intermittent browser_dbg_bfcache.js | uncaught JS exception - TypeError: element is undefined at debugger-controller.js:1275, r=rcampbell
authorVictor Porof <vporof@mozilla.com>
Mon, 01 Oct 2012 18:15:20 +0300
changeset 108912 a2214e8900c0820dbc66ff0bc7903a415e2101f8
parent 108911 0c8442db91feccee0add2a0173ef66c0e2ea47e2
child 108913 1ef6d7852465abc53a35d30c25e5072653423dec
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersrcampbell
bugs782877
milestone18.0a1
Bug 782877 - Intermittent browser_dbg_bfcache.js | uncaught JS exception - TypeError: element is undefined at debugger-controller.js:1275, r=rcampbell
browser/devtools/debugger/debugger-controller.js
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -1348,16 +1348,26 @@ SourceScripts.prototype = {
    *        The content type of the source script.
    * @param object aOptions [optional]
    *        Additional options for showing the script. Supported options:
    *        - targetLine: place the editor at the given line number.
    */
   _onLoadSourceFinished:
   function SS__onLoadSourceFinished(aScriptUrl, aSourceText, aContentType, aOptions) {
     let element = DebuggerView.Scripts.getScriptByLocation(aScriptUrl);
+
+    // Tab navigated before we got a chance to finish loading and displaying
+    // the source. The outcome is that the expected url is not present anymore
+    // in the scripts container, hence the original script object coming from
+    // the active thread no longer exists. There's really nothing that needs
+    // to be done in this case, nor something that can be currently avoided.
+    if (!element) {
+      return;
+    }
+
     let script = element.getUserData("sourceScript");
 
     script.loaded = true;
     script.text = aSourceText;
     script.contentType = aContentType;
     element.setUserData("sourceScript", script, null);
 
     if (aOptions.silent) {