Title: [209149] trunk
Revision
209149
Author
[email protected]
Date
2016-11-30 13:13:42 -0800 (Wed, 30 Nov 2016)

Log Message

Proxy is not allowed in the global prototype chain.
https://bugs.webkit.org/show_bug.cgi?id=165205

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* runtime/ProgramExecutable.cpp:
(JSC::ProgramExecutable::initializeGlobalProperties):
- We'll now throw a TypeError if we detect a Proxy in the global prototype chain.

LayoutTests:

* js/dom/proxy-is-not-allowed-in-global-prototype-chain-expected.txt: Added.
* js/dom/proxy-is-not-allowed-in-global-prototype-chain.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209148 => 209149)


--- trunk/LayoutTests/ChangeLog	2016-11-30 20:38:46 UTC (rev 209148)
+++ trunk/LayoutTests/ChangeLog	2016-11-30 21:13:42 UTC (rev 209149)
@@ -1,3 +1,13 @@
+2016-11-30  Mark Lam  <[email protected]>
+
+        Proxy is not allowed in the global prototype chain.
+        https://bugs.webkit.org/show_bug.cgi?id=165205
+
+        Reviewed by Geoffrey Garen.
+
+        * js/dom/proxy-is-not-allowed-in-global-prototype-chain-expected.txt: Added.
+        * js/dom/proxy-is-not-allowed-in-global-prototype-chain.html: Added.
+
 2016-11-30  Brent Fulgham  <[email protected]>
 
         Use 'childOfType' template when retrieving Shadow DOM elements

Added: trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain-expected.txt (0 => 209149)


--- trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain-expected.txt	2016-11-30 21:13:42 UTC (rev 209149)
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: TypeError: Proxy is not allowed in the global prototype chain.
+onerror saw TypeError: Proxy is not allowed in the global prototype chain.
+

Added: trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain.html (0 => 209149)


--- trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain.html	                        (rev 0)
+++ trunk/LayoutTests/js/dom/proxy-is-not-allowed-in-global-prototype-chain.html	2016-11-30 21:13:42 UTC (rev 209149)
@@ -0,0 +1,30 @@
+<pre id="console"></pre>
+
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+window._onerror_ = function(e) {
+	log("onerror saw " + e);
+}
+
+try {
+    var proto = window.__proto__.__proto__.__proto__;
+    proto.__proto__ = new Proxy(proto.__proto__, {
+        has(target, prop) {
+            log("FAIL: proxy saw " + prop);
+        }
+    });
+
+} catch (e) {
+    log("Caught: " + e);
+    log(e.stack);
+}
+
+function log(s)
+{
+    document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
+}
+</script>
+
+<script>var undefined_variable</script>

Modified: trunk/Source/_javascript_Core/ChangeLog (209148 => 209149)


--- trunk/Source/_javascript_Core/ChangeLog	2016-11-30 20:38:46 UTC (rev 209148)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-11-30 21:13:42 UTC (rev 209149)
@@ -1,3 +1,14 @@
+2016-11-30  Mark Lam  <[email protected]>
+
+        Proxy is not allowed in the global prototype chain.
+        https://bugs.webkit.org/show_bug.cgi?id=165205
+
+        Reviewed by Geoffrey Garen.
+
+        * runtime/ProgramExecutable.cpp:
+        (JSC::ProgramExecutable::initializeGlobalProperties):
+        - We'll now throw a TypeError if we detect a Proxy in the global prototype chain.
+
 2016-11-30  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r209112.

Modified: trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp (209148 => 209149)


--- trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp	2016-11-30 20:38:46 UTC (rev 209148)
+++ trunk/Source/_javascript_Core/runtime/ProgramExecutable.cpp	2016-11-30 21:13:42 UTC (rev 209149)
@@ -79,6 +79,15 @@
     RELEASE_ASSERT(globalObject);
     ASSERT(&globalObject->vm() == &vm);
 
+    JSValue nextPrototype = globalObject->getPrototypeDirect();
+    while (nextPrototype && nextPrototype.isObject()) {
+        if (UNLIKELY(asObject(nextPrototype)->type() == ProxyObjectType)) {
+            ExecState* exec = globalObject->globalExec();
+            return createTypeError(exec, ASCIILiteral("Proxy is not allowed in the global prototype chain."));
+        }
+        nextPrototype = asObject(nextPrototype)->getPrototypeDirect();
+    }
+    
     JSObject* exception = nullptr;
     UnlinkedProgramCodeBlock* unlinkedCodeBlock = globalObject->createProgramCodeBlock(callFrame, this, &exception);
     if (UNLIKELY(exception))
@@ -177,7 +186,7 @@
             RELEASE_ASSERT(offsetForAssert == offset);
         }
     }
-    return 0;
+    return nullptr;
 }
 
 void ProgramExecutable::visitChildren(JSCell* cell, SlotVisitor& visitor)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to