openDatabase should return an empty object when WebSQL is disabled
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jun 2019 05:50:02 +0000 (05:50 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jun 2019 05:50:02 +0000 (05:50 +0000)
commit66e5b33e0b0a07bed1d0df685072c5e080771775
tree58e499d0cf5d44bb57a152d12d06d5ed900f8600
parent820b6cae8cba58a6121dc5418a79c8e7c9a880aa
openDatabase should return an empty object when WebSQL is disabled
https://bugs.webkit.org/show_bug.cgi?id=198805

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

* 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/global-function-resolve-expected.txt
LayoutTests/js/dom/script-tests/global-function-resolve.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSFunction.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html [new file with mode: 0644]