Changeset 199017 in webkit
- Timestamp:
- Apr 4, 2016 1:01:38 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199013 r199017 1 2016-04-04 Chris Dumez <cdumez@apple.com> 2 3 Regression(r196145): Crash in getOwnPropertyDescriptor on http://www.history.com/shows/vikings 4 https://bugs.webkit.org/show_bug.cgi?id=156136 5 <rdar://problem/25410767> 6 7 Reviewed by Ryosuke Niwa. 8 9 Add a layout test to confirm that calling Object.getOwnPropertyDescriptor(window, "indexedDB") 10 does not crash and works as expected. 11 12 * storage/indexeddb/indexeddb-getownpropertyDescriptor-expected.txt: Added. 13 * storage/indexeddb/indexeddb-getownpropertyDescriptor.html: Added. 14 1 15 2016-04-04 Ryan Haddad <ryanhaddad@apple.com> 2 16 -
trunk/Source/JavaScriptCore/ChangeLog
r199016 r199017 1 2016-04-04 Chris Dumez <cdumez@apple.com> 2 3 Regression(r196145): Crash in getOwnPropertyDescriptor on http://www.history.com/shows/vikings 4 https://bugs.webkit.org/show_bug.cgi?id=156136 5 <rdar://problem/25410767> 6 7 Reviewed by Ryosuke Niwa. 8 9 Add a few more identifiers for using in the generated bindings. 10 11 * runtime/CommonIdentifiers.h: 12 1 13 2016-04-04 Geoffrey Garen <ggaren@apple.com> 2 14 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r198981 r199017 29 29 // ways without repeating the list. 30 30 #define JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ 31 macro(AnimationTimeline) \ 31 32 macro(Array) \ 32 33 macro(ArrayBuffer) \ 33 34 macro(ArrayIterator) \ 35 macro(Audio) \ 34 36 macro(BYTES_PER_ELEMENT) \ 35 37 macro(Boolean) \ … … 37 39 macro(Date) \ 38 40 macro(DateTimeFormat) \ 41 macro(DocumentTimeline) \ 39 42 macro(Error) \ 40 43 macro(EvalError) \ 41 44 macro(Function) \ 45 macro(Gamepad) \ 46 macro(GamepadButton) \ 47 macro(GamepadEvent) \ 42 48 macro(GeneratorFunction) \ 49 macro(HTMLAudioElement) \ 50 macro(HTMLSlotElement) \ 51 macro(IDBCursor) \ 52 macro(IDBCursorWithValue) \ 53 macro(IDBDatabase) \ 54 macro(IDBFactory) \ 55 macro(IDBIndex) \ 56 macro(IDBKeyRange) \ 57 macro(IDBObjectStore) \ 58 macro(IDBOpenDBRequest) \ 59 macro(IDBRequest) \ 60 macro(IDBTransaction) \ 61 macro(IDBVersionChangeEvent) \ 43 62 macro(Infinity) \ 44 63 macro(Intl) \ … … 60 79 macro(Set)\ 61 80 macro(SetIterator)\ 81 macro(ShadowRoot) \ 62 82 macro(String) \ 63 83 macro(Symbol) \ … … 68 88 macro(WeakMap)\ 69 89 macro(WeakSet)\ 90 macro(WebSocket) \ 70 91 macro(__defineGetter__) \ 71 92 macro(__defineSetter__) \ … … 219 240 macro(values) \ 220 241 macro(webkit) \ 242 macro(webkitIDBCursor) \ 243 macro(webkitIDBDatabase) \ 244 macro(webkitIDBFactory) \ 245 macro(webkitIDBIndex) \ 246 macro(webkitIDBKeyRange) \ 247 macro(webkitIDBObjectStore) \ 248 macro(webkitIDBRequest) \ 249 macro(webkitIDBTransaction) \ 221 250 macro(webkitIndexedDB) \ 222 251 macro(weekday) \ -
trunk/Source/WebCore/ChangeLog
r199015 r199017 1 2016-04-04 Chris Dumez <cdumez@apple.com> 2 3 Regression(r196145): Crash in getOwnPropertyDescriptor on http://www.history.com/shows/vikings 4 https://bugs.webkit.org/show_bug.cgi?id=156136 5 <rdar://problem/25410767> 6 7 Reviewed by Ryosuke Niwa. 8 9 The page was crashing when doing the following: 10 Object.getOwnPropertyDescriptor(window, "indexedDB") 11 12 getOwnPropertyDescriptor() expected getDirect() to return a CustomGetterSetter for 13 CustomAccessors but it was not the case for window.indexedDB. The reason was that 14 window.indexedDB was a special property, which is not part of the static table but 15 returned by GetOwnPropertySlot() if IndexedDB feature is enabled. This weirdness 16 was due to our bindings generator not having proper support for [EnabledAtRuntime] 17 properties on Window. 18 19 This patch adds support for [EnabledAtRuntime] properties on Window by omitting 20 these properties from the static property table and then setting them at runtime 21 in JSDOMWindow::finishCreation() if the corresponding feature is enabled. 22 window.indexedDB now looks like a regular property when IndexedDB is enabled 23 and getOwnPropertyDescriptor() works as expected for this property. 24 25 Test: storage/indexeddb/indexeddb-getownpropertyDescriptor.html 26 27 * Modules/indexeddb/DOMWindowIndexedDatabase.cpp: 28 (WebCore::DOMWindowIndexedDatabase::indexedDB): 29 * Modules/indexeddb/DOMWindowIndexedDatabase.h: 30 The generated bindings pass DOMWindow by reference instead of pointer so update 31 the implementation accordingly. 32 33 * Modules/indexeddb/DOMWindowIndexedDatabase.idl: 34 Add 'indexedDB' and 'webkitIndexedDB' properties and mark them as 35 [EnabledAtRuntime]. Now that the bindings generator correctly handles 36 [EnabledAtRuntime] properties on the Window, there is no need to 37 custom-handle them in JSDOMWindowCustom. 38 39 * bindings/js/JSDOMWindowCustom.cpp: 40 Drop custom handling for 'indexedDB' and 'webkitIndexedDB' properties 41 in getOwnPropertySlot(). The generated bindings code now makes sure to 42 only set those properties on the Window if IndexedDB is enabled so we 43 can let the regular code path look up those properties. 44 45 * bindings/scripts/CodeGeneratorJS.pm: 46 (GetJSCAttributesForAttribute): 47 (GenerateHeader): 48 (GeneratePropertiesHashTable): 49 (GenerateImplementation): 50 Add support for [EnabledAtRuntime] properties on DOMWindow. For such 51 properties, we do the following: 52 1. Omit them from the static property table 53 2. In JSDOMWindow::finishCreation(), dynamically add those properties 54 at runtime if the corresponding feature is enabled. 55 56 Note that this works for constructors as well. 57 58 * inspector/InspectorIndexedDBAgent.cpp: 59 (WebCore::assertIDBFactory): 60 Pass Window by reference instead of pointer. 61 1 62 2016-04-04 Myles C. Maxfield <mmaxfield@apple.com> 2 63 -
trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
r198762 r199017 94 94 } 95 95 96 IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow *window)96 IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow& window) 97 97 { 98 return from( window)->indexedDB();98 return from(&window)->indexedDB(); 99 99 } 100 100 -
trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h
r197563 r199017 45 45 static DOMWindowIndexedDatabase* from(DOMWindow*); 46 46 47 static IDBFactory* indexedDB(DOMWindow *);47 static IDBFactory* indexedDB(DOMWindow&); 48 48 49 49 void disconnectFrameForDocumentSuspension() override; -
trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.idl
r185322 r199017 28 28 Conditional=INDEXED_DATABASE, 29 29 ] partial interface DOMWindow { 30 // This space is intentionally left blank. 30 [EnabledAtRuntime=IndexedDB] readonly attribute IDBFactory indexedDB; 31 [EnabledAtRuntime=IndexedDB, ImplementedAs=indexedDB] readonly attribute IDBFactory webkitIndexedDB; 31 32 }; 32 33 -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r198023 r199017 77 77 #endif 78 78 79 #if ENABLE(INDEXED_DATABASE)80 static EncodedJSValue jsDOMWindowIndexedDB(ExecState* exec, EncodedJSValue thisValue, PropertyName)81 {82 UNUSED_PARAM(exec);83 auto* castedThis = toJSDOMWindow(JSValue::decode(thisValue));84 if (!RuntimeEnabledFeatures::sharedFeatures().indexedDBEnabled())85 return JSValue::encode(jsUndefined());86 if (!castedThis || !BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->wrapped()))87 return JSValue::encode(jsUndefined());88 auto& impl = castedThis->wrapped();89 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(DOMWindowIndexedDatabase::indexedDB(&impl)));90 return JSValue::encode(result);91 }92 #endif93 94 79 static bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMWindow* thisObject, Frame* frame, ExecState* exec, PropertyName propertyName, PropertySlot& slot, String& errorMessage) 95 80 { … … 288 273 return true; 289 274 290 #if ENABLE(INDEXED_DATABASE)291 // FIXME: With generated JS bindings built on static property tables there is no way to292 // completely remove a generated property at runtime. So to completely disable IndexedDB293 // at runtime we have to not generate these accessors and have to handle them specially here.294 // Once https://webkit.org/b/145669 is resolved, they can once again be auto generated.295 if (RuntimeEnabledFeatures::sharedFeatures().indexedDBEnabled() && (propertyName == exec->propertyNames().indexedDB || propertyName == exec->propertyNames().webkitIndexedDB)) {296 slot.setCustom(thisObject, DontDelete | ReadOnly | CustomAccessor, jsDOMWindowIndexedDB);297 return true;298 }299 #endif300 275 #if ENABLE(USER_MESSAGE_HANDLERS) 301 276 if (propertyName == exec->propertyNames().webkit && thisObject->wrapped().shouldHaveWebKitNamespaceForWorld(thisObject->world())) { -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r199012 r199017 732 732 733 733 return 0; 734 } 735 736 sub GetJSCAttributesForAttribute 737 { 738 my $interface = shift; 739 my $attribute = shift; 740 741 my @specials = (); 742 push(@specials, "DontDelete") if IsUnforgeable($interface, $attribute); 743 744 # As per Web IDL specification, constructor properties on the ECMAScript global object should not be enumerable. 745 my $is_global_constructor = $attribute->signature->type =~ /Constructor$/; 746 push(@specials, "DontEnum") if ($attribute->signature->extendedAttributes->{"NotEnumerable"} || $is_global_constructor); 747 push(@specials, "ReadOnly") if IsReadonly($attribute); 748 push(@specials, "CustomAccessor") unless $is_global_constructor or IsJSBuiltin($interface, $attribute); 749 push(@specials, "Accessor | Builtin") if IsJSBuiltin($interface, $attribute); 750 return (@specials > 0) ? join(" | ", @specials) : "0"; 734 751 } 735 752 … … 1231 1248 if ($interfaceName eq "DOMWindow") { 1232 1249 push(@headerContent, " $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&, JSDOMWindowShell*);\n"); 1250 push(@headerContent, " void finishCreation(JSC::VM&, JSDOMWindowShell*);\n"); 1233 1251 } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) { 1234 1252 push(@headerContent, " $className(JSC::VM&, JSC::Structure*, Ref<$implType>&&);\n"); … … 1393 1411 next if ($attribute->isStatic); 1394 1412 next if AttributeShouldBeOnInstance($interface, $attribute) != $isInstance; 1413 1414 # DOMWindow adds RuntimeEnabled attributes after creation so do not add them to the static table. 1415 if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) { 1416 $propertyCount -= 1; 1417 next; 1418 } 1419 1395 1420 my $name = $attribute->signature->name; 1396 1421 push(@$hashKeys, $name); 1397 1422 1398 my @specials = (); 1399 push(@specials, "DontDelete") if IsUnforgeable($interface, $attribute); 1400 1401 # As per Web IDL specification, constructor properties on the ECMAScript global object should not be enumerable. 1402 my $is_global_constructor = $attribute->signature->type =~ /Constructor$/; 1403 push(@specials, "DontEnum") if ($attribute->signature->extendedAttributes->{"NotEnumerable"} || $is_global_constructor); 1404 push(@specials, "ReadOnly") if IsReadonly($attribute); 1405 push(@specials, "CustomAccessor") unless $is_global_constructor or IsJSBuiltin($interface, $attribute); 1406 push(@specials, "Accessor | Builtin") if IsJSBuiltin($interface, $attribute); 1407 my $special = (@specials > 0) ? join(" | ", @specials) : "0"; 1423 my $special = GetJSCAttributesForAttribute($interface, $attribute); 1408 1424 push(@$hashSpecials, $special); 1409 1425 … … 2175 2191 push(@implContent, " : $parentClassName(vm, structure, WTFMove(impl), shell)\n"); 2176 2192 push(@implContent, "{\n"); 2193 push(@implContent, "}\n\n"); 2194 2195 push(@implContent, "void ${className}::finishCreation(VM& vm, JSDOMWindowShell* shell)\n"); 2196 push(@implContent, "{\n"); 2197 push(@implContent, " Base::finishCreation(vm, shell);\n\n"); 2198 # Support for RuntimeEnabled attributes on DOMWindow. 2199 foreach my $attribute (@{$interface->attributes}) { 2200 next unless $attribute->signature->extendedAttributes->{"EnabledAtRuntime"}; 2201 2202 AddToImplIncludes("RuntimeEnabledFeatures.h"); 2203 my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); 2204 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; 2205 my $enable_function = GetRuntimeEnableFunctionName($attribute->signature); 2206 my $attributeName = $attribute->signature->name; 2207 push(@implContent, " if (${enable_function}()) {\n"); 2208 my $getter = GetAttributeGetterName($interfaceName, $className, $interface, $attribute); 2209 my $setter = IsReadonly($attribute) ? "nullptr" : GetAttributeSetterName($interfaceName, $className, $interface, $attribute); 2210 push(@implContent, " auto* customGetterSetter = CustomGetterSetter::create(vm, $getter, $setter);\n"); 2211 my $jscAttributes = GetJSCAttributesForAttribute($interface, $attribute); 2212 push(@implContent, " putDirectCustomAccessor(vm, vm.propertyNames->$attributeName, customGetterSetter, attributesForStructure($jscAttributes));\n"); 2213 push(@implContent, " }\n"); 2214 push(@implContent, "#endif\n") if $conditionalString; 2215 } 2177 2216 push(@implContent, "}\n\n"); 2178 2217 } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) { … … 2359 2398 # Global constructors can be disabled at runtime. 2360 2399 if ($attribute->signature->type =~ /Constructor$/) { 2361 if ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) { 2362 AddToImplIncludes("RuntimeEnabledFeatures.h"); 2363 my $enable_function = GetRuntimeEnableFunctionName($attribute->signature); 2364 push(@implContent, " if (!${enable_function}())\n"); 2365 push(@implContent, " return JSValue::encode(jsUndefined());\n"); 2366 } elsif ($attribute->signature->extendedAttributes->{"EnabledBySetting"}) { 2400 if ($attribute->signature->extendedAttributes->{"EnabledBySetting"}) { 2367 2401 AddToImplIncludes("Frame.h"); 2368 2402 AddToImplIncludes("Settings.h"); -
trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
r198762 r199017 498 498 } 499 499 500 IDBFactory* idbFactory = DOMWindowIndexedDatabase::indexedDB( domWindow);500 IDBFactory* idbFactory = DOMWindowIndexedDatabase::indexedDB(*domWindow); 501 501 if (!idbFactory) 502 502 errorString = ASCIILiteral("No IndexedDB factory for given frame found");
Note: See TracChangeset
for help on using the changeset viewer.