Title: [246707] trunk
Revision
246707
Author
[email protected]
Date
2019-06-21 22:50:02 -0700 (Fri, 21 Jun 2019)

Log Message

openDatabase should return an empty object when WebSQL is disabled
https://bugs.webkit.org/show_bug.cgi?id=198805

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* runtime/JSFunction.cpp:
(JSC::JSFunction::createFunctionThatMasqueradesAsUndefined):
* runtime/JSFunction.h:

Source/WebCore:

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::IDLOperation<JSDOMWindow>::cast):
(WebCore::jsDOMWindowInstanceFunctionOpenDatabase):
(WebCore::JSDOMWindow::openDatabase const):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm: Added.
(-[WebSQLBasicsMessageHandler userContentController:didReceiveScriptMessage:]):
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html: Added.

LayoutTests:

Modify test expectation as openDatabase is not a function but an attribute of window now.

* js/dom/global-function-resolve-expected.txt:
* js/dom/script-tests/global-function-resolve.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246706 => 246707)


--- trunk/LayoutTests/ChangeLog	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/LayoutTests/ChangeLog	2019-06-22 05:50:02 UTC (rev 246707)
@@ -1,3 +1,15 @@
+2019-06-21  Sihui Liu  <[email protected]>
+
+        openDatabase should return an empty object when WebSQL is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=198805
+
+        Reviewed by Geoffrey Garen.
+
+        Modify test expectation as openDatabase is not a function but an attribute of window now.
+
+        * js/dom/global-function-resolve-expected.txt:
+        * js/dom/script-tests/global-function-resolve.js:
+
 2019-06-21  Saam Barati  <[email protected]>
 
         [WHLSL] Code that accesses an undefined variable crashes

Modified: trunk/LayoutTests/js/dom/global-function-resolve-expected.txt (246706 => 246707)


--- trunk/LayoutTests/js/dom/global-function-resolve-expected.txt	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/LayoutTests/js/dom/global-function-resolve-expected.txt	2019-06-22 05:50:02 UTC (rev 246707)
@@ -61,62 +61,60 @@
 PASS cachedFunctions[27]() is navigator
 PASS cachedFunctions[28]() is open
 PASS cachedFunctions[28]() is open
