Reviewed by Maciej.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2007 10:19:17 +0000 (10:19 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2007 10:19:17 +0000 (10:19 +0000)
        <rdar://problem/5539306> REGRESSION: redirect fails when subframe's document is opened but
        not closed (affects digg.com)

        Tests: fast/loader/meta-refresh-vs-open.html
               fast/loader/redirect-with-open-subframe-2.html
               fast/loader/redirect-with-open-subframe.html
               http/tests/loading/onload-vs-immediate-refresh.pl

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::scheduleRedirection): Only check whether the load is complete for
        HTTP redirects - JavaScript-initiated ones are effective immediately.

WebKitTools:
        * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Replace the current document with a blank
        one after finishing with a test to avoid having its delayed onload handler fired when
        starting the next test. This is ugly and still unreliable (see LayoutTests ChangeLog),
        but it helps somewhat.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/loader/meta-refresh-vs-open-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/meta-refresh-vs-open.html [new file with mode: 0644]
LayoutTests/fast/loader/redirect-with-open-subframe-2-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/redirect-with-open-subframe-2.html [new file with mode: 0644]
LayoutTests/fast/loader/redirect-with-open-subframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/loader/redirect-with-open-subframe.html [new file with mode: 0644]
LayoutTests/http/tests/loading/onload-vs-immediate-refresh-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/onload-vs-immediate-refresh.pl [new file with mode: 0755]
LayoutTests/platform/mac/http/tests/loading/simple-subframe-expected.txt
WebCore/ChangeLog
WebCore/loader/FrameLoader.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm

index 2d7174a..a42ff81 100644 (file)
@@ -1,3 +1,28 @@
+2007-11-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/5539306> REGRESSION: redirect fails when subframe's document is opened but
+        not closed (affects digg.com)
+
+        * fast/loader/meta-refresh-vs-open-expected.txt: Added.
+        * fast/loader/meta-refresh-vs-open.html: Added.
+        Test that HTTP refresh never fires if the document stays open indefinitely.
+
+        * fast/loader/redirect-with-open-subframe-expected.txt: Added.
+        * fast/loader/redirect-with-open-subframe.html: Added.
+        * fast/loader/redirect-with-open-subframe-2-expected.txt: Added.
+        * fast/loader/redirect-with-open-subframe-2.html: Added.
+        Test that setting window.location has effect even if the document is open.
+
+        * http/tests/loading/onload-vs-immediate-refresh-expected.txt: Added.
+        * http/tests/loading/onload-vs-immediate-refresh.pl: Added.
+        Test for <rdar://3829452> - HTTP redirect should only happen after onload fires.
+
+        * platform/mac/http/tests/loading/simple-subframe-expected.txt:
+        It seems that there was a line spilled from the previous test that is now in
+        onload-vs-immediate-refresh-expected.txt - despite my efforts, I couldn't get rid of it.
+
 2007-11-23  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/fast/loader/meta-refresh-vs-open-expected.txt b/LayoutTests/fast/loader/meta-refresh-vs-open-expected.txt
