Reviewed by Maciej.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Mar 2006 06:12:58 +0000 (06:12 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Mar 2006 06:12:58 +0000 (06:12 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4395
         REGRESSION: document.open doesn't clear the document

        Test: fast/dom/Document/document-reopen.html
        Test: fast/dom/Document/doc-open-while-parsing.html

        * dom/DocumentImpl.cpp:
        (WebCore::DocumentImpl::open): Only ignore open() while the frame is still loading the main resource.
        * page/Frame.cpp:
        (WebCore::Frame::isComplete): Added const specifier.
        (WebCore::Frame::isLoadingMainResource): New function.
        * page/Frame.h:

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/Document/doc-open-while-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Document/doc-open-while-parsing.html [new file with mode: 0644]
LayoutTests/fast/dom/Document/document-reopen-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Document/document-reopen.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/DocumentImpl.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h

index 627d66d5a9d7d642e1ed670eabca9f28efa5c874..0ea26eb0e3240a9a08d6397b7fad04876a21665c 100644 (file)
@@ -1,3 +1,15 @@
+2006-03-16  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=4395
+         REGRESSION: document.open doesn't clear the document
+
+        * fast/dom/Document/doc-open-while-parsing-expected.txt: Added.
+        * fast/dom/Document/doc-open-while-parsing.html: Added.
+        * fast/dom/Document/document-reopen-expected.txt: Added.
+        * fast/dom/Document/document-reopen.html: Added.
+
 2006-03-15  Beth Dakin  <bdakin@apple.com>
 
         Rubber stamped by Geoff.
diff --git a/LayoutTests/fast/dom/Document/doc-open-while-parsing-expected.txt b/LayoutTests/fast/dom/Document/doc-open-while-parsing-expected.txt
new file mode 100644 (file)
index 0000000..5d4373d
--- /dev/null
@@ -0,0 +1,7 @@
+Test for a possible problem related to bug 4395: REGRESSION: document.open doesn't clear the document.
+
+This line should appear second.
+
+Last line.
+
+
diff --git a/LayoutTests/fast/dom/Document/doc-open-while-parsing.html b/LayoutTests/fast/dom/Document/doc-open-while-parsing.html
new file mode 100644 (file)
index 0000000..e098158
--- /dev/null
@@ -0,0 +1,13 @@
+<p>Test for a possible problem related to <a href=\'http://bugzilla.opendarwin.org/show_bug.cgi?id=4395\'>bug 4395</a>: 
+REGRESSION: document.open doesn't clear the document.</p>
+
+<script>
+  if (window.layoutTestController)
+      layoutTestController.dumpAsText();
+
+  document.open();
+  document.write("<p>This line should appear second.</p>");
+  document.close();
+</script>
+
+<p>Last line.</p>
diff --git a/LayoutTests/fast/dom/Document/document-reopen-expected.txt b/LayoutTests/fast/dom/Document/document-reopen-expected.txt
new file mode 100644 (file)
index 0000000..d74dd74
--- /dev/null
@@ -0,0 +1,2 @@
+There should be only one line of text here. Bug 4395
+
diff --git a/LayoutTests/fast/dom/Document/document-reopen.html b/LayoutTests/fast/dom/Document/document-reopen.html
new file mode 100644 (file)
index 0000000..894b7b2
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title>document.open</title>
+</head>
+<body onLoad="mainFunc();">
+<script>
+function mainFunc() {
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+       document.open();
+       document.write("will not be visible<br>");
+       document.close();
+
+       for (i = 0; i < 5; i++) {
+
+               document.open();
+               document.write("There should be only one line of text here. <a href=\'http://bugzilla.opendarwin.org/show_bug.cgi?id=4395\'>Bug 4395</a><br>");
+       }
+}
+</script>
+</body>
+</html>
index a4981c62787af78f7ab7bf3be5c40b1fbb6b5a1e..4eef41c34e17228d08464be2c8d3ad8b1fadee93 100644 (file)
@@ -1,3 +1,20 @@
+2006-03-16  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4395
+         REGRESSION: document.open doesn't clear the document
+
+        Test: fast/dom/Document/document-reopen.html
+        Test: fast/dom/Document/doc-open-while-parsing.html
+
+        * dom/DocumentImpl.cpp:
+        (WebCore::DocumentImpl::open): Only ignore open() while the frame is still loading the main resource.
+        * page/Frame.cpp:
+        (WebCore::Frame::isComplete): Added const specifier.
+        (WebCore::Frame::isLoadingMainResource): New function.
+        * page/Frame.h:
+
 2006-03-15  Adele Peterson  <adele@apple.com>
 
         Reviewed by Eric.
index d851efdebbaff13362d971bc6f868cf41de71c6b..1d3a4286c8199320cbabac0d1d020e7ff4b87570 100644 (file)
@@ -1070,7 +1070,7 @@ Tokenizer *DocumentImpl::createTokenizer()
 
 void DocumentImpl::open()
 {
-    if (parsing())
+    if (frame() && frame()->isLoadingMainResource())
         return;
 
     implicitOpen();
index 33095b1ea0da59430dff67bf3d1738a22b1e30c4..a466604d28d2240935d73c81d9048b3cff8d762d 100644 (file)
@@ -3245,11 +3245,16 @@ NodeImpl *Frame::mousePressNode()
     return d->m_mousePressNode.get();
 }
 
-bool Frame::isComplete()
+bool Frame::isComplete() const
 {
     return d->m_bComplete;
 }
 
+bool Frame::isLoadingMainResource() const
+{
+    return d->m_bLoadingMainResource;
+}
+
 FrameTree *Frame::tree() const
 {
     return &d->m_treeNode;
index 77ca812cdd34d628e2a15cec110852890fca6d71..4bba90aad07ce1b2c558b000959a396242c51af7 100644 (file)
@@ -769,7 +769,8 @@ private:
   void prepareForUserAction();
   NodeImpl *mousePressNode();
 
-  bool isComplete();
+  bool isComplete() const;
+  bool isLoadingMainResource() const;
   
   void replaceContentsWithScriptResult(const KURL &url);