Changeset 274308 in webkit
- Timestamp:
- Mar 11, 2021 4:08:05 PM (17 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 25 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/microbenchmarks/global-var-put-to-scope.js (added)
-
JSTests/stress/eval-func-decl-in-frozen-global.js (modified) (1 diff)
-
JSTests/stress/global-object-define-own-property-put-to-scope.js (added)
-
JSTests/stress/global-object-define-own-property.js (added)
-
JSTests/stress/to-this-before-arrow-function-closes-over-this-that-starts-as-lexical-environment.js (modified) (3 diffs)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/Window/Location/window-override-location-using-defineGetter-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/Window/Location/window-override-location-using-defineGetter.html (modified) (1 diff)
-
LayoutTests/fast/dom/Window/Location/window-override-window-using-defineGetter-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/Window/Location/window-override-window-using-defineGetter.html (modified) (1 diff)
-
LayoutTests/fast/dom/getter-on-window-object2-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/getter-on-window-object2.html (modified) (2 diffs)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/jit/JIT.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JIT.h (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITPropertyAccess.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp (modified) (1 diff)
-
Source/JavaScriptCore/llint/LowLevelInterpreter.asm (modified) (1 diff)
-
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (modified) (2 diffs)
-
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObject.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObject.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/JSSymbolTableObject.h (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r274274 r274308 1 2021-03-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Align JSGlobalObject::defineOwnProperty() with the spec and other runtimes 4 https://bugs.webkit.org/show_bug.cgi?id=203456 5 6 Reviewed by Robin Morisset. 7 8 * microbenchmarks/global-var-put-to-scope.js: Added. 9 * stress/eval-func-decl-in-frozen-global.js: 10 Object.freeze() redefines all global variables as ReadOnly, including hoisted `var error`. 11 Aligns with V8. 12 13 * stress/global-object-define-own-property-put-to-scope.js: Added. 14 * stress/global-object-define-own-property.js: Added. 15 * stress/to-this-before-arrow-function-closes-over-this-that-starts-as-lexical-environment.js: 16 Fix unwanted name conflict, which was an error in the original test, not an intended part of it. 17 Also, remove misleading comment on `defineProperty` and assert accessors are created on global object. 18 Aligns with V8. 19 1 20 2021-03-11 Commit Queue <commit-queue@webkit.org> 2 21 -
trunk/JSTests/stress/eval-func-decl-in-frozen-global.js
r215984 r274308 37 37 Object.freeze(this); 38 38 { 39 varerror = false;39 let error = false; 40 40 try { 41 41 eval('{ function boo() {} }'); -
trunk/JSTests/stress/to-this-before-arrow-function-closes-over-this-that-starts-as-lexical-environment.js
r202693 r274308 18 18 function wrapper() { 19 19 let x = () => { 20 // This should not defineProperty on a JSLexicalEnvironment! That's a huge bug. 21 Object.defineProperty(this, "foo", { 20 Object.defineProperty(this, "baz", { 22 21 get: function() { }, 23 22 set: function() { } … … 38 37 function wrapper() { 39 38 let x = () => { 40 // This should not defineProperty on a JSLexicalEnvironment! That's a huge bug. 41 Object.defineProperty(this, "foo", { 39 Object.defineProperty(this, "baz2", { 42 40 get: function() { }, 43 41 set: function() { } 44 42 }); 43 assert(this === globalThis); 45 44 } 46 45 … … 57 56 } 58 57 foo2(); 58 59 assert(this.hasOwnProperty("baz")); 60 assert(this.hasOwnProperty("baz2")); -
trunk/LayoutTests/ChangeLog
r274301 r274308 1 2021-03-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Align JSGlobalObject::defineOwnProperty() with the spec and other runtimes 4 https://bugs.webkit.org/show_bug.cgi?id=203456 5 6 Reviewed by Robin Morisset. 7 8 * fast/dom/Window/Location/window-override-location-using-defineGetter-expected.txt: 9 * fast/dom/Window/Location/window-override-location-using-defineGetter.html: 10 * fast/dom/Window/Location/window-override-window-using-defineGetter-expected.txt: 11 * fast/dom/Window/Location/window-override-window-using-defineGetter.html: 12 * fast/dom/getter-on-window-object2-expected.txt: 13 * fast/dom/getter-on-window-object2.html: 14 1 15 2021-03-11 Aditya Keerthi <akeerthi@apple.com> 2 16 -
trunk/LayoutTests/fast/dom/Window/Location/window-override-location-using-defineGetter-expected.txt
r42218 r274308 1 PASS function () { 2 window.__defineGetter__("location", () => "haxored"); 3 } threw exception TypeError: Attempting to change configurable attribute of unconfigurable property.. 1 4 PASS result is correctValue 2 5 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/Window/Location/window-override-location-using-defineGetter.html
r155265 r274308 6 6 <body> 7 7 <script> 8 window.__defineGetter__("location", function() { return "haxored"; }); 8 shouldThrowErrorName(function() { 9 window.__defineGetter__("location", () => "haxored"); 10 }, "TypeError"); 9 11 10 12 var result = normalizeURL(String(window.location)); -
trunk/LayoutTests/fast/dom/Window/Location/window-override-window-using-defineGetter-expected.txt
r42218 r274308 1 PASS function () { 2 window.__defineGetter__("window", () => ({ location: "haxored" })); 3 } threw exception TypeError: Attempting to change configurable attribute of unconfigurable property.. 1 4 PASS result is correctValue 2 5 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/Window/Location/window-override-window-using-defineGetter.html
r155265 r274308 6 6 <body> 7 7 <script> 8 window.__defineGetter__("window",function() {9 return { location: "haxored" };10 } );8 shouldThrowErrorName(function() { 9 window.__defineGetter__("window", () => ({ location: "haxored" })); 10 }, "TypeError"); 11 11 12 12 var result = normalizeURL(String(window.location)); -
trunk/LayoutTests/fast/dom/getter-on-window-object2-expected.txt
r99136 r274308 4 4 5 5 6 PASS function () { 7 window.__defineGetter__("x", function() { return "window.x __getter__"; }); 8 } threw exception TypeError: Attempting to change configurable attribute of unconfigurable property.. 6 9 PASS window.x is 1 7 10 PASS typeof window.__lookupGetter__('x') is 'undefined' 8 11 PASS typeof Object.getOwnPropertyDescriptor(window, 'x').get is 'undefined' 9 12 13 PASS function () { 14 window.__defineSetter__("x", function() { debug("window.x __setter__ called"); }); 15 } threw exception TypeError: Attempting to change configurable attribute of unconfigurable property.. 10 16 PASS window.x is 2 11 17 PASS typeof window.__lookupGetter__('x') is 'undefined' -
trunk/LayoutTests/fast/dom/getter-on-window-object2.html
r155265 r274308 5 5 6 6 var x = 1; 7 try{7 shouldThrowErrorName(function() { 8 8 window.__defineGetter__("x", function() { return "window.x __getter__"; }); 9 } catch(e) { debug(e); }9 }, "TypeError"); 10 10 11 11 shouldBe("window.x", "1"); … … 15 15 16 16 17 try{17 shouldThrowErrorName(function() { 18 18 window.__defineSetter__("x", function() { debug("window.x __setter__ called"); }); 19 } catch(e) { debug(e); }19 }, "TypeError"); 20 20 x = 2; 21 21 -
trunk/LayoutTests/imported/w3c/ChangeLog
r274235 r274308 1 2021-03-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Align JSGlobalObject::defineOwnProperty() with the spec and other runtimes 4 https://bugs.webkit.org/show_bug.cgi?id=203456 5 6 Reviewed by Robin Morisset. 7 8 * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin-expected.txt: Added. 9 * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html: Added. 10 1 11 2021-03-10 Antoine Quint <graouts@webkit.org> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r274288 r274308 1 2021-03-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Align JSGlobalObject::defineOwnProperty() with the spec and other runtimes 4 https://bugs.webkit.org/show_bug.cgi?id=203456 5 6 Reviewed by Robin Morisset. 7 8 Per spec, top-level `var` bindings are non-configurable properties of the global 9 object [1], while `undefined` / `NaN` / `Infinity` are also non-writable [2]. 10 11 Prior to this change, redefining global `var` binding with accessor descriptor 12 failed silently (rather than throwing a TypeError); redefining with data or 13 generic descriptor created a structure property, which took precedence over 14 symbol table entry in JSGlobalObject::getOwnPropertySlot(), effectively 15 destroying live binding between `global.foo` and `var foo`. 16 17 This patch re-engineers JSGlobalObject::defineOwnProperty(), fixing both issues 18 mentioned above. If defineOwnProperty() override is removed, there is no way 19 a live binding can be maintained. 20 21 In a follow-up change, JSGlobalObject::getOwnPropertySlot() will be updated to 22 search symbol table first, aligning it with the spec [3], put(), and 23 defineOwnProperty(). Apart from consistency, this will bring a mild speed-up. 24 25 To accomodate global `var` binding reassignment right after it becomes read-only 26 (in the same scope), this patch introduces a watchpoint that can be fired by 27 JSGlobalObject::defineOwnProperty(). put_to_scope performance is neutral. 28 29 Also, this patch removes unused symbolTableGet() overload and orphaned 30 JSGlobalObject::defineGetter() / JSGlobalObject::defineSetter() declarations. 31 32 [1]: https://tc39.es/ecma262/#sec-object-environment-records-createmutablebinding-n-d 33 [2]: https://tc39.es/ecma262/#sec-value-properties-of-the-global-object 34 [3]: https://tc39.es/ecma262/#sec-global-environment-records-getbindingvalue-n-s 35 36 * dfg/DFGByteCodeParser.cpp: 37 (JSC::DFG::ByteCodeParser::needsDynamicLookup): 38 (JSC::DFG::ByteCodeParser::parseBlock): 39 * jit/JIT.cpp: 40 (JSC::JIT::emitVarReadOnlyCheck): 41 * jit/JIT.h: 42 * jit/JITPropertyAccess.cpp: 43 (JSC::JIT::emit_op_put_to_scope): 44 * jit/JITPropertyAccess32_64.cpp: 45 (JSC::JIT::emit_op_put_to_scope): 46 * llint/LowLevelInterpreter.asm: 47 * llint/LowLevelInterpreter32_64.asm: 48 * llint/LowLevelInterpreter64.asm: 49 * runtime/JSGlobalObject.cpp: 50 (JSC::JSGlobalObject::JSGlobalObject): 51 (JSC::JSGlobalObject::defineOwnProperty): 52 * runtime/JSGlobalObject.h: 53 (JSC::JSGlobalObject::varReadOnlyWatchpoint): 54 * runtime/JSSymbolTableObject.h: 55 (JSC::symbolTableGet): 56 1 57 2021-03-11 BJ Burg <bburg@apple.com> 2 58 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r274037 r274308 4216 4216 4217 4217 switch (type) { 4218 case GlobalProperty:4219 4218 case GlobalVar: 4219 case GlobalVarWithVarInjectionChecks: { 4220 if (opcode == op_put_to_scope && globalObject->varReadOnlyWatchpoint()->hasBeenInvalidated()) 4221 return true; 4222 4223 return false; 4224 } 4225 4226 case GlobalProperty: 4220 4227 case GlobalLexicalVar: 4221 4228 case ClosureVar: … … 4252 4259 4253 4260 case GlobalPropertyWithVarInjectionChecks: 4254 case GlobalVarWithVarInjectionChecks:4255 4261 case GlobalLexicalVarWithVarInjectionChecks: 4256 4262 case ClosureVarWithVarInjectionChecks: … … 7926 7932 addToGraph(CheckNotEmpty, value); 7927 7933 } 7934 if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks) 7935 m_graph.watchpoints().addLazily(globalObject->varReadOnlyWatchpoint()); 7928 7936 7929 7937 JSSegmentedVariableObject* scopeObject = jsCast<JSSegmentedVariableObject*>(JSScope::constantScopeForCodeBlock(resolveType, m_inlineStackTop->m_codeBlock)); -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r274024 r274308 116 116 { 117 117 addSlowCase(branch8(NotEqual, Address(pointerToSet, WatchpointSet::offsetOfState()), TrustedImm32(IsInvalidated))); 118 } 119 120 void JIT::emitVarReadOnlyCheck(ResolveType resolveType) 121 { 122 if (resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks) 123 addSlowCase(branch8(Equal, AbsoluteAddress(m_codeBlock->globalObject()->varReadOnlyWatchpoint()->addressOfState()), TrustedImm32(IsInvalidated))); 118 124 } 119 125 -
trunk/Source/JavaScriptCore/jit/JIT.h
r272580 r274308 753 753 void emitNewFuncExprCommon(const Instruction*); 754 754 void emitVarInjectionCheck(bool needsVarInjectionChecks); 755 void emitVarReadOnlyCheck(ResolveType); 755 756 void emitResolveClosure(VirtualRegister dst, VirtualRegister scope, bool needsVarInjectionChecks, unsigned depth); 756 757 void emitLoadWithStructureCheck(VirtualRegister scope, Structure** structureSlot); -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r272580 r274308 1228 1228 RELEASE_ASSERT(constantScope); 1229 1229 emitVarInjectionCheck(needsVarInjectionChecks(resolveType)); 1230 emitVarReadOnlyCheck(resolveType); 1230 1231 if (!isInitialization(getPutInfo.initializationMode()) && (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)) { 1231 1232 // We need to do a TDZ check here because we can't always prove we need to emit TDZ checks statically. -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r272580 r274308 1244 1244 emitWriteBarrier(constantScope, value, ShouldFilterValue); 1245 1245 emitVarInjectionCheck(needsVarInjectionChecks(resolveType)); 1246 emitVarReadOnlyCheck(resolveType); 1246 1247 if (!isInitialization(getPutInfo.initializationMode()) && (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)) { 1247 1248 // We need to do a TDZ check here because we can't always prove we need to emit TDZ checks statically. -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r272170 r274308 1342 1342 end 1343 1343 1344 macro varReadOnlyCheck(slowPath, scratch) 1345 loadp CodeBlock[cfr], scratch 1346 loadp CodeBlock::m_globalObject[scratch], scratch 1347 loadp JSGlobalObject::m_varReadOnlyWatchpoint[scratch], scratch 1348 bbeq WatchpointSet::m_state[scratch], IsInvalidated, slowPath 1349 end 1350 1344 1351 macro checkSwitchToJIT(increment, action) 1345 1352 loadp CodeBlock[cfr], t0 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r273104 r274308 2626 2626 .pGlobalVar: 2627 2627 bineq t0, GlobalVar, .pGlobalLexicalVar 2628 varReadOnlyCheck(.pDynamic, t2) 2628 2629 putGlobalVariable() 2629 2630 writeBarrierOnGlobalObject(size, get, m_value) … … 2653 2654 .pGlobalVarWithVarInjectionChecks: 2654 2655 bineq t0, GlobalVarWithVarInjectionChecks, .pGlobalLexicalVarWithVarInjectionChecks 2656 # FIXME: Avoid loading m_globalObject twice 2657 # https://bugs.webkit.org/show_bug.cgi?id=223097 2655 2658 varInjectionCheck(.pDynamic) 2659 varReadOnlyCheck(.pDynamic, t2) 2656 2660 putGlobalVariable() 2657 2661 writeBarrierOnGlobalObject(size, get, m_value) -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r272580 r274308 2728 2728 .pGlobalVar: 2729 2729 bineq t0, GlobalVar, .pGlobalLexicalVar 2730 varReadOnlyCheck(.pDynamic, t2) 2730 2731 putGlobalVariable() 2731 2732 writeBarrierOnGlobalObject(size, get, m_value) … … 2755 2756 .pGlobalVarWithVarInjectionChecks: 2756 2757 bineq t0, GlobalVarWithVarInjectionChecks, .pGlobalLexicalVarWithVarInjectionChecks 2758 # FIXME: Avoid loading m_globalObject twice 2759 # https://bugs.webkit.org/show_bug.cgi?id=223097 2757 2760 varInjectionCheck(.pDynamic, t2) 2761 varReadOnlyCheck(.pDynamic, t2) 2758 2762 putGlobalVariable() 2759 2763 writeBarrierOnGlobalObject(size, get, m_value) -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r273777 r274308 496 496 , m_havingABadTimeWatchpoint(WatchpointSet::create(IsWatched)) 497 497 , m_varInjectionWatchpoint(WatchpointSet::create(IsWatched)) 498 , m_varReadOnlyWatchpoint(WatchpointSet::create(IsWatched)) 498 499 , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0))) 499 500 , m_arrayIteratorProtocolWatchpointSet(IsWatched) … … 1481 1482 { 1482 1483 VM& vm = globalObject->vm(); 1484 auto scope = DECLARE_THROW_SCOPE(vm); 1483 1485 JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object); 1484 PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry, &vm); 1485 // silently ignore attempts to add accessors aliasing vars. 1486 if (descriptor.isAccessorDescriptor() && symbolTableGet(thisObject, propertyName, slot)) 1487 return false; 1488 slot.disallowVMEntry.reset(); 1489 return Base::defineOwnProperty(thisObject, globalObject, propertyName, descriptor, shouldThrow); 1486 1487 SymbolTableEntry entry; 1488 PropertyDescriptor currentDescriptor; 1489 if (symbolTableGet(thisObject, propertyName, entry, currentDescriptor)) { 1490 bool isExtensible = false; // ignored since current descriptor is present 1491 bool isCurrentDefined = true; 1492 bool isCompatibleDescriptor = validateAndApplyPropertyDescriptor(globalObject, nullptr, propertyName, isExtensible, descriptor, isCurrentDefined, currentDescriptor, shouldThrow); 1493 EXCEPTION_ASSERT(!!scope.exception() == !isCompatibleDescriptor); 1494 if (!isCompatibleDescriptor) 1495 return false; 1496 1497 if (descriptor.value()) { 1498 bool ignoreReadOnlyErrors = true; 1499 bool putResult = false; 1500 if (symbolTablePutTouchWatchpointSet(thisObject, globalObject, propertyName, descriptor.value(), shouldThrow, ignoreReadOnlyErrors, putResult)) 1501 ASSERT(putResult); 1502 scope.assertNoException(); 1503 } 1504 if (descriptor.writablePresent() && !descriptor.writable() && !entry.isReadOnly()) { 1505 entry.setAttributes(static_cast<unsigned>(PropertyAttribute::ReadOnly)); 1506 thisObject->symbolTable()->set(propertyName.uid(), entry); 1507 thisObject->varReadOnlyWatchpoint()->fireAll(vm, "GlobalVar was redefined as ReadOnly"); 1508 } 1509 return true; 1510 } 1511 1512 RELEASE_AND_RETURN(scope, Base::defineOwnProperty(thisObject, globalObject, propertyName, descriptor, shouldThrow)); 1490 1513 } 1491 1514 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r273661 r274308 475 475 RefPtr<WatchpointSet> m_havingABadTimeWatchpoint; 476 476 RefPtr<WatchpointSet> m_varInjectionWatchpoint; 477 RefPtr<WatchpointSet> m_varReadOnlyWatchpoint; 477 478 478 479 std::unique_ptr<JSGlobalObjectRareData> m_rareData; … … 624 625 JS_EXPORT_PRIVATE static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&); 625 626 JS_EXPORT_PRIVATE static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); 626 627 JS_EXPORT_PRIVATE static void defineGetter(JSObject*, JSGlobalObject*, PropertyName, JSObject* getterFunc, unsigned attributes);628 JS_EXPORT_PRIVATE static void defineSetter(JSObject*, JSGlobalObject*, PropertyName, JSObject* setterFunc, unsigned attributes);629 627 JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow); 630 628 … … 999 997 WatchpointSet* havingABadTimeWatchpoint() { return m_havingABadTimeWatchpoint.get(); } 1000 998 WatchpointSet* varInjectionWatchpoint() { return m_varInjectionWatchpoint.get(); } 999 WatchpointSet* varReadOnlyWatchpoint() { return m_varReadOnlyWatchpoint.get(); } 1001 1000 1002 1001 bool isHavingABadTime() const -
trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.h
r273138 r274308 100 100 template<typename SymbolTableObjectType> 101 101 inline bool symbolTableGet( 102 SymbolTableObjectType* object, PropertyName propertyName, PropertyDescriptor& descriptor)102 SymbolTableObjectType* object, PropertyName propertyName, SymbolTableEntry& entry, PropertyDescriptor& descriptor) 103 103 { 104 104 SymbolTable& symbolTable = *object->symbolTable(); … … 107 107 if (iter == symbolTable.end(locker)) 108 108 return false; 109 SymbolTableEntry::Fastentry = iter->value;109 entry = iter->value; 110 110 ASSERT(!entry.isNull()); 111 111 … … 116 116 117 117 descriptor.setDescriptor(object->variableAt(offset).get(), entry.getAttributes() | PropertyAttribute::DontDelete); 118 return true;119 }120 121 template<typename SymbolTableObjectType>122 inline bool symbolTableGet(123 SymbolTableObjectType* object, PropertyName propertyName, PropertySlot& slot,124 bool& slotIsWriteable)125 {126 SymbolTable& symbolTable = *object->symbolTable();127 ConcurrentJSLocker locker(symbolTable.m_lock);128 SymbolTable::Map::iterator iter = symbolTable.find(locker, propertyName.uid());129 if (iter == symbolTable.end(locker))130 return false;131 SymbolTableEntry::Fast entry = iter->value;132 ASSERT(!entry.isNull());133 134 ScopeOffset offset = entry.scopeOffset();135 // Defend against the inspector asking for a var after it has been optimized out.136 if (!object->isValidScopeOffset(offset))137 return false;138 139 slot.setValue(object, entry.getAttributes() | PropertyAttribute::DontDelete, object->variableAt(offset).get());140 slotIsWriteable = !entry.isReadOnly();141 118 return true; 142 119 } -
trunk/Source/WebCore/ChangeLog
r274307 r274308 1 2021-03-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Align JSGlobalObject::defineOwnProperty() with the spec and other runtimes 4 https://bugs.webkit.org/show_bug.cgi?id=203456 5 6 Reviewed by Robin Morisset. 7 8 This patch removes `location` special-casing, which a) incorrectly returned 9 `false` if new descriptor was the same as the current one and b) failed 10 silently otherwise (rather than throwing a TypeError). 11 12 However, this change introduces `window` / `document` special-casing because 13 they exist on the structure and as symbol table entries (for performance reasons). 14 Aligns WebKit with Blink and partly with Gecko. 15 16 Test: imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html 17 18 * bindings/js/JSDOMWindowCustom.cpp: 19 (WebCore::JSDOMWindow::defineOwnProperty): 20 1 21 2021-03-11 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r273901 r274308 476 476 bool JSDOMWindow::defineOwnProperty(JSC::JSObject* object, JSC::JSGlobalObject* lexicalGlobalObject, JSC::PropertyName propertyName, const JSC::PropertyDescriptor& descriptor, bool shouldThrow) 477 477 { 478 JSC::VM& vm = lexicalGlobalObject->vm();479 auto scope = DECLARE_THROW_SCOPE(vm);480 481 478 JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object); 482 479 // Only allow defining properties in this way by frames in the same origin, as it allows setters to be introduced. 483 480 if (!BindingSecurity::shouldAllowAccessToDOMWindow(lexicalGlobalObject, thisObject->wrapped(), ThrowSecurityError)) 484 RELEASE_AND_RETURN(scope, false);485 486 EXCEPTION_ASSERT(!scope.exception());487 // Don't allow shadowing location using accessor properties.488 if (descriptor.isAccessorDescriptor() && propertyName == Identifier::fromString(vm, "location"))489 481 return false; 490 482 491 RELEASE_AND_RETURN(scope, Base::defineOwnProperty(thisObject, lexicalGlobalObject, propertyName, descriptor, shouldThrow)); 483 auto& builtinNames = static_cast<JSVMClientData*>(lexicalGlobalObject->vm().clientData)->builtinNames(); 484 if (propertyName == builtinNames.documentPublicName() || propertyName == builtinNames.windowPublicName()) 485 return JSObject::defineOwnProperty(thisObject, lexicalGlobalObject, propertyName, descriptor, shouldThrow); 486 487 return Base::defineOwnProperty(thisObject, lexicalGlobalObject, propertyName, descriptor, shouldThrow); 492 488 } 493 489
Note: See TracChangeset
for help on using the changeset viewer.