new file mode 100644 (file)
index 0000000..22ab688
--- /dev/null
@@ -0,0 +1,2 @@
+
+SUCCESS - shouldn't refresh or invoke onload.
diff --git a/LayoutTests/fast/loader/meta-refresh-vs-open.html b/LayoutTests/fast/loader/meta-refresh-vs-open.html
new file mode 100644 (file)
index 0000000..52a5844
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+</script>
+<meta http-equiv="refresh" content="0;url=data:text/plain,You should not have been redirected here.">
+</head>
+<body onload="if (window.layoutTestController) document.write('<p>FAIL: onload</p>'); else alert('FAIL: onload');">
+<iframe id="ifrm" src="about:blank"></iframe>
+<script>
+    document.getElementById("ifrm").contentDocument.open();
+    if (window.layoutTestController)
+        setTimeout("layoutTestController.notifyDone()", 500);
+</script>
+<p>SUCCESS - shouldn't refresh or invoke onload.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/loader/redirect-with-open-subframe-2-expected.txt b/LayoutTests/fast/loader/redirect-with-open-subframe-2-expected.txt
new file mode 100644 (file)
index 0000000..ff43ca4
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS
diff --git a/LayoutTests/fast/loader/redirect-with-open-subframe-2.html b/LayoutTests/fast/loader/redirect-with-open-subframe-2.html
new file mode 100644 (file)
index 0000000..5c53837
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<script>
+function test() {
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+    }
+    document.open();
+    var newDoc = "SUCCESS<script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt>";
+    setTimeout("window.location='data:text/html," + newDoc + "'", 500);
+}
+</script>
+<body onload="test()">
+</body>
+</html>
diff --git a/LayoutTests/fast/loader/redirect-with-open-subframe-expected.txt b/LayoutTests/fast/loader/redirect-with-open-subframe-expected.txt
new file mode 100644 (file)
index 0000000..ff43ca4
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS
diff --git a/LayoutTests/fast/loader/redirect-with-open-subframe.html b/LayoutTests/fast/loader/redirect-with-open-subframe.html
new file mode 100644 (file)
index 0000000..929f548
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<body>
+<iframe id="ifrm" src="about:blank"></iframe>
+<script>
+    document.getElementById("ifrm").contentDocument.open();
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+    }
+    var newDoc = "SUCCESS<script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt>";
+    setTimeout("window.location='data:text/html," + newDoc + "'", 500);
+</script>
+<div>FAILURE: should redirect.</div>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/loading/onload-vs-immediate-refresh-expected.txt b/LayoutTests/http/tests/loading/onload-vs-immediate-refresh-expected.txt
new file mode 100644 (file)
index 0000000..5cf7612
--- /dev/null
@@ -0,0 +1,9 @@
+main frame - didStartProvisionalLoadForFrame
+frame "f1" - willCloseFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didFinishLoadForFrame
+SUCCESS
diff --git a/LayoutTests/http/tests/loading/onload-vs-immediate-refresh.pl b/LayoutTests/http/tests/loading/onload-vs-immediate-refresh.pl
new file mode 100755 (executable)
index 0000000..1f2ccb2
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+# http://trac.webkit.org/projects/webkit/changeset/7800
+# rdar://problem/3829452 REGRESSION (156-157): onload handler doesn't run on page with meta refresh of 0 duration (new Apple start page)
+
+# flush the buffers after each print
+select (STDOUT);
+$| = 1;
+
+print "Refresh: 0;url=data:text/plain,You should have seen an alert.\r\n";
+print "Content-Type: text/html\r\n";
+print "\r\n";
+
+print << "EOF";
+<html>
+<head>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+</script>
+<meta http-equiv="refresh" content="0;url=data:text/plain,You should have seen an alert.">
+</head>
+EOF
+
+for ($count=1; $count<20000; $count++) {
+    print " \n";
+}
+
+print << "EOF";
+<body onload="if (window.layoutTestController) document.write('<p>SUCCESS</p>'); else alert('SUCCESS');">
+</body>
+</html>
+EOF
index 6d20ded..1d08239 100644 (file)
@@ -1,5 +1,4 @@
 main frame - didStartProvisionalLoadForFrame
-frame "f1" - willCloseFrame
 main frame - willCloseFrame
 main frame - didCommitLoadForFrame
 main frame - didClearWindowObjectForFrame
index 5378dc2..52dde1e 100644 (file)
@@ -1,3 +1,19 @@
+2007-11-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/5539306> REGRESSION: redirect fails when subframe's document is opened but
+        not closed (affects digg.com)
+
+        Tests: fast/loader/meta-refresh-vs-open.html
+               fast/loader/redirect-with-open-subframe-2.html
+               fast/loader/redirect-with-open-subframe.html
+               http/tests/loading/onload-vs-immediate-refresh.pl
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::scheduleRedirection): Only check whether the load is complete for
+        HTTP redirects - JavaScript-initiated ones are effective immediately.
+
 2007-11-23  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Alexey Proskuryakov.
index 8f12e0a..d881f57 100644 (file)
@@ -1808,7 +1808,9 @@ void FrameLoader::scheduleRedirection(ScheduledRedirection* redirection)
 {
     stopRedirectionTimer();
     m_scheduledRedirection.set(redirection);
-    if (m_isComplete)
+    if (!m_isComplete && redirection->type != ScheduledRedirection::redirection)
+        completed();
+    if (m_isComplete || redirection->type != ScheduledRedirection::redirection)
         startRedirectionTimer();
 }
 
index 767a223..bdb3a60 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/5539306> REGRESSION: redirect fails when subframe's document is opened but
+        not closed (affects digg.com)
+
+        * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Replace the current document with a blank
+        one after finishing with a test to avoid having its delayed onload handler firing when
+        replaced with the next one. This is ugly and still unreliable (see LayoutTests ChangeLog),
+        but it helps somewhat.
+
 2007-11-22  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Alp Toker.
index e733920..14324ab 100644 (file)
@@ -874,6 +874,9 @@ static void runTest(const char *pathOrURL)
         }
     }
     
+    [mainFrame loadHTMLString:@"<html></html>" baseURL:[NSURL URLWithString:@"about:blank"]];
+    [mainFrame stopLoading];
+    
     [pool release];
 
     // We should only have our main window left when we're done