<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[209662] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/209662">209662</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2016-12-10 03:56:30 -0800 (Sat, 10 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Module namespace object behaves like immutable prototype exotic object
https://bugs.webkit.org/show_bug.cgi?id=165598

Reviewed by Mark Lam.

JSTests:

* modules/namespace-prototype-assignment.js: Added.
(else):
(reportError):
(shouldEqual):
(shouldThrow):
(stringify):
(makeTestID):
(doInternalSetPrototypeOf):
(ordinarySetPrototypeOf):
(setImmutablePrototype):
(windowProxySetPrototypeOf):
(initSetterExpectation):
(throwIfNoExceptionPending):
(objectSetPrototypeOf):
(setUnderscoreProto):
(reflectSetPrototypeOf):
(setPrototypeOf):
(newObjectProto.toString):
(Symbol):
(test):
(runTests):
* modules/namespace-set-prototype-of.js: Added.
(shouldThrow):
(TypeError.Cannot.set prototype):

Source/JavaScriptCore:

In the latest ECMA262 draft, the module namespace object behaves like immutable prototype exotic object.
https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects-setprototypeof-v

* runtime/JSModuleNamespaceObject.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleNamespaceObjecth">trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsmodulesnamespaceprototypeassignmentjs">trunk/JSTests/modules/namespace-prototype-assignment.js</a></li>
<li><a href="#trunkJSTestsmodulesnamespacesetprototypeofjs">trunk/JSTests/modules/namespace-set-prototype-of.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (209661 => 209662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-12-10 10:19:00 UTC (rev 209661)
+++ trunk/JSTests/ChangeLog        2016-12-10 11:56:30 UTC (rev 209662)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-12-10  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC] Module namespace object behaves like immutable prototype exotic object
+        https://bugs.webkit.org/show_bug.cgi?id=165598
+
+        Reviewed by Mark Lam.
+
+        * modules/namespace-prototype-assignment.js: Added.
+        (else):
+        (reportError):
+        (shouldEqual):
+        (shouldThrow):
+        (stringify):
+        (makeTestID):
+        (doInternalSetPrototypeOf):
+        (ordinarySetPrototypeOf):
+        (setImmutablePrototype):
+        (windowProxySetPrototypeOf):
+        (initSetterExpectation):
+        (throwIfNoExceptionPending):
+        (objectSetPrototypeOf):
+        (setUnderscoreProto):
+        (reflectSetPrototypeOf):
+        (setPrototypeOf):
+        (newObjectProto.toString):
+        (Symbol):
+        (test):
+        (runTests):
+        * modules/namespace-set-prototype-of.js: Added.
+        (shouldThrow):
+        (TypeError.Cannot.set prototype):
+
</ins><span class="cx"> 2016-12-09  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         JSVALUE64: Pass arguments in platform argument registers when making JavaScript calls
</span></span></pre></div>
<a id="trunkJSTestsmodulesnamespaceprototypeassignmentjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/modules/namespace-prototype-assignment.js (0 => 209662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/modules/namespace-prototype-assignment.js                                (rev 0)
+++ trunk/JSTests/modules/namespace-prototype-assignment.js        2016-12-10 11:56:30 UTC (rev 209662)
</span><span class="lines">@@ -0,0 +1,389 @@
</span><ins>+// This test suite compares the behavior of setting the prototype on various values
+// (using Object.setPrototypeOf(), obj.__proto__ assignment, and Reflect.setPrototypeOf())
+// against what is specified in the ES spec.  The expected behavior specified according
+// to the spec is expressed in expectationsForObjectSetPrototypeOf,
+// expectationsForSetUnderscoreProto, and expectationsForReflectSetPrototypeOf.
+
+import * as namespace from &quot;./namespace-prototype-assignment.js&quot;
+
+var inBrowser = (typeof window != &quot;undefined&quot;);
+
+// Test configuration options:
+var verbose = false;
+var maxIterations = 1;
+var throwOnEachError = true;
+
+var testUndefined = true;
+var testNull = true;
+var testTrue = true;
+var testFalse = true;
+var testNumbers = true;
+var testString = true;
+var testSymbol = true;
+var testObject = true;
+var testGlobal = true;
+var testWindowProtos = inBrowser;
+
+var engine;
+
+//====================================================================================
+// Error messages:
+
+if (inBrowser) {
+    let userAgent = navigator.userAgent;
+    if (userAgent.match(/ Chrome\/[0-9]+/)) engine = &quot;chrome&quot;;
+    else if (userAgent.match(/ Firefox\/[0-9]+/)) engine = &quot;default&quot;;
+    else engine = &quot;safari&quot;;
+} else
+    engine = &quot;jsc&quot;;
+
+// Set default error messages and then override with engine specific ones below.
+var DefaultTypeError = &quot;TypeError: &quot;;
+var CannotSetPrototypeOfImmutablePrototypeObject = DefaultTypeError;
+var CannotSetPrototypeOfThisObject = DefaultTypeError;
+var CannotSetPrototypeOfUndefinedOrNull = DefaultTypeError;
+var CannotSetPrototypeOfNonObject = DefaultTypeError;
+var PrototypeValueCanOnlyBeAnObjectOrNull = DefaultTypeError;
+var ObjectProtoCalledOnNullOrUndefinedError = DefaultTypeError;
+var ReflectSetPrototypeOfRequiresTheFirstArgumentBeAnObject = DefaultTypeError;
+var ReflectSetPrototypeOfRequiresTheSecondArgumentBeAnObjectOrNull = DefaultTypeError;
+
+if (engine == &quot;jsc&quot; || engine === &quot;safari&quot;) {
+    CannotSetPrototypeOfImmutablePrototypeObject = &quot;TypeError: Cannot set prototype of immutable prototype object&quot;;
+    CannotSetPrototypeOfThisObject = &quot;TypeError: Cannot set prototype of this object&quot;;
+    CannotSetPrototypeOfUndefinedOrNull = &quot;TypeError: Cannot set prototype of undefined or null&quot;;
+    CannotSetPrototypeOfNonObject = &quot;TypeError: Cannot set prototype of non-object&quot;;
+    PrototypeValueCanOnlyBeAnObjectOrNull = &quot;TypeError: Prototype value can only be an object or null&quot;;
+    ObjectProtoCalledOnNullOrUndefinedError = &quot;TypeError: Object.prototype.__proto__ called on null or undefined&quot;;
+    ReflectSetPrototypeOfRequiresTheFirstArgumentBeAnObject = &quot;TypeError: Reflect.setPrototypeOf requires the first argument be an object&quot;;
+    ReflectSetPrototypeOfRequiresTheSecondArgumentBeAnObjectOrNull = &quot;TypeError: Reflect.setPrototypeOf requires the second argument be either an object or null&quot;;
+} else if (engine === &quot;chrome&quot;) {
+    CannotSetPrototypeOfImmutablePrototypeObject = &quot;TypeError: Immutable prototype object &quot;;
+}
+
+//====================================================================================
+// Utility functions:
+
+if (inBrowser)
+    print = console.log;
+
+function reportError(errorMessage) {
+    if (throwOnEachError)
+        throw errorMessage;
+    else
+        print(errorMessage);
+}
+
+function shouldEqual(testID, resultType, actual, expected) {
+    if (actual != expected)
+        reportError(&quot;ERROR in &quot; + resultType
+            + &quot;: expect &quot; + stringify(expected) + &quot;, actual &quot; + stringify(actual)
+            + &quot; in test: &quot; + testID.signature + &quot; on iteration &quot; + testID.iteration);
+}
+
+function shouldThrow(testID, resultType, actual, expected) {
+    let actualStr = &quot;&quot; + actual;
+    if (!actualStr.startsWith(expected))
+        reportError(&quot;ERROR in &quot; + resultType
+            + &quot;: expect &quot; + expected + &quot;, actual &quot; + actual
+            + &quot; in test: &quot; + testID.signature + &quot; on iteration &quot; + testID.iteration);
+}
+
+function stringify(value) {
+    if (typeof value == &quot;string&quot;) return '&quot;' + value + '&quot;';
+    if (typeof value == &quot;symbol&quot;) return value.toString();
+
+    if (value === origGlobalProto) return &quot;origGlobalProto&quot;;
+    if (value === origObjectProto) return &quot;origObjectProto&quot;;
+    if (value === newObjectProto) return &quot;newObjectProto&quot;;
+    if (value === proxyObject) return &quot;proxyObject&quot;;
+
+    if (value === null) return &quot;null&quot;;
+    if (typeof value == &quot;object&quot;) return &quot;object&quot;;
+    return &quot;&quot; + value;
+}
+
+function makeTestID(index, iteration, targetName, protoToSet, protoSetter, expected) {
+    let testID = {};
+    testID.signature = &quot;[&quot; + index + &quot;] &quot;
+        + protoSetter.actionName + &quot;|&quot;
+        + targetName + &quot;|&quot;
+        + stringify(protoToSet) + &quot;|&quot;
+        + stringify(expected.result) + &quot;|&quot;
+        + stringify(expected.proto) + &quot;|&quot;
+        + stringify(expected.exception);
+    testID.iteration = iteration;
+    return testID;
+}
+
+//====================================================================================
+// Functions to express the expectations of the ES specification:
+
+function doInternalSetPrototypeOf(result, target, origProto, newProto) {
+    if (!target.setPrototypeOf) {
+        result.success = true;
+        result.exception = undefined;
+        return;
+    }
+    target.setPrototypeOf(result, origProto, newProto);
+}
+
+// 9.1.2.1 OrdinarySetPrototypeOf ( O, V )
+// https://tc39.github.io/ecma262/#sec-ordinarysetprototypeof
+function ordinarySetPrototypeOf(result, currentProto, newProto) {
+    // 9.1.2.1-4 If SameValue(V, current) is true, return true.
+    if (newProto === currentProto) {
+        result.success = true;
+        return;
+    }
+    // 9.1.2.1-5 [extensibility check not tested here]
+    // 9.1.2.1-8 [cycle check not tested here]
+    result.success = true;
+}
+
+// 9.4.7.2 SetImmutablePrototype ( O, V )
+// https://tc39.github.io/ecma262/#sec-set-immutable-prototype
+function setImmutablePrototype(result, currentProto, newProto) {
+    if (newProto === currentProto) {
+        result.success = true;
+        return;
+    }
+    result.success = false;
+    result.exception = CannotSetPrototypeOfImmutablePrototypeObject;
+}
+
+// HTML spec: 7.4.2 [[SetPrototypeOf]] ( V )
+// https://html.spec.whatwg.org/#windowproxy-setprototypeof
+function windowProxySetPrototypeOf(result, currentProto, newProto) {
+    result.success = false;
+    result.exception = CannotSetPrototypeOfThisObject;
+}
+
+
+var count = 0;
+function initSetterExpectation(target, newProto) {
+    var targetValue = target.value();
+    var origProto = undefined;
+    if (targetValue != null &amp;&amp; targetValue != undefined)
+        origProto = targetValue.__proto__; // Default to old proto.
+
+    var expected = {};
+    expected.targetValue = targetValue;
+    expected.origProto = origProto;
+    expected.exception = undefined;
+    expected.proto = origProto;
+    expected.result = undefined;
+
+    return expected;
+}
+
+// 19.1.2.21 Object.setPrototypeOf ( O, proto )
+// https://tc39.github.io/ecma262/#sec-object.setprototypeof
+function objectSetPrototypeOf(target, newProto) {
+    let expected = initSetterExpectation(target, newProto);
+    var targetValue = expected.targetValue;
+    var origProto = expected.origProto;
+
+    function throwIfNoExceptionPending(e) {
+        if (!expected.exception)
+            expected.exception = e;
+    }
+
+    // 19.1.2.21-1 Let O be ? RequireObjectCoercible(O).
+    if (targetValue == undefined || targetValue == null)
+        throwIfNoExceptionPending(CannotSetPrototypeOfUndefinedOrNull);
+
+    // 19.1.2.21-2 If Type(proto) is neither Object nor Null, throw a TypeError exception.
+    if (typeof newProto != &quot;object&quot;)
+        throwIfNoExceptionPending(PrototypeValueCanOnlyBeAnObjectOrNull);
+
+    // 19.1.2.21-3 If Type(O) is not Object, return O.
+    else if (typeof targetValue != &quot;object&quot;)
+        expected.result = targetValue;
+
+    // 19.1.2.21-4 Let status be ? O.[[SetPrototypeOf]](proto).
+    else {
+        // 19.1.2.21-5 If status is false, throw a TypeError exception.
+        let result = {};
+        doInternalSetPrototypeOf(result, target, origProto, newProto);
+        if (result.success)
+            expected.proto = newProto;
+        else
+            throwIfNoExceptionPending(result.exception);
+
+        // 19.1.2.21-6 Return O.
+        expected.result = targetValue;
+    }
+
+    return expected;
+}
+objectSetPrototypeOf.action = (obj, newProto) =&gt; Object.setPrototypeOf(obj, newProto);
+objectSetPrototypeOf.actionName = &quot;Object.setPrototypeOf&quot;;
+
+
+// B.2.2.1.2 set Object.prototype.__proto__
+// https://tc39.github.io/ecma262/#sec-set-object.prototype.__proto__
+function setUnderscoreProto(target, newProto) {
+    let expected = initSetterExpectation(target, newProto);
+    var targetValue = expected.targetValue;
+    var origProto = expected.origProto;
+
+    function throwIfNoExceptionPending(e) {
+        if (!expected.exception)
+            expected.exception = e;
+    }
+
+    // B.2.2.1.2-1 Let O be ? RequireObjectCoercible(this value).
+    if (targetValue == undefined || targetValue == null)
+        throwIfNoExceptionPending(DefaultTypeError);
+
+    // B.2.2.1.2-2 If Type(proto) is neither Object nor Null, return undefined.
+    if (typeof newProto != &quot;object&quot;)
+        expected.result = undefined;
+
+    // B.2.2.1.2-3 If Type(O) is not Object, return undefined.
+    else if (typeof targetValue != &quot;object&quot;)
+        expected.result = undefined;
+
+    // B.2.2.1.2-4 Let status be ? O.[[SetPrototypeOf]](proto).
+    else {
+        // B.2.2.1.2-5 If status is false, throw a TypeError exception.
+        let result = {};
+        doInternalSetPrototypeOf(result, target, origProto, newProto);
+        if (result.success)
+            expected.proto = newProto;
+        else
+            throwIfNoExceptionPending(result.exception);
+
+        // B.2.2.1.2-6 Return undefined.
+        expected.result = undefined;
+    }
+
+    // Override the result to be the newProto value because the statement obj.__proto__ = value
+    // will produce the rhs value, not the result of the obj.__proto__ setter.
+    expected.result = newProto;
+    return expected;
+}
+setUnderscoreProto.action = (obj, newProto) =&gt; (obj.__proto__ = newProto);
+setUnderscoreProto.actionName = &quot;obj.__proto__&quot;;
+
+
+// 26.1.13 Reflect.setPrototypeOf ( target, proto )
+// https://tc39.github.io/ecma262/#sec-reflect.setprototypeof
+// function expectationsForReflectSetPrototypeOf(target, newProto, targetExpectation) {
+function reflectSetPrototypeOf(target, newProto) {
+    let expected = initSetterExpectation(target, newProto);
+    var targetValue = expected.targetValue;
+    var origProto = expected.origProto;
+
+    function throwIfNoExceptionPending(e) {
+        if (!expected.exception)
+            expected.exception = e;
+    }
+
+    // 26.1.13-1 If Type(target) is not Object, throw a TypeError exception.
+    if (targetValue === null || typeof targetValue != &quot;object&quot;)
+        throwIfNoExceptionPending(ReflectSetPrototypeOfRequiresTheFirstArgumentBeAnObject);
+
+    // 26.1.13-2 If Type(proto) is not Object and proto is not null, throw a TypeError exception.
+    if (typeof newProto != &quot;object&quot;)
+        throwIfNoExceptionPending(ReflectSetPrototypeOfRequiresTheSecondArgumentBeAnObjectOrNull);
+
+    // 26.1.13-3 Return ? target.[[SetPrototypeOf]](proto).
+    let result = {};
+    doInternalSetPrototypeOf(result, target, origProto, newProto);
+    expected.result = result.success;
+    if (result.success)
+        expected.proto = newProto;
+
+    return expected;
+}
+reflectSetPrototypeOf.action = (obj, newProto) =&gt; Reflect.setPrototypeOf(obj, newProto);
+reflectSetPrototypeOf.actionName = &quot;Reflect.setPrototypeOf&quot;;
+
+
+//====================================================================================
+// Test Data:
+
+var global = new Function('return this')();
+var origGlobalProto = global.__proto__;
+var origObjectProto = {}.__proto__;
+var proxyObject = new Proxy({ }, {
+    setPrototypeOf(target, value) {
+        throw &quot;Thrown from proxy&quot;;
+    }
+});
+var newObjectProto = { toString() { return &quot;newObjectProto&quot;; } };
+var origNamespaceProto = namespace.__proto__;
+
+var targets = [];
+
+targets.push({
+  name: &quot;namespace&quot;,
+  value: () =&gt; origNamespaceProto,
+  setPrototypeOf: setImmutablePrototype
+});
+
+var newProtos = [
+    undefined,
+    null,
+    true,
+    false,
+    0,
+    11,
+    123.456,
+    &quot;doh&quot;,
+    Symbol(&quot;doh&quot;),
+    {},
+    origObjectProto,
+    origGlobalProto,
+    newObjectProto
+];
+
+var protoSetters = [
+    objectSetPrototypeOf,
+    setUnderscoreProto,
+    reflectSetPrototypeOf,
+];
+
+
+//====================================================================================
+// Test driver functions:
+
+function test(testID, targetValue, newProto, setterAction, expected) {
+    let exception = undefined;
+    let result = undefined;
+    try {
+        result = setterAction(targetValue, newProto);
+    } catch (e) {
+        exception = e;
+    }
+    shouldThrow(testID, &quot;exception&quot;, exception, expected.exception);
+    if (!expected.exception) {
+        shouldEqual(testID, &quot;__proto__&quot;, targetValue.__proto__, expected.proto);
+        shouldEqual(testID, &quot;result&quot;, result, expected.result);
+    }
+}
+
+function runTests() {
+    let testIndex = 0;
+    for (let protoSetter of protoSetters) {
+        for (let target of targets) {
+            for (let newProto of newProtos) {
+                let currentTestIndex = testIndex++;
+                for (var i = 0; i &lt; maxIterations; i++) {
+                    let expected = protoSetter(target, newProto);
+                    let targetValue = expected.targetValue;
+
+                    let testID = makeTestID(currentTestIndex, i, target.name, newProto, protoSetter, expected);
+                    if (verbose &amp;&amp; i == 0)
+                        print(&quot;test: &quot; + testID.signature);
+
+                    test(testID, targetValue, newProto, protoSetter.action, expected);
+                }
+            }
+        }
+    }
+}
+
+runTests();
</ins></span></pre></div>
<a id="trunkJSTestsmodulesnamespacesetprototypeofjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/modules/namespace-set-prototype-of.js (0 => 209662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/modules/namespace-set-prototype-of.js                                (rev 0)
+++ trunk/JSTests/modules/namespace-set-prototype-of.js        2016-12-10 11:56:30 UTC (rev 209662)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+import * as namespace from &quot;./namespace-set-prototype-of.js&quot;
+import { shouldBe, shouldThrow } from &quot;./resources/assert.js&quot;;
+
+shouldThrow(() =&gt; {
+    Object.setPrototypeOf(namespace, {});
+}, `TypeError: Cannot set prototype of immutable prototype object`);
+
+shouldBe(Reflect.setPrototypeOf(namespace, {}), false);
+shouldBe(Reflect.setPrototypeOf(namespace, null), true);
+shouldBe(Object.setPrototypeOf(namespace, null), namespace);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209661 => 209662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-10 10:19:00 UTC (rev 209661)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-10 11:56:30 UTC (rev 209662)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2016-12-10  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><ins>+        [JSC] Module namespace object behaves like immutable prototype exotic object
+        https://bugs.webkit.org/show_bug.cgi?id=165598
+
+        Reviewed by Mark Lam.
+
+        In the latest ECMA262 draft, the module namespace object behaves like immutable prototype exotic object.
+        https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects-setprototypeof-v
+
+        * runtime/JSModuleNamespaceObject.h:
+
+2016-12-10  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
</ins><span class="cx">         REGRESSION(r208791): Assertion in testb3
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=165651
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleNamespaceObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h (209661 => 209662)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h        2016-12-10 10:19:00 UTC (rev 209661)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h        2016-12-10 11:56:30 UTC (rev 209662)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> class JSModuleNamespaceObject : public JSDestructibleObject {
</span><span class="cx"> public:
</span><span class="cx">     typedef JSDestructibleObject Base;
</span><del>-    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | GetOwnPropertySlotIsImpureForPropertyAbsence;
</del><ins>+    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | GetOwnPropertySlotIsImpureForPropertyAbsence | IsImmutablePrototypeExoticObject;
</ins><span class="cx"> 
</span><span class="cx">     static JSModuleNamespaceObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, AbstractModuleRecord* moduleRecord, const IdentifierSet&amp; exports)
</span><span class="cx">     {
</span></span></pre>
</div>
</div>

</body>
</html>