Changeset 207518 in webkit
- Timestamp:
- Oct 18, 2016 8:52:29 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r207500 r207518 1 2016-10-18 Mark Lam <mark.lam@apple.com> 2 3 Invoking Object.prototype.__proto__ accessors directly should throw a TypeError. 4 https://bugs.webkit.org/show_bug.cgi?id=154377 5 <rdar://problem/27330808> 6 7 Reviewed by Filip Pizlo and Saam Barati. 8 9 * stress/object-prototype-proto-accessors-should-throw-on-undefined-this.js: Added. 10 1 11 2016-10-18 Keith Miller <keith_miller@apple.com> 2 12 -
trunk/LayoutTests/ChangeLog
r207515 r207518 1 2016-10-18 Mark Lam <mark.lam@apple.com> 2 3 Invoking Object.prototype.__proto__ accessors directly should throw a TypeError. 4 https://bugs.webkit.org/show_bug.cgi?id=154377 5 <rdar://problem/27330808> 6 7 Reviewed by Filip Pizlo and Saam Barati. 8 9 * http/tests/security/xss-DENIED-htmlelelment-with-iframe-proto-expected.txt: 10 * http/tests/security/xss-DENIED-method-with-iframe-proto-expected.txt: 11 * http/tests/security/xss-DENIED-non-shadowable-propterty-with-iframe-proto-expected.txt: 12 * http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto-expected.txt: 13 * http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto.html: 14 * js/dom/activation-proto-expected.txt: 15 * js/dom/script-tests/activation-proto.js: 16 * js/object-literal-shorthand-construction-expected.txt: 17 * js/script-tests/object-literal-shorthand-construction.js: 18 * js/script-tests/sloppy-getter-setter-global-object.js: 19 * js/sloppy-getter-setter-global-object-expected.txt: 20 1 21 2016-10-18 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/LayoutTests/http/tests/security/xss-DENIED-htmlelelment-with-iframe-proto-expected.txt
r205670 r207518 5 5 6 6 7 PASS __proto__ = targetWindow threw exception TypeError: Cannot set prototype of this object.7 PASS __proto__ = targetWindow threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 8 8 PASS targetWindow.myinput threw exception SecurityError (DOM Exception 18): Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.. 9 9 PASS: successfullyParsed should be 'true' and is. -
trunk/LayoutTests/http/tests/security/xss-DENIED-method-with-iframe-proto-expected.txt
r205670 r207518 8 8 9 9 10 PASS __proto__ = targetWindow threw exception TypeError: Cannot set prototype of this object.10 PASS __proto__ = targetWindow threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 11 11 PASS: successfullyParsed should be 'true' and is. 12 12 -
trunk/LayoutTests/http/tests/security/xss-DENIED-non-shadowable-propterty-with-iframe-proto-expected.txt
r205670 r207518 5 5 6 6 7 PASS __proto__ = targetWindow threw exception TypeError: Cannot set prototype of this object.7 PASS __proto__ = targetWindow threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 8 8 PASS: location === originalLocation should be 'true' and is. 9 9 PASS: this.location === originalLocation should be 'true' and is. -
trunk/LayoutTests/http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto-expected.txt
r205670 r207518 5 5 6 6 7 PASS __proto__ = targetWindow threw exception TypeError: Cannot set prototype of this object. 7 PASS this.__proto__ = targetWindow threw exception TypeError: Cannot set prototype of this object. 8 PASS __proto__ = targetWindow threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 8 9 PASS: innerHeight === originalInnerHeight should be 'true' and is. 9 10 PASS: this.innerHeight === originalInnerHeight should be 'true' and is. -
trunk/LayoutTests/http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto.html
r205670 r207518 16 16 originalInnerHeight = innerHeight; 17 17 18 shouldThrowErrorName("this.__proto__ = targetWindow", "TypeError"); 18 19 shouldThrowErrorName("__proto__ = targetWindow", "TypeError"); 19 20 -
trunk/LayoutTests/js/dom/activation-proto-expected.txt
r156066 r207518 4 4 5 5 6 PASS (function() { __proto__.testVariable = 'found'; return window.testVariable; })() is 'found'6 PASS (function() { this.__proto__.testVariable = 'found'; return window.testVariable; })() is 'found' 7 7 PASS successfullyParsed is true 8 8 -
trunk/LayoutTests/js/dom/script-tests/activation-proto.js
r156066 r207518 5 5 ); 6 6 7 shouldBe("(function() { __proto__.testVariable = 'found'; return window.testVariable; })()", "'found'");7 shouldBe("(function() { this.__proto__.testVariable = 'found'; return window.testVariable; })()", "'found'"); -
trunk/LayoutTests/js/object-literal-shorthand-construction-expected.txt
r205939 r207518 62 62 PASS !!Object.getOwnPropertyDescriptor({set 'x'(value){}}, 'x').set is true 63 63 PASS !!Object.getOwnPropertyDescriptor({set 42(value){}}, '42').set is true 64 PASS __proto__ = [] threw exception TypeError: Cannot set prototype of this object. 65 PASS ({__proto__: __proto__}) instanceof Array is false 64 PASS this.__proto__ = [] threw exception TypeError: Cannot set prototype of this object. 65 PASS ({__proto__: this.__proto__}) instanceof Array is false 66 PASS __proto__ = [] threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 67 PASS ({__proto__: __proto__}) instanceof Array threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 66 68 PASS successfullyParsed is true 67 69 -
trunk/LayoutTests/js/script-tests/object-literal-shorthand-construction.js
r205939 r207518 111 111 112 112 // __proto__ shorthand should not modify the prototype. 113 shouldThrow("__proto__ = []"); 114 shouldBeFalse("({__proto__: __proto__}) instanceof Array"); 113 shouldThrow("this.__proto__ = []"); 114 shouldBeFalse("({__proto__: this.__proto__}) instanceof Array"); 115 shouldThrow("__proto__ = []", '"TypeError: Object.prototype.__proto__ called on null or undefined"'); 116 shouldThrow("({__proto__: __proto__}) instanceof Array", '"TypeError: Object.prototype.__proto__ called on null or undefined"'); -
trunk/LayoutTests/js/script-tests/sloppy-getter-setter-global-object.js
r205939 r207518 26 26 shouldNotThrow("Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set(['foo'])"); 27 27 28 shouldThrow("(0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get)()", "\"TypeError: Can't convert undefined or null to object\"");29 shouldThrow("(0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set)(['foo'])", "\"TypeError: Can't convert undefined or null to object\"");28 shouldThrow("(0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get)()", "\"TypeError: Object.prototype.__proto__ called on null or undefined\""); 29 shouldThrow("(0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set)(['foo'])", "\"TypeError: Object.prototype.__proto__ called on null or undefined\""); 30 30 31 31 32 32 var top_level_sloppy_getter = Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get; 33 should NotThrow("top_level_sloppy_getter();");33 shouldThrow("top_level_sloppy_getter();", "\"TypeError: Object.prototype.__proto__ called on null or undefined\""); 34 34 35 35 var top_level_sloppy_setter = Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set; 36 shouldThrow("top_level_sloppy_setter(['foo']);" );36 shouldThrow("top_level_sloppy_setter(['foo']);", "\"TypeError: Object.prototype.__proto__ called on null or undefined\""); -
trunk/LayoutTests/js/sloppy-getter-setter-global-object-expected.txt
r205939 r207518 9 9 PASS Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get() did not throw exception. 10 10 PASS Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set(['foo']) did not throw exception. 11 PASS (0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get)() threw exception TypeError: Can't convert undefined or null to object.12 PASS (0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set)(['foo']) threw exception TypeError: Can't convert undefined or null to object.13 PASS top_level_sloppy_getter(); did not throw exception.14 PASS top_level_sloppy_setter(['foo']); threw exception TypeError: Cannot set prototype of this object.11 PASS (0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').get)() threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 12 PASS (0,Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set)(['foo']) threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 13 PASS top_level_sloppy_getter(); threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 14 PASS top_level_sloppy_setter(['foo']); threw exception TypeError: Object.prototype.__proto__ called on null or undefined. 15 15 PASS successfullyParsed is true 16 16 -
trunk/Source/JavaScriptCore/ChangeLog
r207517 r207518 1 2016-10-18 Mark Lam <mark.lam@apple.com> 2 3 Invoking Object.prototype.__proto__ accessors directly should throw a TypeError. 4 https://bugs.webkit.org/show_bug.cgi?id=154377 5 <rdar://problem/27330808> 6 7 Reviewed by Filip Pizlo and Saam Barati. 8 9 In a scenario where we cache the __proto__ accessors in global variables, and 10 later explicitly invoke those accessors as functions, the spec for Function Calls 11 (see https://tc39.github.io/ecma262/#sec-function-calls) states that the function 12 ref value is of type Reference, and base of ref is an Environment Record. Then, 13 it follows that the thisValue should be set to refEnv.WithBaseObject() 14 (see section 4.b.ii of 12.3.4.1 at 15 https://tc39.github.io/ecma262/#sec-function-calls-runtime-semantics-evaluation). 16 17 refEnv in this case is the environment record that the cached accessors were 18 found in i.e. the global object. The WithBaseObject() of the global object is 19 undefined (see details about WithBaseObject at 20 https://tc39.github.io/ecma262/#sec-environment-records). 21 22 Hence, the __proto__ accessors should see a thisValue of undefined, and throw 23 TypeErrors. See https://tc39.github.io/ecma262/#sec-get-object.prototype.__proto__, 24 https://tc39.github.io/ecma262/#sec-set-object.prototype.__proto__, 25 https://tc39.github.io/ecma262/#sec-toobject, and 26 https://tc39.github.io/ecma262/#sec-requireobjectcoercible. 27 28 In JSC's implementation, the callee needs to do a ToThis operation on the 29 incoming "this" argument in order to get the specified thisValue. The 30 implementations of the __proto__ accessors were not doing this correctly. This 31 has now been fixed. 32 33 * runtime/JSGlobalObjectFunctions.cpp: 34 (JSC::globalFuncProtoGetter): 35 (JSC::globalFuncProtoSetter): 36 1 37 2016-10-18 Sam Weinig <sam@webkit.org> 2 38 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r207461 r207518 53 53 54 54 namespace JSC { 55 56 static const char* const ObjectProtoCalledOnNullOrUndefinedError = "Object.prototype.__proto__ called on null or undefined"; 55 57 56 58 template<typename CallbackWhenNoException> … … 871 873 auto scope = DECLARE_THROW_SCOPE(vm); 872 874 873 if (exec->thisValue().isUndefinedOrNull())874 return throwVMTypeError(exec, scope, ASCIILiteral("Can't convert undefined or null to object"));875 876 JSObject* thisObject = jsDynamicCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode)); 877 875 JSValue thisValue = exec->thisValue().toThis(exec, StrictMode); 876 if (thisValue.isUndefinedOrNull()) 877 return throwVMTypeError(exec, scope, ASCIILiteral(ObjectProtoCalledOnNullOrUndefinedError)); 878 879 JSObject* thisObject = jsDynamicCast<JSObject*>(thisValue); 878 880 if (!thisObject) { 879 881 JSObject* prototype = exec->thisValue().synthesizePrototype(exec); … … 891 893 auto scope = DECLARE_THROW_SCOPE(vm); 892 894 893 if (exec->thisValue().isUndefinedOrNull()) 894 return throwVMTypeError(exec, scope, ASCIILiteral("Can't convert undefined or null to object")); 895 JSValue thisValue = exec->thisValue().toThis(exec, StrictMode); 896 if (thisValue.isUndefinedOrNull()) 897 return throwVMTypeError(exec, scope, ASCIILiteral(ObjectProtoCalledOnNullOrUndefinedError)); 895 898 896 899 JSValue value = exec->argument(0); 897 900 898 JSObject* thisObject = jsDynamicCast<JSObject*>( exec->thisValue().toThis(exec, NotStrictMode));901 JSObject* thisObject = jsDynamicCast<JSObject*>(thisValue); 899 902 900 903 // Setting __proto__ of a primitive should have no effect.
Note: See TracChangeset
for help on using the changeset viewer.