Bug 1320697 - Remove wrong assertion in jsscript.cpp. r=till
authorTooru Fujisawa <arai_a@mac.com>
Tue, 29 Nov 2016 09:08:44 +0900
changeset 324506 1b68b4d00610f0628cb5fac27600670815100f42
parent 324505 df0caa6a80d9a13333e1bc78b5a9f1919a08ed28
child 324507 952640eb7c568ae5794667cd78c6b9a080d3baee
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerstill
bugs1320697
milestone53.0a1
Bug 1320697 - Remove wrong assertion in jsscript.cpp. r=till
js/src/jsscript.cpp
js/src/tests/ecma_2017/AsyncFunctions/clone.js
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3121,18 +3121,16 @@ Rebase(JSScript* dst, JSScript* src, T* 
 {
     size_t off = reinterpret_cast<uint8_t*>(srcp) - src->data;
     return reinterpret_cast<T*>(dst->data + off);
 }
 
 static JSObject*
 CloneInnerInterpretedFunction(JSContext* cx, HandleScope enclosingScope, HandleFunction srcFun)
 {
-    /* async function should not appear as inner function. */
-    MOZ_ASSERT(!srcFun->isAsync());
     /* NB: Keep this in sync with XDRInterpretedFunction. */
     RootedObject cloneProto(cx);
     if (srcFun->isStarGenerator()) {
         cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
         if (!cloneProto)
             return nullptr;
     }
 
--- a/js/src/tests/ecma_2017/AsyncFunctions/clone.js
+++ b/js/src/tests/ecma_2017/AsyncFunctions/clone.js
@@ -1,7 +1,22 @@
-// |reftest| skip-if(!xulRuntime.shell) -- needs clone
+// |reftest| skip-if(!xulRuntime.shell) -- needs clone, cloneAndExecuteScript, drainJobQueue
 
 // Async function cannot be cloned.
 assertThrowsInstanceOf(() => clone(async function f() {}), TypeError);
 
+// unwrapped async function can be cloned.
+let g = newGlobal();
+cloneAndExecuteScript(`
+async function f() {
+  var a = await 1;
+  var b = await 2;
+  var c = await 3;
+  return a + b + c;
+}
+var V;
+f().then(v => V = v);
+drainJobQueue();
+`, g);
+assertEq(g.V, 6);
+
 if (typeof reportCompare === "function")
     reportCompare(true, true);