- Revision
- 247434
- Author
- [email protected]
- Date
- 2019-07-15 10:17:52 -0700 (Mon, 15 Jul 2019)
Log Message
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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (247433 => 247434)
--- trunk/Source/WebCore/ChangeLog 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Source/WebCore/ChangeLog 2019-07-15 17:17:52 UTC (rev 247434)
@@ -1,3 +1,21 @@
+2019-07-15 Sihui Liu <[email protected]>
+
+ 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 <[email protected]>
Filter SDP c lines
Modified: trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl (247433 => 247434)
--- trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl 2019-07-15 17:17:52 UTC (rev 247434)
@@ -25,5 +25,5 @@
*/
partial interface DOMWindow {
- [CustomGetter, NotEnumerable] readonly attribute any openDatabase;
+ [Custom, NotEnumerable] attribute any openDatabase;
};
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (247433 => 247434)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2019-07-15 17:17:52 UTC (rev 247434)
@@ -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
Modified: trunk/Tools/ChangeLog (247433 => 247434)
--- trunk/Tools/ChangeLog 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Tools/ChangeLog 2019-07-15 17:17:52 UTC (rev 247434)
@@ -1,3 +1,15 @@
+2019-07-15 Sihui Liu <[email protected]>
+
+ 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 <[email protected]>
[ews-build] Parse and display layout test failures
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm (247433 => 247434)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSQLBasics.mm 2019-07-15 17:17:52 UTC (rev 247434)
@@ -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());
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html (247433 => 247434)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html 2019-07-15 16:54:28 UTC (rev 247433)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/opendatabase-always-exists.html 2019-07-15 17:17:52 UTC (rev 247434)
@@ -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");