bug 654312 - include urls of remote pages in content crash reports r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Tue, 03 May 2011 10:35:20 -0400
changeset 68901 6a3209b9d1fee02621433c49dbc26fde7c425fdf
parent 68900 83b30b8ad22c3a2aad1fb93766c6175e4de8548c
child 68902 0a0081de66e32f5ae6e3fc9da5db16d58af1953c
push id19792
push userblassey@mozilla.com
push dateTue, 03 May 2011 14:36:15 +0000
treeherdermozilla-central@6a3209b9d1fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs654312
milestone6.0a1
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
bug 654312 - include urls of remote pages in content crash reports r=mfinkle
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2411,20 +2411,21 @@ var ContentCrashObserver = {
     }
 
     let hideUI = env.get("MOZ_CRASHREPORTER_NO_REPORT");
     if (hideUI)
       return;
 
     // Spin through the open tabs and resurrect the out-of-process tabs. Resurrection
     // does not auto-reload the content. We delay load the content as needed.
+    let URLs = []
     Browser.tabs.forEach(function(aTab) {
       if (aTab.browser.getAttribute("remote") == "true")
-        aTab.resurrect();
-    })
+        URLs.push(aTab.resurrect().data.entries[0].url);
+    });
 
     let dumpID = aSubject.hasKey("dumpID") ? aSubject.getProperty("dumpID") : null;
 
     // Execute the UI prompt after the notification has had a chance to return and close the child process
     setTimeout(function(self) {
       // Ask the user if we should reload or close the current tab. Other tabs
       // will be reloaded when selected.
       let title = Strings.browser.GetStringFromName("tabs.crashWarningTitle");
@@ -2458,18 +2459,34 @@ var ContentCrashObserver = {
         }
 
         // Close this tab, it could be the reason we crashed. The undo-close-tab
         // system will pick it up.
         Browser.closeTab(Browser.selectedTab, { forceClose: true });
       }
 
       // Submit the report, if we have one and the user wants to submit it
-      if (submit.value && dumpID)
+      if (submit.value && dumpID) {
+        let directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
+        let extra = directoryService.get("UAppData", Ci.nsIFile);
+        extra.append("Crash Reports");
+        extra.append("pending");
+        extra.append(dumpID + ".extra");
+        let foStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
+        try {
+          // use 0x02 | 0x10 to open file for appending.
+          foStream.init(extra, 0x02 |  0x10, 0666, 0); 
+          let data = "URL=" + URLs.join(" ") + "\n";
+          foStream.write(data, data.length);
+          foStream.close();
+        } catch (x) {
+          dump (x);
+        }
         self.CrashSubmit.submit(dumpID, Elements.stack, null, null);
+      }
     }, 0, this);
   }
 };
 
 var MemoryObserver = {
   observe: function mo_observe(aSubject, aTopic, aData) {
     if (aData == "heap-minimize") {
       // do non-destructive stuff here.
@@ -2736,16 +2753,18 @@ Tab.prototype = {
     let browser = this._createBrowser(currentURL, sibling);
     if (active)
       this.active = true;
 
     // Reattach session store data and flag this browser so it is restored on select
     browser.__SS_data = session.data;
     browser.__SS_extdata = session.extra;
     browser.__SS_restore = true;
+
+    return session;
   },
 
   _createBrowser: function _createBrowser(aURI, aInsertBefore) {
     if (this._browser)
       throw "Browser already exists";
 
     // Create a notification box around the browser
     let notification = this._notification = document.createElement("notificationbox");