WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2007 22:06:50 +0000 (22:06 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2007 22:06:50 +0000 (22:06 +0000)
        Reviewed by Brady.

        Make document.open count as committing a document load, so that -[WebFrame dataSource:] won't
        return nil in that case.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::didExplicitOpen):

WebKitTools:

        Reviewed by Brady.

        Assert that a web frame that's loading a resource always has either a data source or
        a provisional data source.

        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
        (-[ResourceLoadDelegate webView:identifierForInitialRequest:fromDataSource:]):

LayoutTests:

        Reviewed by Brady.

        Add test that calls window.open and then immediately writes into the document
        of the newly opened window.

        * http/tests/misc/resources/compass.jpg: Added.
        * http/tests/misc/window-open-then-write-expected.txt: Added.
        * http/tests/misc/window-open-then-write.html: Added.
        * platform/win/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/resources/compass.jpg [new file with mode: 0644]
LayoutTests/http/tests/misc/window-open-then-write-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/window-open-then-write.html [new file with mode: 0644]
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/loader/FrameLoader.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm

index a371e9f9e3174805feedfc6f66c0bf19f9eebc87..a56d2cb66f781c15170e8503de4602be51250e74 100644 (file)
@@ -1,3 +1,15 @@
+2007-12-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Brady.
+
+        Add test that calls window.open and then immediately writes into the document
+        of the newly opened window.
+        
+        * http/tests/misc/resources/compass.jpg: Added.
+        * http/tests/misc/window-open-then-write-expected.txt: Added.
+        * http/tests/misc/window-open-then-write.html: Added.
+        * platform/win/Skipped:
+
 2007-12-14  David Smith  <catfish.man@gmail.com>
 
         Reviewed by Mitz.
diff --git a/LayoutTests/http/tests/misc/resources/compass.jpg b/LayoutTests/http/tests/misc/resources/compass.jpg
new file mode 100644 (file)
index 0000000..671f7b1
Binary files /dev/null and b/LayoutTests/http/tests/misc/resources/compass.jpg differ
diff --git a/LayoutTests/http/tests/misc/window-open-then-write-expected.txt b/LayoutTests/http/tests/misc/window-open-then-write-expected.txt
new file mode 100644 (file)
index 0000000..54af798
--- /dev/null
@@ -0,0 +1,2 @@
+This tests that calling window.open() with a URL and then writing to the window using document.write still causes the WebFrame in question to have a correct WebDataSource.
+SUCCESS! Did not assert!
diff --git a/LayoutTests/http/tests/misc/window-open-then-write.html b/LayoutTests/http/tests/misc/window-open-then-write.html
new file mode 100644 (file)
index 0000000..75cbfdf
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.setCanOpenWindows();
+    layoutTestController.dumpAsText();
+}
+
+function runTest() {
+    var w = window.open('test.html');
+    w.document.write('<img src="resources/compass.jpg" onload="if (window.layoutTestController) setTimeout(\'layoutTestController.notifyDone()\', 100);">');
+    w.document.close();
+}
+</script>
+<body onload="runTest();">
+<div>This tests that calling window.open() with a URL and then writing to the window using document.write still causes the WebFrame in question to have a correct WebDataSource.</div>
+<div>SUCCESS! Did not assert!</div>
+</body>
+</html>
index 556904ebc545d9112938f5fd19c2fbd6198a1e12..39965f55bbf5cf1b647cabdd9da0be2699aa7ff5 100644 (file)
@@ -244,6 +244,7 @@ fast/dom/Document/early-document-access.html
 fast/history/history_reload.html
 http/tests/navigation/new-window-redirect-history.html
 http/tests/navigation/target-frame-from-window.html
+http/tests/misc/window-open-then-write.html
 #http/tests/security/dataURL/xss-DENIED-from-data-url-in-foreign-domain-window-open.html [This test is currently disabled]
 http/tests/security/dataURL/xss-DENIED-from-javascript-url-window-open.html
 #http/tests/security/dataURL/xss-DENIED-to-data-url-in-foreign-domain-window-open.html [This test is currently disabled]
index 22ff91424935b2185fefb7a244a8c582d13637e7..2151f7f9d10bc1e5faa90ad5c34ff7886b8c4f2c 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Brady.
+
+        Make document.open count as committing a document load, so that -[WebFrame dataSource:] won't
+        return nil in that case.
+        
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::didExplicitOpen):
+
 2007-12-14  David Smith  <catfish.man@gmail.com>
 
         Reviewed by Mitz.
index e78e3105453ab91bc93f1644948817348d32eb44..5711cfeb058155f9f317e83f1e4d3393461339dd 100644 (file)
@@ -726,6 +726,9 @@ void FrameLoader::didExplicitOpen()
     m_isComplete = false;
     m_didCallImplicitClose = false;
 
+    // Calling document.open counts as committing the first real document load.
+    m_committedFirstRealDocumentLoad = true;
+    
     // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
     // from a subsequent window.document.open / window.document.write call. 
     // Cancelling redirection here works for all cases because document.open 
index 7b774160b642b89f49c257c9c0b7828a3ea9c819..6593b52f42e90e14e8f711fe68ae5529c8da70cd 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Brady.
+
+        Assert that a web frame that's loading a resource always has either a data source or 
+        a provisional data source.
+        
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+        (-[ResourceLoadDelegate webView:identifierForInitialRequest:fromDataSource:]):
+
 2007-12-14  Darin Adler  <darin@apple.com>
 
         - fix mistake causing nearly all tests to fail on Windows
index d23db3b147fd2a940af136d7c9dd94b51c748496..cc0eb4a23b02299d72cee85cd2df76bbc323601f 100644 (file)
@@ -31,6 +31,7 @@
 #import "DumpRenderTree.h"
 #import "LayoutTestController.h"
 #import <WebKit/WebKit.h>
+#import <wtf/Assertions.h>
 
 @interface NSURL (DRTExtras)
 - (NSString *)_drt_descriptionSuitableForTestResult;
 
 - webView: (WebView *)wv identifierForInitialRequest: (NSURLRequest *)request fromDataSource: (WebDataSource *)dataSource
 {
+    ASSERT([[dataSource webFrame] dataSource] || [[dataSource webFrame] provisionalDataSource]);
+    
     if (!done && layoutTestController->dumpResourceLoadCallbacks())
         return [[request URL] _drt_descriptionSuitableForTestResult];