-PASS cachedFunctions[29]() is openDatabase
-PASS cachedFunctions[29]() is openDatabase
-PASS cachedFunctions[30]() is opener
-PASS cachedFunctions[30]() is opener
-PASS cachedFunctions[31]() is outerHeight
-PASS cachedFunctions[31]() is outerHeight
-PASS cachedFunctions[32]() is outerWidth
-PASS cachedFunctions[32]() is outerWidth
-PASS cachedFunctions[33]() is pageXOffset
-PASS cachedFunctions[33]() is pageXOffset
-PASS cachedFunctions[34]() is pageYOffset
-PASS cachedFunctions[34]() is pageYOffset
-PASS cachedFunctions[35]() is parent
-PASS cachedFunctions[35]() is parent
-PASS cachedFunctions[36]() is prompt
-PASS cachedFunctions[36]() is prompt
-PASS cachedFunctions[37]() is releaseEvents
-PASS cachedFunctions[37]() is releaseEvents
-PASS cachedFunctions[38]() is removeEventListener
-PASS cachedFunctions[38]() is removeEventListener
-PASS cachedFunctions[39]() is resizeBy
-PASS cachedFunctions[39]() is resizeBy
-PASS cachedFunctions[40]() is resizeTo
-PASS cachedFunctions[40]() is resizeTo
-PASS cachedFunctions[41]() is screen
-PASS cachedFunctions[41]() is screen
-PASS cachedFunctions[42]() is screenLeft
-PASS cachedFunctions[42]() is screenLeft
-PASS cachedFunctions[43]() is screenTop
-PASS cachedFunctions[43]() is screenTop
-PASS cachedFunctions[44]() is screenX
-PASS cachedFunctions[44]() is screenX
-PASS cachedFunctions[45]() is screenY
-PASS cachedFunctions[45]() is screenY
-PASS cachedFunctions[46]() is scroll
-PASS cachedFunctions[46]() is scroll
-PASS cachedFunctions[47]() is scrollBy
-PASS cachedFunctions[47]() is scrollBy
-PASS cachedFunctions[48]() is scrollTo
-PASS cachedFunctions[48]() is scrollTo
-PASS cachedFunctions[49]() is scrollX
-PASS cachedFunctions[49]() is scrollX
-PASS cachedFunctions[50]() is scrollY
-PASS cachedFunctions[50]() is scrollY
-PASS cachedFunctions[51]() is setInterval
-PASS cachedFunctions[51]() is setInterval
-PASS cachedFunctions[52]() is setTimeout
-PASS cachedFunctions[52]() is setTimeout
-PASS cachedFunctions[53]() is showModalDialog
-PASS cachedFunctions[53]() is showModalDialog
-PASS cachedFunctions[54]() is status
-PASS cachedFunctions[54]() is status
-PASS cachedFunctions[55]() is stop
-PASS cachedFunctions[55]() is stop
-PASS cachedFunctions[56]() is window
-PASS cachedFunctions[56]() is window
+PASS cachedFunctions[29]() is opener
+PASS cachedFunctions[29]() is opener
+PASS cachedFunctions[30]() is outerHeight
+PASS cachedFunctions[30]() is outerHeight
+PASS cachedFunctions[31]() is outerWidth
+PASS cachedFunctions[31]() is outerWidth
+PASS cachedFunctions[32]() is pageXOffset
+PASS cachedFunctions[32]() is pageXOffset
+PASS cachedFunctions[33]() is pageYOffset
+PASS cachedFunctions[33]() is pageYOffset
+PASS cachedFunctions[34]() is parent
+PASS cachedFunctions[34]() is parent
+PASS cachedFunctions[35]() is prompt
+PASS cachedFunctions[35]() is prompt
+PASS cachedFunctions[36]() is releaseEvents
+PASS cachedFunctions[36]() is releaseEvents
+PASS cachedFunctions[37]() is removeEventListener
+PASS cachedFunctions[37]() is removeEventListener
+PASS cachedFunctions[38]() is resizeBy
+PASS cachedFunctions[38]() is resizeBy
+PASS cachedFunctions[39]() is resizeTo
+PASS cachedFunctions[39]() is resizeTo
+PASS cachedFunctions[40]() is screen
+PASS cachedFunctions[40]() is screen
+PASS cachedFunctions[41]() is screenLeft
+PASS cachedFunctions[41]() is screenLeft
+PASS cachedFunctions[42]() is screenTop
+PASS cachedFunctions[42]() is screenTop
+PASS cachedFunctions[43]() is screenX
+PASS cachedFunctions[43]() is screenX
+PASS cachedFunctions[44]() is screenY
+PASS cachedFunctions[44]() is screenY
+PASS cachedFunctions[45]() is scroll
+PASS cachedFunctions[45]() is scroll
+PASS cachedFunctions[46]() is scrollBy
+PASS cachedFunctions[46]() is scrollBy
+PASS cachedFunctions[47]() is scrollTo
+PASS cachedFunctions[47]() is scrollTo
+PASS cachedFunctions[48]() is scrollX
+PASS cachedFunctions[48]() is scrollX
+PASS cachedFunctions[49]() is scrollY
+PASS cachedFunctions[49]() is scrollY
+PASS cachedFunctions[50]() is setInterval
+PASS cachedFunctions[50]() is setInterval
+PASS cachedFunctions[51]() is setTimeout
+PASS cachedFunctions[51]() is setTimeout
+PASS cachedFunctions[52]() is showModalDialog
+PASS cachedFunctions[52]() is showModalDialog
+PASS cachedFunctions[53]() is status
+PASS cachedFunctions[53]() is status
+PASS cachedFunctions[54]() is stop
+PASS cachedFunctions[54]() is stop
+PASS cachedFunctions[55]() is window
+PASS cachedFunctions[55]() is window
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/js/dom/script-tests/global-function-resolve.js (246706 => 246707)


