Source/WebCore: [V8] Wait until no v8 context is on the stack before
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2011 22:13:56 +0000 (22:13 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2011 22:13:56 +0000 (22:13 +0000)
cancelling pending indexed db transactions.
https://bugs.webkit.org/show_bug.cgi?id=64552

Reviewed by Adam Barth.

Test: storage/indexeddb/transaction-abort-with-js-recursion.html

* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::didLeaveScriptContext):

LayoutTests: Test for https://bugs.webkit.org/show_bug.cgi?id=64552.

Reviewed by Adam Barth.

* storage/indexeddb/transaction-abort-with-js-recursion-expected.txt: Added.
* storage/indexeddb/transaction-abort-with-js-recursion.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91309 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/V8Proxy.cpp

index fefc34c..cbbbd29 100644 (file)
@@ -1,3 +1,12 @@
+2011-07-19  Nate Chapin  <japhet@chromium.org>
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=64552.
+
+        Reviewed by Adam Barth.
+
+        * storage/indexeddb/transaction-abort-with-js-recursion-expected.txt: Added.
+        * storage/indexeddb/transaction-abort-with-js-recursion.html: Added.
+
 2011-07-19  Mike West  <mkwst@chromium.org>
 
         Sending a `Ping-From` header for cross-origin pings from non-HTTPS documents.
diff --git a/LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion-expected.txt b/LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion-expected.txt
new file mode 100644 (file)
index 0000000..9a216e9
--- /dev/null
@@ -0,0 +1,21 @@
+Test that pending transactions are not aborted during recursive JS calls until all JS is finished.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS 'webkitIndexedDB' in window is true
+PASS webkitIndexedDB == null is false
+webkitIndexedDB.open('transaction-abort-with-js-recursion')
+db = event.target.result
+db.setVersion('new version')
+pendingTransaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
+Start re-entrant JS
+transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
+End re-entrant JS
+store = pendingTransaction.objectStore('objectStore')
+PASS store !== undefined is true
+Pending transaction aborted
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion.html b/LayoutTests/storage/indexeddb/transaction-abort-with-js-recursion.html
new file mode 100644 (file)
index 0000000..d0cde03
--- /dev/null
@@ -0,0 +1,72 @@
+<html>\r
+<head>\r
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">\r
+<script src="../../fast/js/resources/js-test-pre.js"></script>\r
+<script src="../../fast/js/resources/js-test-post-function.js"></script>\r
+<script src="resources/shared.js"></script>\r
+</head>\r
+<body>\r
+<p id="description"></p>\r
+<div id="console"></div>\r
+<script>\r
+\r
+var transaction;\r
+var store;\r
+var db;\r
+var body = document.getElementsByTagName("body")[0];\r
+\r
+description("Test that pending transactions are not aborted during recursive JS calls until all JS is finished.");\r
+if (window.layoutTestController)\r
+    layoutTestController.waitUntilDone();\r
+\r
+function setup() {\r
+    shouldBeTrue("'webkitIndexedDB' in window");\r
+    shouldBeFalse("webkitIndexedDB == null");\r
+\r
+    request = evalAndLog("webkitIndexedDB.open('transaction-abort-with-js-recursion')");\r
+    request.onsuccess = setVersion;\r
+    request.onerror = unexpectedErrorCallback;\r
+}\r
+\r
+function setVersion() {\r
+    db = evalAndLog("db = event.target.result");\r
+    request = evalAndLog("db.setVersion('new version')");\r
+    request.onsuccess = click;\r
+    request.onerror = unexpectedErrorCallback;\r
+}\r
+\r
+function click() {\r
+    body.onclick = test;\r
+    var pendingTransaction = evalAndLog("pendingTransaction = db.transaction([], webkitIDBTransaction.READ_WRITE)");\r
+    pendingTransaction.onsuccess = unexpectedErrorCallback;\r
+    pendingTransaction.onerror = unexpectedErrorCallback;\r
+    pendingTransaction.onabort = abortCallback;\r
+    var event = document.createEvent("MouseEvent");\r
+    event.initMouseEvent("click", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);\r
+    body.dispatchEvent(event);\r
+    var store = evalAndLog("store = pendingTransaction.objectStore('objectStore')");\r
+    shouldBeTrue("store !== undefined");\r
+    body.onclick = undefined;\r
+}\r
+\r
+function test()\r
+{\r
+    debug("Start re-entrant JS");\r
+    store = db.createObjectStore('objectStore', null);\r
+    transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)");\r
+    debug("End re-entrant JS");\r
+}\r
+\r
+\r
+function abortCallback()\r
+{\r
+    debug("Pending transaction aborted");\r
+    done();\r
+}\r
+\r
+setup();\r
+var successfullyParsed = true;\r
+\r
+</script>\r
+</body>\r
+</html>\r
index 26b9b3c..6d058a2 100644 (file)
@@ -1,3 +1,16 @@
+2011-07-19  Nate Chapin  <japhet@chromium.org>
+
+        [V8] Wait until no v8 context is on the stack before
+        cancelling pending indexed db transactions.
+        https://bugs.webkit.org/show_bug.cgi?id=64552
+
+        Reviewed by Adam Barth.
+
+        Test: storage/indexeddb/transaction-abort-with-js-recursion.html
+
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::didLeaveScriptContext):
+
 2011-07-19  MORITA Hajime  <morrita@google.com>
 
         Crash in CompositeEditCommand::replaceTextInNodePreservingMarkers.
index 1105bf9..a47885e 100644 (file)
@@ -611,17 +611,17 @@ void V8Proxy::didLeaveScriptContext()
     Page* page = m_frame->page();
     if (!page)
         return;
+    // If we've just left a top level script context and local storage has been
+    // instantiated, we must ensure that any storage locks have been freed.
+    // Per http://dev.w3.org/html5/spec/Overview.html#storage-mutex
+    if (m_recursion)
+        return;
 #if ENABLE(INDEXED_DATABASE)
     // If we've just left a script context and indexed database has been
     // instantiated, we must let its transaction coordinator know so it can terminate
     // any not-yet-started transactions.
     IDBPendingTransactionMonitor::abortPendingTransactions();
 #endif // ENABLE(INDEXED_DATABASE)
-    // If we've just left a top level script context and local storage has been
-    // instantiated, we must ensure that any storage locks have been freed.
-    // Per http://dev.w3.org/html5/spec/Overview.html#storage-mutex
-    if (m_recursion != 0)
-        return;
     if (page->group().hasLocalStorage())
         page->group().localStorage()->unlock();
 }