2011-02-03 Mihai Parparita <mihaip@chromium.org>
authormihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 00:40:23 +0000 (00:40 +0000)
committermihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 00:40:23 +0000 (00:40 +0000)
        Reviewed by Alexey Proskuryakov.

        REGRESSION (r77355): Page cache layout tests crash
        https://bugs.webkit.org/show_bug.cgi?id=53648

        Add test that calls setTimeout during a pagehide event handler (the
        timeout should not fire while the document is in the page cache).

        Skipped for Chromium since it doesn't use the page cache.

        * fast/events/pagehide-timeout-expected.txt: Added.
        * fast/events/pagehide-timeout.html: Added.
        * fast/events/resources/pagehide-timeout-go-back.html: Added.
        * platform/chromium/test_expectations.txt:
2011-02-03  Mihai Parparita  <mihaip@chromium.org>

        Reviewed by Alexey Proskuryakov.

        REGRESSION (r77355): Page cache layout tests crash
        https://bugs.webkit.org/show_bug.cgi?id=53648

        Test: fast/events/pagehide-timeout.html

        Suspend active DOM objects after all pagehide event handlers have run,
        otherwise it's possible for them to create more objects that weren't
        getting suspended.

        * history/CachedFrame.cpp:
        (WebCore::CachedFrame::CachedFrame):

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

LayoutTests/ChangeLog
LayoutTests/fast/events/pagehide-timeout-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/pagehide-timeout.html [new file with mode: 0644]
LayoutTests/fast/events/resources/pagehide-timeout-go-back.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/history/CachedFrame.cpp

index 2404588e12b8c82cdd6b6f7c6498f7dcc7834deb..4d64fe6ea8ac981bd09f33132afcad71f28baa4b 100644 (file)
@@ -1,3 +1,20 @@
+2011-02-03  Mihai Parparita  <mihaip@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        REGRESSION (r77355): Page cache layout tests crash
+        https://bugs.webkit.org/show_bug.cgi?id=53648
+        
+        Add test that calls setTimeout during a pagehide event handler (the
+        timeout should not fire while the document is in the page cache).
+        
+        Skipped for Chromium since it doesn't use the page cache.
+
+        * fast/events/pagehide-timeout-expected.txt: Added.
+        * fast/events/pagehide-timeout.html: Added.
+        * fast/events/resources/pagehide-timeout-go-back.html: Added.
+        * platform/chromium/test_expectations.txt:
+
 2011-02-03  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Added SL-specific result for the test and put back the original result that
diff --git a/LayoutTests/fast/events/pagehide-timeout-expected.txt b/LayoutTests/fast/events/pagehide-timeout-expected.txt
new file mode 100644 (file)
index 0000000..44e7ea1
--- /dev/null
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 19: Creating timeout in pagehide
+CONSOLE MESSAGE: line 5: Loaded pagehide-timeout-go-back.html, going back
+CONSOLE MESSAGE: line 32: Restored page from page cache.
+CONSOLE MESSAGE: line 23: Timeout created in pagehide fired
+Tests that JS execution is suspended after the pagehide event is fired, so that timers created within it will not fire while the document is in the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/pagehide-timeout.html b/LayoutTests/fast/events/pagehide-timeout.html
new file mode 100644 (file)
index 0000000..4baac90
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/javascript">
+description('Tests that JS execution is suspended after the pagehide event is fired, so that timers created within it will not fire while the document is in the page cache.');
+
+if (window.layoutTestController)
+    layoutTestController.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+    
+onpagehide = function()
+{
+    // Don't try to create the timeout again if the test is complete and we're
+    // moving to the next one.
+    if (!window.wasFinishJSTestCalled) {
+        console.log('Creating timeout in pagehide');
+        setTimeout(function() {
+            // This log statement should happen after the one done in the pageshow
+            // handler.
+            console.log('Timeout created in pagehide fired');
+            finishJSTest();
+        }, 100);
+    }
+};
+
+onpageshow = function(event)
+{
+    if (event.persisted)
+        console.log('Restored page from page cache.');
+}
+
+onload = function()
+{
+    setTimeout(function() {
+        location.href = 'resources/pagehide-timeout-go-back.html';
+    }, 0);
+}
+
+var successfullyParsed = true;
+var jsTestIsAsync = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/resources/pagehide-timeout-go-back.html b/LayoutTests/fast/events/resources/pagehide-timeout-go-back.html
new file mode 100644 (file)
index 0000000..b03bbf6
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+console.log('Loaded pagehide-timeout-go-back.html, going back');
+setTimeout(function() { history.back(); }, 200);
+</script>
+</body>
+</html>
index a9c1ed2b07d1fd3ad6bf5dbe2d2cd1e4530b9332..b6c3e2fc018a5e7db245eda17b3d571da21ce096 100644 (file)
@@ -150,7 +150,7 @@ WONTFIX SKIP : http/tests/websocket/tests/workers/ = PASS TIMEOUT FAIL
 // on which renderer process to use for each of them.
 WONTFIX SKIP BUGCR19635 : fast/harness/use-page-cache.html = TIMEOUT FAIL
 WONTFIX SKIP BUGCR19635 : fast/dom/Window/timer-resume-on-navigation-back.html = TIMEOUT FAIL