--- trunk/LayoutTests/js/dom/script-tests/global-function-resolve.js	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/LayoutTests/js/dom/script-tests/global-function-resolve.js	2019-06-22 05:50:02 UTC (rev 246707)
@@ -30,7 +30,6 @@
     'name',
     'navigator',
     'open',
-    'openDatabase',
     'opener',
     'outerHeight',
     'outerWidth',

Modified: trunk/Source/_javascript_Core/ChangeLog (246706 => 246707)


--- trunk/Source/_javascript_Core/ChangeLog	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-06-22 05:50:02 UTC (rev 246707)
@@ -1,3 +1,14 @@
+2019-06-21  Sihui Liu  <[email protected]>
+
+        openDatabase should return an empty object when WebSQL is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=198805
+
+        Reviewed by Geoffrey Garen.
+
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::createFunctionThatMasqueradesAsUndefined):
+        * runtime/JSFunction.h:
+
 2019-06-21  Alexey Shvayka  <[email protected]>
 
         Remove extra check in RegExp @matchSlow

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (246706 => 246707)


--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2019-06-22 05:50:02 UTC (rev 246707)
@@ -99,6 +99,16 @@
     return function;
 }
 
+JSFunction* JSFunction::createFunctionThatMasqueradesAsUndefined(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()

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.h (246706 => 246707)


--- trunk/Source/_javascript_Core/runtime/JSFunction.h	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.h	2019-06-22 05:50:02 UTC (rev 246707)
@@ -80,6 +80,7 @@
     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* createFunctionThatMasqueradesAsUndefined(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor, const DOMJIT::Signature* = nullptr);
     
     static JSFunction* createWithInvalidatedReallocationWatchpoint(VM&, FunctionExecutable*, JSScope*);
 

Modified: trunk/Source/WebCore/ChangeLog (246706 => 246707)


--- trunk/Source/WebCore/ChangeLog	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/WebCore/ChangeLog	2019-06-22 05:50:02 UTC (rev 246707)
@@ -1,3 +1,23 @@
+2019-06-21  Sihui Liu  <[email protected]>
+
+        openDatabase should return an empty object when WebSQL is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=198805
+
+        Reviewed by Geoffrey Garen.
+
+        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::IDLOperation<JSDOMWindow>::cast):
+        (WebCore::jsDOMWindowInstanceFunctionOpenDatabase):
+        (WebCore::JSDOMWindow::openDatabase const):
+
 2019-06-21  Ryosuke Niwa  <[email protected]>
 
         Nullptr crash in DeleteSelectionCommand::handleGeneralDelete

Modified: trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl (246706 => 246707)


--- trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl	2019-06-22 05:50:02 UTC (rev 246707)
@@ -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;
 };

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (246706 => 246707)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2019-06-22 05:50:02 UTC (rev 246707)
@@ -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 <_javascript_Core/BuiltinNames.h>
 #include <_javascript_Core/HeapSnapshotBuilder.h>
 #include <_javascript_Core/JSCInlines.h>
+#include <_javascript_Core/JSFunction.h>
 #include <_javascript_Core/JSMicrotask.h>
 #include <_javascript_Core/Lookup.h>
+#include <_javascript_Core/Structure.h>
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
 #include "JSWebKitNamespace.h"
@@ -60,6 +65,7 @@
 using namespace JSC;
 
 EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionShowModalDialog(ExecState*);
+EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionOpenDatabase(ExecState*);
 
 void JSDOMWindow::visitAdditionalChildren(SlotVisitor& visitor)
 {
@@ -564,4 +570,53 @@
     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))));
