Bug 866342 - Use try/catch around weakref.get(), r=mdas
authorJonathan Griffin <jgriffin@mozilla.com>
Tue, 30 Apr 2013 11:22:03 -0700
changeset 141313 9828d3c19f477d9353b279d029374a6bc49e9873
parent 141312 7ea794cb249ff2fa7e9d476bb4188a4c548c1c08
child 141314 79220f9494068ea8438eb548707138047f05ae7e
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas
bugs866342
milestone23.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 866342 - Use try/catch around weakref.get(), r=mdas
testing/marionette/marionette-elements.js
--- a/testing/marionette/marionette-elements.js
+++ b/testing/marionette/marionette-elements.js
@@ -66,17 +66,21 @@ ElementManager.prototype = {
   * @param nsIDOMElement element
   *        The element to add
   *
   * @return string
   *        Returns the server-assigned reference ID
   */
   addToKnownElements: function EM_addToKnownElements(element) {
     for (let i in this.seenItems) {
-      let foundEl = this.seenItems[i].get();
+      let foundEl = null;
+      try {
+        foundEl = this.seenItems[i].get();
+      }
+      catch(e) {}
       if (foundEl) {
         if (XPCNativeWrapper(foundEl) == XPCNativeWrapper(element)) {
           return i;
         }
       }
       else {
         //cleanup reference to GC'd element
         delete this.seenItems[i];
@@ -98,17 +102,23 @@ ElementManager.prototype = {
    * @returns nsIDOMElement
    *        Returns the element or throws Exception if not found
    */
   getKnownElement: function EM_getKnownElement(id, win) {
     let el = this.seenItems[id];
     if (!el) {
       throw new ElementException("Element has not been seen before", 17, null);
     }
-    el = el.get();
+    try {
+      el = el.get();
+    }
+    catch(e) {
+      el = null;
+      delete this.seenItems[id];
+    }
     // use XPCNativeWrapper to compare elements; see bug 834266
     if (!el || !(XPCNativeWrapper(el).ownerDocument == XPCNativeWrapper(win).document)) {
       throw new ElementException("Stale element reference", 10, null);
     }
     return el;
   },
   
   /**