-// Depends on page cache, as far as I can tell.
+WONTFIX SKIP BUGCR19635 : fast/events/pagehide-timeout.html = TIMEOUT
 WONTFIX SKIP BUGCR19635 : fast/events/pageshow-pagehide-on-back-cached.html = TIMEOUT FAIL
 WONTFIX SKIP BUGCR19635 : fast/events/pageshow-pagehide-on-back-cached-with-frames.html = TIMEOUT
 WONTFIX SKIP BUGCR19635 : media/restore-from-page-cache.html = TIMEOUT
@@ -3201,4 +3201,4 @@ BUGWK50528 MAC : svg/transforms/text-with-pattern-with-svg-transform.svg = IMAGE
 BUGWK50528 MAC : svg/zoom/page/zoom-coords-viewattr-01-b.svg = IMAGE
 BUGWK50528 MAC : svg/zoom/page/zoom-mask-with-percentages.svg = IMAGE
 BUGWK50528 MAC : svg/zoom/text/zoom-coords-viewattr-01-b.svg = IMAGE
-BUGWK50528 MAC : svg/custom/stroked-pattern.svg = IMAGE
\ No newline at end of file
+BUGWK50528 MAC : svg/custom/stroked-pattern.svg = IMAGE
index 4b1a2981d08a0cf49cb1622eec96f4ef2622325f..ed82ef815449f06d3911ae175ea9714fe0c52478 100644 (file)
@@ -1,3 +1,19 @@
+2011-02-03  Mihai Parparita  <mihaip@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        REGRESSION (r77355): Page cache layout tests crash
+        https://bugs.webkit.org/show_bug.cgi?id=53648
+
+        Test: fast/events/pagehide-timeout.html
+        
+        Suspend active DOM objects after all pagehide event handlers have run,
+        otherwise it's possible for them to create more objects that weren't
+        getting suspended.
+
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame):
+
 2011-02-03  Jeremy Orlow  <jorlow@chromium.org>
 
         Reviewed by Nate Chapin.
index 310983b266749c2df454cd5baffd8c73cd91d767..0059691340045d39ec0204aa9122516863172e09 100644 (file)
@@ -135,10 +135,6 @@ CachedFrame::CachedFrame(Frame* frame)
     if (frame->page()->focusController()->focusedFrame() == frame)
         frame->page()->focusController()->setFocusedFrame(frame->page()->mainFrame());
 
-    // Active DOM objects must be suspended before we cached the frame script data
-    m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
-    m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame));
-    
     // Custom scrollbar renderers will get reattached when the document comes out of the page cache
     m_view->detachCustomScrollbars();
 
@@ -146,13 +142,21 @@ CachedFrame::CachedFrame(Frame* frame)
     frame->clearTimers();
     m_document->setInPageCache(true);
     frame->loader()->stopLoading(UnloadEventPolicyUnloadAndPageHide);
-    
-    frame->loader()->client()->savePlatformDataToCachedFrame(this);
 
     // Create the CachedFrames for all Frames in the FrameTree.
     for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
         m_childFrames.append(CachedFrame::create(child));
 
+    // Active DOM objects must be suspended before we cache the frame script data,
+    // but after we've fired the pagehide event, in case that creates more objects.
+    // Suspending must also happen after we've recursed over child frames, in case
+    // those create more objects.
+    // FIXME: It's still possible to have objects created after suspending in some cases, see http://webkit.org/b/53733 for more details.
+    m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
+    m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame));
+
+    frame->loader()->client()->savePlatformDataToCachedFrame(this);
+
     // Deconstruct the FrameTree, to restore it later.
     // We do this for two reasons:
     // 1 - We reuse the main frame, so when it navigates to a new page load it needs to start with a blank FrameTree.