+}
+
+template<> inline JSDOMWindow* IDLOperation<JSDOMWindow>::cast(ExecState& state)
+{
+    return toJSDOMWindow(state.vm(), state.thisValue().toThis(&state, NotStrictMode));
+}
+
+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 (RuntimeEnabledFeatures::sharedFeatures().webSQLEnabled())
+        return JSFunction::create(vm, state.lexicalGlobalObject(), 4, name, jsDOMWindowInstanceFunctionOpenDatabase, NoIntrinsic);
+
+    return JSFunction::createFunctionThatMasqueradesAsUndefined(vm, state.lexicalGlobalObject(), 4, name, jsDOMWindowInstanceFunctionOpenDatabase, NoIntrinsic);
+}
+
 } // namespace WebCore

Modified: trunk/Tools/ChangeLog (246706 => 246707)


--- trunk/Tools/ChangeLog	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Tools/ChangeLog	2019-06-22 05:50:02 UTC (rev 246707)
@@ -1,3 +1,16 @@
+2019-06-21  Sihui Liu  <[email protected]>
+
+        openDatabase should return an empty object when WebSQL is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=198805
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm: Added.
+        (-[WebSQLBasicsMessageHandler userContentController:didReceiveScriptMessage:]):
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html: Added.
+
 2019-06-21  Jiewen Tan  <[email protected]>
 
         WebPageProxy::loadData should accept ShouldOpenExternalURLsPolicy

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (246706 => 246707)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-06-22 04:04:23 UTC (rev 246706)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-06-22 05:50:02 UTC (rev 246707)
@@ -645,6 +645,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 */; };
@@ -1283,6 +1285,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 */,
@@ -1927,6 +1930,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>"; };
@@ -2770,6 +2775,7 @@
 				C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */,
 				5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
 				5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
+				931C281C22BC55A7001D98C4 /* WebSQLBasics.mm */,
 				2E5C77061FA70136005932C3 /* WKAttachmentTests.mm */,
 				1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */,
 				5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */,
@@ -3130,6 +3136,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 */,
@@ -4533,6 +4540,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 */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm (0 => 246707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm	2019-06-22 05:50:02 UTC (rev 246707)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/WebKit.h>
+#import <wtf/RetainPtr.h>
+
+static bool receivedScriptMessage;
+static RetainPtr<WKScriptMessage> lastScriptMessage;
+
+@interface WebSQLBasicsMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation WebSQLBasicsMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    receivedScriptMessage = true;
+    lastScriptMessage = message;
+}
+
+@end
+
+TEST(WebSQL, OpenDatabaseAlwaysExists)
+{
+    auto handler = adoptNS([[WebSQLBasicsMessageHandler alloc] init]);
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
+    receivedScriptMessage = false;
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"opendatabase-always-exists" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&receivedScriptMessage);
+    RetainPtr<NSString> string = (NSString *)[lastScriptMessage body];
+    EXPECT_WK_STREQ(@"Web SQL is deprecated", string.get());
+}

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html (0 => 246707)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html	2019-06-22 05:50:02 UTC (rev 246707)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script>
+
+var allPassed = false;
+if (!window.openDatabase) {
+    if (window.openDatabase(null, null, null, null)) {
+        var hasError = false;
+        try {
+            openDatabase('WebSQLDatabase', '1.0', 'Test DB', 524288);
+        } catch(e) {
+            hasError = true;
+            window.webkit.messageHandlers.testHandler.postMessage(e.message);
+        } finally {
+            if (!hasError)
+                window.webkit.messageHandlers.testHandler.postMessage("openDatabase can be called with non-null parameters");
+        }
+    } else {
+        window.webkit.messageHandlers.testHandler.postMessage("openDatabase cannot be called");
+    }
+} else {
+    window.webkit.messageHandlers.testHandler.postMessage("window has openDatabase");
+}
+
+</script>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to