window.openDatabase is not writable
https://bugs.webkit.org/show_bug.cgi?id=199737
<rdar://problem/52551332>
Reviewed by Chris Dumez.
Source/WebCore:
In r246707 we made openDatabase an undetectable attribute of window, and it was set to be read-only. This broke
some sites which replace window.openDatabase with their own implementation when window.openDatabase does not
exists or WebSQL is not implemented.
This patch removes the readonly property and adds a setter for openDatabase.
* Modules/webdatabase/DOMWindowWebDatabase.idl:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::setOpenDatabase):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d2eb69a..eb1a3f7 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2019-07-15 Sihui Liu <sihui_liu@apple.com>
+
+ window.openDatabase is not writable
+ https://bugs.webkit.org/show_bug.cgi?id=199737
+ <rdar://problem/52551332>
+
+ Reviewed by Chris Dumez.
+
+ In r246707 we made openDatabase an undetectable attribute of window, and it was set to be read-only. This broke
+ some sites which replace window.openDatabase with their own implementation when window.openDatabase does not
+ exists or WebSQL is not implemented.
+
+ This patch removes the readonly property and adds a setter for openDatabase.
+
+ * Modules/webdatabase/DOMWindowWebDatabase.idl:
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::setOpenDatabase):
+
2019-07-15 Youenn Fablet <youenn@apple.com>
Filter SDP c lines
diff --git a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
index 11eadaa..16ad40a 100644
--- a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
+++ b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
@@ -25,5 +25,5 @@
*/
partial interface DOMWindow {
- [CustomGetter, NotEnumerable] readonly attribute any openDatabase;
+ [Custom, NotEnumerable] attribute any openDatabase;
};
diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 5010680..a966b55 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -619,4 +619,12 @@
return JSFunction::createFunctionThatMasqueradesAsUndefined(vm, state.lexicalGlobalObject(), 4, name, jsDOMWindowInstanceFunctionOpenDatabase, NoIntrinsic);
}
+void JSDOMWindow::setOpenDatabase(JSC::ExecState& state, JSC::JSValue value)
+{
+ if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, wrapped(), ThrowSecurityError))
+ return;
+
+ replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "openDatabase"), value);
+}
+
} // namespace WebCore
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index b9767cf..b099bce 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,15 @@
+2019-07-15 Sihui Liu <sihui_liu@apple.com>
+
+ window.openDatabase is not writable
+ https://bugs.webkit.org/show_bug.cgi?id=199737
+ <rdar://problem/52551332>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm:
+ (TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html:
+
2019-07-15 Aakash Jain <aakash_jain@apple.com>
[ews-build] Parse and display layout test failures
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm
index 1b8ec02..b5c0fea 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm
@@ -64,5 +64,5 @@
TestWebKitAPI::Util::run(&receivedScriptMessage);
RetainPtr<NSString> string = (NSString *)[lastScriptMessage body];
- EXPECT_WK_STREQ(@"Web SQL is deprecated", string.get());
+ EXPECT_WK_STREQ(@"openDatabase tests passed", string.get());
}
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html
index c899e7f..d8c6337 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html
@@ -9,10 +9,18 @@
openDatabase('WebSQLDatabase', '1.0', 'Test DB', 524288);
} catch(e) {
hasError = true;
- window.webkit.messageHandlers.testHandler.postMessage(e.message);
} finally {
- if (!hasError)
+ if (!hasError) {
window.webkit.messageHandlers.testHandler.postMessage("openDatabase can be called with non-null parameters");
+ } else {
+ var func = function() { }
+ window.openDatabase = func;
+ if (window.openDatabase == func) {
+ window.webkit.messageHandlers.testHandler.postMessage("openDatabase tests passed");
+ } else {
+ window.webkit.messageHandlers.testHandler.postMessage("openDatabase is not writable");
+ }
+ }
}
} else {
window.webkit.messageHandlers.testHandler.postMessage("openDatabase cannot be called");