Changeset 87826 in webkit
- Timestamp:
- Jun 1, 2011 11:08:07 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87822 r87826 1 2011-05-31 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Freezing a function and its prototype causes browser to crash. 6 https://bugs.webkit.org/show_bug.cgi?id=61758 7 8 Add test to ensure correct behaviour 9 10 * fast/js/preventExtensions-expected.txt: 11 * fast/js/script-tests/preventExtensions.js: 12 (f): 13 1 14 2011-05-19 Adrienne Walker <enne@google.com> 2 15 -
trunk/LayoutTests/fast/js/preventExtensions-expected.txt
r80378 r87826 4 4 5 5 6 PASS (new inextensible).prototypeExists is true 7 PASS (new sealed).prototypeExists is true 8 PASS (new frozen).prototypeExists is true 6 9 PASS test(obj()) is "(b:4)(c:3)E" 7 10 PASS test(preventExtensions(obj())) is "(b:4)" -
trunk/LayoutTests/fast/js/script-tests/preventExtensions.js
r80378 r87826 44 44 } 45 45 46 function inextensible(){} 47 function sealed(){} 48 function frozen(){}; 49 preventExtensions(inextensible); 50 seal(sealed); 51 freeze(frozen); 52 new inextensible; 53 new sealed; 54 new frozen; 55 inextensible.prototype.prototypeExists = true; 56 sealed.prototype.prototypeExists = true; 57 frozen.prototype.prototypeExists = true; 58 59 shouldBeTrue("(new inextensible).prototypeExists"); 60 shouldBeTrue("(new sealed).prototypeExists"); 61 shouldBeTrue("(new frozen).prototypeExists"); 62 46 63 shouldBe('test(obj())', '"(b:4)(c:3)E"'); // extensible, can delete a, can modify b, and can add c 47 64 shouldBe('test(preventExtensions(obj()))', '"(b:4)"'); // <nothing>, can delete a, can modify b, and CANNOT add c -
trunk/Source/JavaScriptCore/ChangeLog
r87799 r87826 1 2011-05-31 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Freezing a function and its prototype causes browser to crash. 6 https://bugs.webkit.org/show_bug.cgi?id=61758 7 8 Make JSObject::preventExtensions virtual so that we can override it 9 and instantiate all lazy 10 11 * JavaScriptCore.exp: 12 * runtime/JSFunction.cpp: 13 (JSC::createPrototypeProperty): 14 (JSC::JSFunction::preventExtensions): 15 (JSC::JSFunction::getOwnPropertySlot): 16 * runtime/JSFunction.h: 17 * runtime/JSObject.h: 18 * runtime/JSObject.cpp: 19 (JSC::JSObject::seal): 20 (JSC::JSObject::seal): 21 1 22 2011-06-01 Sheriff Bot <webkit.review.bot@gmail.com> 2 23 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r87653 r87826 299 299 __ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE 300 300 __ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb 301 __ZN3JSC8JSObject17preventExtensionsERNS_12JSGlobalDataE 301 302 __ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_10JSFunctionEj 302 303 __ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r87653 r87826 256 256 ?objectProtoFuncToString@JSC@@YI_JPAVExecState@1@@Z 257 257 ?parseDateFromNullTerminatedCharacters@WTF@@YANPBD@Z 258 ?preventExtensions@JSObject@JSC@@UAEXAAVJSGlobalData@2@@Z 258 259 ?profiler@Profiler@JSC@@SAPAV12@XZ 259 260 ?protect@Heap@JSC@@QAEXVJSValue@2@@Z -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r86510 r87826 178 178 } 179 179 180 static inline WriteBarrierBase<Unknown>* createPrototypeProperty(JSGlobalData& globalData, JSGlobalObject* globalObject, JSFunction* function) 181 { 182 ExecState* exec = globalObject->globalExec(); 183 if (WriteBarrierBase<Unknown>* location = function->getDirectLocation(globalData, exec->propertyNames().prototype)) 184 return location; 185 JSObject* prototype = constructEmptyObject(exec, globalObject->emptyObjectStructure()); 186 prototype->putDirect(globalData, exec->propertyNames().constructor, function, DontEnum); 187 function->putDirect(globalData, exec->propertyNames().prototype, prototype, DontDelete | DontEnum); 188 return function->getDirectLocation(exec->globalData(), exec->propertyNames().prototype); 189 } 190 191 void JSFunction::preventExtensions(JSGlobalData& globalData) 192 { 193 createPrototypeProperty(globalData, scope()->globalObject.get(), this); 194 JSObject::preventExtensions(globalData); 195 } 196 180 197 bool JSFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 181 198 { … … 186 203 WriteBarrierBase<Unknown>* location = getDirectLocation(exec->globalData(), propertyName); 187 204 188 if (!location) { 189 JSObject* prototype = constructEmptyObject(exec, scope()->globalObject->emptyObjectStructure()); 190 prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, this, DontEnum); 191 putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum); 192 location = getDirectLocation(exec->globalData(), propertyName); 193 } 205 if (!location) 206 location = createPrototypeProperty(exec->globalData(), scope()->globalObject.get(), this); 194 207 195 208 slot.setValue(this, location->get(), offsetForLocation(location)); -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r84556 r87826 92 92 bool isHostFunctionNonInline() const; 93 93 94 virtual void preventExtensions(JSGlobalData&); 94 95 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 95 96 virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r86499 r87826 510 510 void JSObject::seal(JSGlobalData& globalData) 511 511 { 512 if (isSealed(globalData)) 513 return; 514 preventExtensions(globalData); 512 515 setStructure(globalData, Structure::sealTransition(globalData, m_structure.get())); 513 516 } … … 515 518 void JSObject::freeze(JSGlobalData& globalData) 516 519 { 520 if (isFrozen(globalData)) 521 return; 522 preventExtensions(globalData); 517 523 setStructure(globalData, Structure::freezeTransition(globalData, m_structure.get())); 518 524 } -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r87527 r87826 212 212 void seal(JSGlobalData&); 213 213 void freeze(JSGlobalData&); 214 v oid preventExtensions(JSGlobalData&);214 virtual void preventExtensions(JSGlobalData&); 215 215 bool isSealed(JSGlobalData& globalData) { return m_structure->isSealed(globalData); } 216 216 bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); }
Note: See TracChangeset
for help on using the changeset viewer.