Write a test to ensure we don't regress processing of tasks when page defers loading
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Sep 2015 15:50:58 +0000 (15:50 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Sep 2015 15:50:58 +0000 (15:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135882
<rdar://problem/22550497>

Reviewed by Darin Adler.

Source/WebCore:

Towards adding a test for <https://bugs.webkit.org/show_bug.cgi?id=135688>, add a window.internals
function, setPageDefersLoading, to enable and disable whether the page defers loading.

Test: storage/websql/success-callback-when-page-defers-loading.html

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState): Reset defers loading for the page to false.
(WebCore::Internals::setPageDefersLoading): Added.
* testing/Internals.h:
* testing/Internals.idl: Added IDL declaration setPageDefersLoading.

LayoutTests:

Add a test to ensure we do not regress <https://bugs.webkit.org/show_bug.cgi?id=135688>.

* storage/websql/success-callback-when-page-defers-loading-expected.txt: Added.
* storage/websql/success-callback-when-page-defers-loading.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/storage/websql/success-callback-when-page-defers-loading-expected.txt [new file with mode: 0644]
LayoutTests/storage/websql/success-callback-when-page-defers-loading.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index 9aecb04..b20218a 100644 (file)
@@ -1,3 +1,16 @@
+2015-09-10  Daniel Bates  <dabates@apple.com>
+
+        Write a test to ensure we don't regress processing of tasks when page defers loading
+        https://bugs.webkit.org/show_bug.cgi?id=135882
+        <rdar://problem/22550497>
+
+        Reviewed by Darin Adler.
+
+        Add a test to ensure we do not regress <https://bugs.webkit.org/show_bug.cgi?id=135688>.
+
+        * storage/websql/success-callback-when-page-defers-loading-expected.txt: Added.
+        * storage/websql/success-callback-when-page-defers-loading.html: Added.
+
 2015-09-10  Sergio Villar Senin  <svillar@igalia.com>
 
         min-width/height should default to auto for flexbox items
diff --git a/LayoutTests/storage/websql/success-callback-when-page-defers-loading-expected.txt b/LayoutTests/storage/websql/success-callback-when-page-defers-loading-expected.txt
new file mode 100644 (file)
index 0000000..216fdec
--- /dev/null
@@ -0,0 +1,10 @@
+This tests that a SQL success callback completes when the page defers loading.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Callback invoked.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/websql/success-callback-when-page-defers-loading.html b/LayoutTests/storage/websql/success-callback-when-page-defers-loading.html
new file mode 100644 (file)
index 0000000..c0e4814
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+window.jsTestIsAsync = true;
+
+function runTest()
+{
+    if (!window.testRunner || !window.internals) {
+        testFailed("You must run this test in the test tool.");
+        finishJSTest();
+        return;
+    }
+    testRunner.clearAllDatabases();
+    internals.setPageDefersLoading(true);
+
+    var database = openDatabase("DatabaseTest", "1.0", "Test", 1024 /* bytes */);
+    database.transaction(new Function(), new Function(), function () { testPassed("Callback invoked."); finishJSTest(); });
+}
+</script>
+</head>
+<body>
+<script>
+description("This tests that a SQL success callback completes when the page defers loading.");
+runTest();
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 0c847ab..577c840 100644 (file)
@@ -1,3 +1,22 @@
+2015-09-10  Daniel Bates  <dabates@apple.com>
+
+        Write a test to ensure we don't regress processing of tasks when page defers loading
+        https://bugs.webkit.org/show_bug.cgi?id=135882
+        <rdar://problem/22550497>
+
+        Reviewed by Darin Adler.
+
+        Towards adding a test for <https://bugs.webkit.org/show_bug.cgi?id=135688>, add a window.internals
+        function, setPageDefersLoading, to enable and disable whether the page defers loading.
+
+        Test: storage/websql/success-callback-when-page-defers-loading.html
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState): Reset defers loading for the page to false.
+        (WebCore::Internals::setPageDefersLoading): Added.
+        * testing/Internals.h:
+        * testing/Internals.idl: Added IDL declaration setPageDefersLoading.
+
 2015-09-10  Sergio Villar Senin  <svillar@igalia.com>
 
         min-width/height should default to auto for flexbox items
index 9a49c58..0e95d57 100644 (file)
@@ -305,6 +305,8 @@ void Internals::resetToConsistentState(Page* page)
 
     page->setPageScaleFactor(1, IntPoint(0, 0));
     page->setPagination(Pagination());
+
+    page->setDefersLoading(false);
     
     page->mainFrame().setTextZoomFactor(1.0f);
     
@@ -2935,6 +2937,15 @@ bool Internals::isPagePlayingAudio()
     return !!(document->page()->mediaState() & MediaProducer::IsPlayingAudio);
 }
 
+void Internals::setPageDefersLoading(bool defersLoading)
+{
+    Document* document = contextDocument();
+    if (!document)
+        return;
+    if (Page* page = document->page())
+        page->setDefersLoading(defersLoading);
+}
+
 RefPtr<File> Internals::createFile(const String& path)
 {
     Document* document = contextDocument();
index b71bdc9..cfc4d93 100644 (file)
@@ -418,6 +418,8 @@ public:
     void setPageMuted(bool);
     bool isPagePlayingAudio();
 
+    void setPageDefersLoading(bool);
+
     RefPtr<File> createFile(const String&);
     void queueMicroTask(int);
     bool testPreloaderSettingViewport();
index 7514c30..6953d73 100644 (file)
@@ -387,7 +387,9 @@ enum MediaControlEvent {
 
     void setPageMuted(boolean muted);
     boolean isPagePlayingAudio();
-    
+
+    void setPageDefersLoading(boolean defersLoading);
+
     File createFile(DOMString url);
     void queueMicroTask(long testNumber);
     boolean testPreloaderSettingViewport();