Bug 1312817 - Handle wrappers in JS::WasmModule APIs, enable {window,iframe}.postMessage() (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Fri, 28 Oct 2016 08:32:16 -0500
changeset 346649 dc216bb3f2c7f149d4d5ca8e1dfee6aac9c5cd4d
parent 346648 94efce672651a0dadb9fff2325103f4e22d89362
child 346650 fdf88420e469e82ff3dc857e7928f8e9cec98cef
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1312817
milestone52.0a1
Bug 1312817 - Handle wrappers in JS::WasmModule APIs, enable {window,iframe}.postMessage() (r=bbouvier) MozReview-Commit-ID: 3byAlv3KBMm
dom/base/test/test_postMessages.html
js/src/jsapi.cpp
--- a/dom/base/test/test_postMessages.html
+++ b/dom/base/test/test_postMessages.html
@@ -364,17 +364,17 @@ function test_windowToIframeURL(url) {
     tmp({ data: e.data, ports: e.ports });
   }
 
   var ifr = document.createElement('iframe');
   ifr.src = url;
   ifr.onload = function() {
     runTests({
       clonableObjectsEveryWhere: true,
-      clonableObjectsSameProcess: false,
+      clonableObjectsSameProcess: true,
       transferableObjects: true,
       send: function(what, ports) {
         return new Promise(function(r, rr) {
           resolve = r;
           try {
             ifr.contentWindow.postMessage(what, '*', ports);
           } catch(e) {
             resolve = null;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6677,23 +6677,27 @@ JS_PUBLIC_API(void)
 JS::SetAsmJSCacheOps(JSContext* cx, const JS::AsmJSCacheOps* ops)
 {
     cx->runtime()->asmJSCacheOps = *ops;
 }
 
 bool
 JS::IsWasmModuleObject(HandleObject obj)
 {
-    return obj->is<WasmModuleObject>();
+    JSObject* unwrapped = CheckedUnwrap(obj);
+    if (!unwrapped)
+        return false;
+    return unwrapped->is<WasmModuleObject>();
 }
 
 JS_PUBLIC_API(RefPtr<JS::WasmModule>)
 JS::GetWasmModule(HandleObject obj)
 {
-    return &obj->as<WasmModuleObject>().module();
+    MOZ_ASSERT(JS::IsWasmModuleObject(obj));
+    return &CheckedUnwrap(obj)->as<WasmModuleObject>().module();
 }
 
 JS_PUBLIC_API(bool)
 JS::CompiledWasmModuleAssumptionsMatch(PRFileDesc* compiled, JS::BuildIdCharVector&& buildId)
 {
     return wasm::CompiledModuleAssumptionsMatch(compiled, Move(buildId));
 }