Bug 1572903: Part 1 - Handle remote object proxies sanely in isWrapper. r=mccr8
authorKris Maglione <maglione.k@gmail.com>
Fri, 09 Aug 2019 19:04:58 -0700
changeset 488074 5f0660a4dc617fdeae2221bde5b77f2655e109a6
parent 488073 4546e42005a04b3cb98bbf315bd8a986f772f543
child 488075 1d8042fdc2b8a6ec78169a33d2648db97b2131c4
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1572903
milestone70.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 1572903: Part 1 - Handle remote object proxies sanely in isWrapper. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D41472
testing/specialpowers/content/WrapPrivileged.jsm
--- a/testing/specialpowers/content/WrapPrivileged.jsm
+++ b/testing/specialpowers/content/WrapPrivileged.jsm
@@ -34,17 +34,24 @@ var EXPORTED_SYMBOLS = ["WrapPrivileged"
 function isWrappable(x) {
   if (typeof x === "object") {
     return x !== null;
   }
   return typeof x === "function";
 }
 
 function isWrapper(x) {
-  return isWrappable(x) && typeof x.SpecialPowers_wrappedObject !== "undefined";
+  try {
+    return isWrappable(x) && typeof x.SpecialPowers_wrappedObject !== "undefined";
+  } catch (e) {
+    // If `x` is a remote object proxy, trying to access an unexpected property
+    // on it will throw a security error, even though we're chrome privileged.
+    // However, remote proxies are not SpecialPowers wrappers, so:
+    return false;
+  }
 }
 
 function unwrapIfWrapped(x) {
   return isWrapper(x) ? unwrapPrivileged(x) : x;
 }
 
 function wrapIfUnwrapped(x) {
   return isWrapper(x) ? x : wrapPrivileged(x);