Bug 1406146 - Fix handling of WindowProxy in jsshell testing functions. r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Wed, 10 Apr 2019 08:30:10 +0000
changeset 468817 fd75d6285f74bf868368020ce0ec37f81911705d
parent 468816 c15c9dd0fb2be8f40111d191497e0818fcc439d2
child 468818 dc43810c71fd7969ddae1f9cf4fc35736c50ba1b
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1406146
milestone68.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 1406146 - Fix handling of WindowProxy in jsshell testing functions. r=jandem This patch fixes a few cases in testing functions that do not correctly handling WindowProxy wrappers. This mostly involves passing the stopAtWindowProxy=false argument to unwrap functions. Differential Revision: https://phabricator.services.mozilla.com/D26836
js/src/builtin/TestingFunctions.cpp
js/src/shell/js.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -3909,17 +3909,17 @@ static bool EvalReturningScope(JSContext
   }
 
   RootedScript script(cx, JS::CompileForNonSyntacticScope(cx, options, srcBuf));
   if (!script) {
     return false;
   }
 
   if (global) {
-    global = CheckedUnwrapDynamic(global, cx);
+    global = CheckedUnwrapDynamic(global, cx, /* stopAtWindowProxy = */ false);
     if (!global) {
       JS_ReportErrorASCII(cx, "Permission denied to access global");
       return false;
     }
     if (!global->is<GlobalObject>()) {
       JS_ReportErrorASCII(cx, "Argument must be a global object");
       return false;
     }
@@ -4012,17 +4012,17 @@ static bool ShellCloneAndExecuteScript(J
     return false;
   }
 
   RootedScript script(cx, JS::Compile(cx, options, srcBuf));
   if (!script) {
     return false;
   }
 
-  global = CheckedUnwrapDynamic(global, cx);
+  global = CheckedUnwrapDynamic(global, cx, /* stopAtWindowProxy = */ false);
   if (!global) {
     JS_ReportErrorASCII(cx, "Permission denied to access global");
     return false;
   }
   if (!global->is<GlobalObject>()) {
     JS_ReportErrorASCII(cx, "Argument must be a global object");
     return false;
   }
@@ -4379,17 +4379,17 @@ static bool GetLcovInfo(JSContext* cx, u
 
   RootedObject global(cx);
   if (args.hasDefined(0)) {
     global = ToObject(cx, args[0]);
     if (!global) {
       JS_ReportErrorASCII(cx, "Permission denied to access global");
       return false;
     }
-    global = CheckedUnwrapDynamic(global, cx);
+    global = CheckedUnwrapDynamic(global, cx, /* stopAtWindowProxy = */ false);
     if (!global) {
       ReportAccessDenied(cx);
       return false;
     }
     if (!global->is<GlobalObject>()) {
       JS_ReportErrorASCII(cx, "Argument must be a global object");
       return false;
     }
@@ -5318,17 +5318,17 @@ static bool ObjectGlobal(JSContext* cx, 
   RootedObject callee(cx, &args.callee());
 
   if (!args.get(0).isObject()) {
     ReportUsageErrorASCII(cx, callee, "Argument must be an object");
     return false;
   }
 
   RootedObject obj(cx, &args[0].toObject());
-  if (IsWrapper(obj)) {
+  if (IsCrossCompartmentWrapper(obj)) {
     args.rval().setNull();
     return true;
   }
 
   obj = ToWindowProxyIfWindow(&obj->nonCCWGlobal());
 
   args.rval().setObject(*obj);
   return true;
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2043,17 +2043,18 @@ static bool Evaluate(JSContext* cx, unsi
       }
     }
 
     if (!JS_GetProperty(cx, opts, "global", &v)) {
       return false;
     }
     if (!v.isUndefined()) {
       if (v.isObject()) {
-        global = js::UncheckedUnwrap(&v.toObject());
+        global = js::CheckedUnwrapDynamic(&v.toObject(), cx,
+                                          /* stopAtWindowProxy = */ false);
         if (!global) {
           return false;
         }
       }
       if (!global || !(JS_GetClass(global)->flags & JSCLASS_IS_GLOBAL)) {
         JS_ReportErrorNumberASCII(
             cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
             "\"global\" passed to evaluate()", "not a global object");
@@ -8116,17 +8117,19 @@ static bool TransplantObject(JSContext* 
   RootedFunction callee(cx, &args.callee().as<JSFunction>());
 
   if (args.length() != 1 || !args[0].isObject()) {
     JS_ReportErrorASCII(cx, "transplant() must be called with an object");
     return false;
   }
 
   // |newGlobal| needs to be a GlobalObject.
-  RootedObject newGlobal(cx, CheckedUnwrapDynamic(&args[0].toObject(), cx));
+  RootedObject newGlobal(
+      cx, js::CheckedUnwrapDynamic(&args[0].toObject(), cx,
+                                   /* stopAtWindowProxy = */ false));
   if (!newGlobal) {
     ReportAccessDenied(cx);
     return false;
   }
   if (!JS_IsGlobalObject(newGlobal)) {
     JS_ReportErrorNumberASCII(
         cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
         "\"global\" passed to transplant()", "not a global object");