WebKit Bugzilla
Attachment 372617 Details for
Bug 198805
: openDatabase should return an empty object when WebSQL is disabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198805-20190620233051.patch (text/plain), 15.34 KB, created by
Sihui Liu
on 2019-06-20 23:30:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-06-20 23:30:52 PDT
Size:
15.34 KB
patch
obsolete
>Subversion Revision: 246606 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 706050d1f84bab2bee2cce9448056e65505f1240..c310255158c38be50bdfa5f40101200cc126badc 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,14 @@ >+2019-06-20 Sihui Liu <sihui_liu@apple.com> >+ >+ openDatabase should return an empty object when WebSQL is disabled >+ https://bugs.webkit.org/show_bug.cgi?id=198805 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * runtime/JSFunction.cpp: >+ (JSC::JSFunction::createUndefinedFunction): >+ * runtime/JSFunction.h: >+ > 2019-06-19 Adrian Perez de Castro <aperez@igalia.com> > > [WPE][GTK] Fix build with unified sources disabled >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 780b85bea79ecb5372887c8d252f5775ba2df87b..9b6125df4ebb0566b60877a90d0c2692d8dcc956 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-06-20 Sihui Liu <sihui_liu@apple.com> >+ >+ openDatabase should return an empty object when WebSQL is disabled >+ https://bugs.webkit.org/show_bug.cgi?id=198805 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Some websites rely on calling openDatabase with null parameters to check for private browsing. To not break >+ those sites, we now expose openDatabase interface even if Web SQL is disabled. When Web SQL is disabled, >+ window.openDatabase returns false, but it is callable and returns empty object. >+ >+ Test: WebSQL.OpenDatabaseAlwaysExists >+ >+ * Modules/webdatabase/DOMWindowWebDatabase.idl: >+ * bindings/js/JSDOMWindowCustom.cpp: >+ (WebCore::jsDOMWindowInstanceFunctionOpenDatabaseBody): >+ (WebCore::jsDOMWindowInstanceFunctionOpenDatabase): >+ (WebCore::JSDOMWindow::openDatabase const): >+ > 2019-06-19 Adrian Perez de Castro <aperez@igalia.com> > > [WPE][GTK] Fix build with unified sources disabled >diff --git a/Source/JavaScriptCore/runtime/JSFunction.cpp b/Source/JavaScriptCore/runtime/JSFunction.cpp >index 9ab3c22c04b425a725d353764827b2b34b2ec332..a0a56072f42cd70338c209bfa28d8186b36f1b91 100644 >--- a/Source/JavaScriptCore/runtime/JSFunction.cpp >+++ b/Source/JavaScriptCore/runtime/JSFunction.cpp >@@ -99,6 +99,16 @@ JSFunction* JSFunction::create(VM& vm, JSGlobalObject* globalObject, int length, > return function; > } > >+JSFunction* JSFunction::createUndefinedFunction(VM& vm, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor, const DOMJIT::Signature* signature) >+{ >+ NativeExecutable* executable = vm.getHostFunction(nativeFunction, intrinsic, nativeConstructor, signature, name); >+ Structure* structure = Structure::create(vm, globalObject, globalObject->objectPrototype(), TypeInfo(JSFunctionType, JSFunction::StructureFlags | MasqueradesAsUndefined), JSFunction::info()); >+ globalObject->masqueradesAsUndefinedWatchpoint()->fireAll(globalObject->vm(), "Allocated masquerading object"); >+ JSFunction* function = new (NotNull, allocateCell<JSFunction>(vm.heap)) JSFunction(vm, globalObject, structure); >+ function->finishCreation(vm, executable, length, name); >+ return function; >+} >+ > JSFunction::JSFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure) > : Base(vm, globalObject, structure) > , m_executable() >diff --git a/Source/JavaScriptCore/runtime/JSFunction.h b/Source/JavaScriptCore/runtime/JSFunction.h >index 2248330d03fdfa9c527e6281200f563b72e22b12..275bf98e36684fc6179ceaafb63ff601360f4368 100644 >--- a/Source/JavaScriptCore/runtime/JSFunction.h >+++ b/Source/JavaScriptCore/runtime/JSFunction.h >@@ -80,6 +80,7 @@ public: > static Structure* selectStructureForNewFuncExp(JSGlobalObject*, FunctionExecutable*); > > JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor, const DOMJIT::Signature* = nullptr); >+ JS_EXPORT_PRIVATE static JSFunction* createUndefinedFunction(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor, const DOMJIT::Signature* = nullptr); > > static JSFunction* createWithInvalidatedReallocationWatchpoint(VM&, FunctionExecutable*, JSScope*); > >diff --git a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl >index 438a3821e130c1e02c87c08af62bf3f9017acfae..b628eeccedb902ad149f81a1d2569d13a6f39018 100644 >--- a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl >+++ b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl >@@ -24,10 +24,6 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >-[ >- EnabledAtRuntime=WebSQL, >- EnabledByQuirk=hasWebSQLSupport, >-] > partial interface DOMWindow { >- [MayThrowException] Database? openDatabase(DOMString name, DOMString version, DOMString displayName, unsigned long estimatedSize, optional DatabaseCallback? creationCallback); >+ [CustomGetter] readonly attribute any openDatabase; > }; >diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >index d10310ab6c89aa2a4b9a4a7017767d500cd4868f..c46532c1ed025ce99928d628b076e8097a30da31 100644 >--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp >@@ -22,6 +22,7 @@ > #include "JSDOMWindowCustom.h" > > #include "DOMWindowIndexedDatabase.h" >+#include "DOMWindowWebDatabase.h" > #include "Frame.h" > #include "HTMLCollection.h" > #include "HTMLDocument.h" >@@ -31,6 +32,8 @@ > #include "JSDOMConvertNullable.h" > #include "JSDOMConvertNumbers.h" > #include "JSDOMConvertStrings.h" >+#include "JSDatabase.h" >+#include "JSDatabaseCallback.h" > #include "JSEvent.h" > #include "JSEventListener.h" > #include "JSHTMLAudioElement.h" >@@ -48,8 +51,10 @@ > #include <JavaScriptCore/BuiltinNames.h> > #include <JavaScriptCore/HeapSnapshotBuilder.h> > #include <JavaScriptCore/JSCInlines.h> >+#include <JavaScriptCore/JSFunction.h> > #include <JavaScriptCore/JSMicrotask.h> > #include <JavaScriptCore/Lookup.h> >+#include <JavaScriptCore/Structure.h> > > #if ENABLE(USER_MESSAGE_HANDLERS) > #include "JSWebKitNamespace.h" >@@ -60,6 +65,7 @@ namespace WebCore { > using namespace JSC; > > EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionShowModalDialog(ExecState*); >+EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionOpenDatabase(ExecState*); > > void JSDOMWindow::visitAdditionalChildren(SlotVisitor& visitor) > { >@@ -564,4 +570,51 @@ JSValue JSDOMWindow::frames(JSC::ExecState&) const > return globalThis(); > } > >+static inline JSC::EncodedJSValue jsDOMWindowInstanceFunctionOpenDatabaseBody(JSC::ExecState* state, typename IDLOperation<JSDOMWindow>::ClassParameter castedThis, JSC::ThrowScope& throwScope) >+{ >+ if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, castedThis->wrapped(), ThrowSecurityError)) >+ return JSValue::encode(jsUndefined()); >+ auto& impl = castedThis->wrapped(); >+ if (UNLIKELY(state->argumentCount() < 4)) >+ return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); >+ auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); >+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); >+ auto version = convert<IDLDOMString>(*state, state->uncheckedArgument(1)); >+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); >+ auto displayName = convert<IDLDOMString>(*state, state->uncheckedArgument(2)); >+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); >+ auto estimatedSize = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(3)); >+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); >+ >+ if (!RuntimeEnabledFeatures::sharedFeatures().webSQLEnabled()) { >+ if (name != "null" || version != "null" || displayName != "null" || estimatedSize) >+ propagateException(*state, throwScope, Exception(UnknownError, "Web SQL is deprecated"_s)); >+ return JSValue::encode(constructEmptyObject(state, castedThis->globalObject()->objectPrototype())); >+ } >+ >+ auto creationCallback = convert<IDLNullable<IDLCallbackFunction<JSDatabaseCallback>>>(*state, state->argument(4), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { >+ throwArgumentMustBeFunctionError(state, scope, 4, "creationCallback", "Window", "openDatabase"); >+ }); >+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); >+ return JSValue::encode(toJS<IDLNullable<IDLInterface<Database>>>(*state, *castedThis->globalObject(), throwScope, WebCore::DOMWindowWebDatabase::openDatabase(impl, WTFMove(name), WTFMove(version), WTFMove(displayName), WTFMove(estimatedSize), WTFMove(creationCallback)))); >+} >+ >+EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionOpenDatabase(ExecState* state) >+{ >+ return IDLOperation<JSDOMWindow>::call<jsDOMWindowInstanceFunctionOpenDatabaseBody>(*state, "openDatabase"); >+} >+ >+JSValue JSDOMWindow::openDatabase(JSC::ExecState& state) const >+{ >+ VM& vm = state.vm(); >+ StringImpl* name = PropertyName(static_cast<JSVMClientData*>(vm.clientData)->builtinNames().openDatabasePublicName()).publicName(); >+ if (!name) >+ name = vm.propertyNames->anonymous.impl(); >+ >+ if (RuntimeEnabledFeatures::sharedFeatures().webSQLEnabled()) >+ return JSFunction::create(vm, state.lexicalGlobalObject(), 4, name, jsDOMWindowInstanceFunctionOpenDatabase, NoIntrinsic); >+ >+ return JSFunction::createUndefinedFunction(vm, state.lexicalGlobalObject(), 4, name, jsDOMWindowInstanceFunctionOpenDatabase, NoIntrinsic); >+} >+ > } // namespace WebCore >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index db4c9d448476f0ff9843f2e091d669fc4af0a2ed..d435f9f84b6ec2004103a9ecafd48f5cfc2e5be6 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,12 @@ >+2019-06-20 Sihui Liu <sihui_liu@apple.com> >+ >+ openDatabase should return an empty object when WebSQL is disabled >+ https://bugs.webkit.org/show_bug.cgi?id=198805 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ > 2019-06-19 Alex Christensen <achristensen@webkit.org> > > Add a unit test for client certificate authentication >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 916186310cd1bd845ef537b10474d4967d07ff1f..76058fd2a785340c51a64a2671ba9756bc3baa86 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -643,6 +643,8 @@ > 8E4A85371E1D1AB200F53B0F /* GridPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */; }; > 930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; }; > 9310CD381EF708FB0050FFE0 /* Function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9310CD361EF708FB0050FFE0 /* Function.cpp */; }; >+ 931C281D22BC55F2001D98C4 /* WebSQLBasics.mm in Sources */ = {isa = PBXBuildFile; fileRef = 931C281C22BC55A7001D98C4 /* WebSQLBasics.mm */; }; >+ 931C281E22BC579A001D98C4 /* opendatabase-always-exists.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 931C281B22BC5583001D98C4 /* opendatabase-always-exists.html */; }; > 9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */; }; > 932AE53D1D371047005DFFAF /* focus-inputs.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93575C551D30366E000D604D /* focus-inputs.html */; }; > 933D631D1FCB76200032ECD6 /* Hasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933D631B1FCB76180032ECD6 /* Hasher.cpp */; }; >@@ -1281,6 +1283,7 @@ > CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */, > 7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */, > 468BC45522653A1000A36C96 /* open-window-then-write-to-it.html in Copy Resources */, >+ 931C281E22BC579A001D98C4 /* opendatabase-always-exists.html in Copy Resources */, > 290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */, > 83148B09202AC78D00BADE99 /* override-builtins-test.html in Copy Resources */, > CEBCA1391E3A807A00C73293 /* page-with-csp-iframe.html in Copy Resources */, >@@ -1921,6 +1924,8 @@ > 8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridPosition.cpp; sourceTree = "<group>"; }; > 930AD401150698B30067970F /* lots-of-text.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-text.html"; sourceTree = "<group>"; }; > 9310CD361EF708FB0050FFE0 /* Function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Function.cpp; sourceTree = "<group>"; }; >+ 931C281B22BC5583001D98C4 /* opendatabase-always-exists.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "opendatabase-always-exists.html"; sourceTree = "<group>"; }; >+ 931C281C22BC55A7001D98C4 /* WebSQLBasics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSQLBasics.mm; sourceTree = "<group>"; }; > 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBreakIterator.cpp; sourceTree = "<group>"; }; > 9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = "<group>"; }; > 933D631B1FCB76180032ECD6 /* Hasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Hasher.cpp; sourceTree = "<group>"; }; >@@ -2761,6 +2766,7 @@ > C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */, > 5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */, > 5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */, >+ 931C281C22BC55A7001D98C4 /* WebSQLBasics.mm */, > 2E5C77061FA70136005932C3 /* WKAttachmentTests.mm */, > 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */, > 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */, >@@ -3121,6 +3127,7 @@ > CDB5DFFE21360ED800D3E189 /* now-playing.html */, > 93E2D2751ED7D51700FA76F6 /* offscreen-iframe-of-media-document.html */, > 7CCB99221D3B44E7003922F6 /* open-multiple-external-url.html */, >+ 931C281B22BC5583001D98C4 /* opendatabase-always-exists.html */, > CEBCA1341E3A803400C73293 /* page-with-csp-iframe.html */, > CEBCA1351E3A803400C73293 /* page-with-csp.html */, > CEBCA1361E3A803400C73293 /* page-without-csp-iframe.html */, >@@ -4521,6 +4528,7 @@ > 536770341CC8022800D425B1 /* WebScriptObjectDescription.mm in Sources */, > 5120C83D1E6751290025B250 /* WebsiteDataStoreCustomPaths.mm in Sources */, > 5C9E56851DF9145400C9EE33 /* WebsitePolicies.mm in Sources */, >+ 931C281D22BC55F2001D98C4 /* WebSQLBasics.mm in Sources */, > 7CCE7ED41A411A7E00447C4C /* WebViewCanPasteURL.mm in Sources */, > 5C0BF8911DD599A900B00328 /* WebViewCanPasteZeroPng.mm in Sources */, > 7C83E0421D0A63FD00FEBCF3 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198805
:
371987
|
372617
|
372638
|
372641
|
372648
|
372650
|
372653
|
372654
|
372655
|
372673