2008-07-01 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2008 19:05:23 +0000 (19:05 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jul 2008 19:05:23 +0000 (19:05 +0000)
        Reviewed by Brady Eidson.

        Bug 19822: REGRESSION (r30243): setting location.hash to "#" causes a reload
        <https://bugs.webkit.org/show_bug.cgi?id=19822>

        Change JSLocation::setHash() to not schedule navigation in the case
        where the old fragment is the null String and the new fragment is an
        empty String.

        WebCore:

        * bindings/js/JSLocationCustom.cpp:
        (WebCore::JSLocation::setHash):

        LayoutTests:

        * http/tests/loading/location-hash-reload-cycle-expected.txt: Added.
        * http/tests/loading/location-hash-reload-cycle.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/loading/location-hash-reload-cycle-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/location-hash-reload-cycle.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/JSLocationCustom.cpp

index a727d6c28d3a0b5aae4a65da82ff0d800337ffd0..b23a30ba0edbfa9924c7a7092bd9e390ed1b5ae0 100644 (file)
@@ -1,3 +1,15 @@
+2008-07-01  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Brady Eidson.
+
+        Tests for:
+
+        Bug 19822: REGRESSION (r30243): setting location.hash to "#" causes a reload
+        <https://bugs.webkit.org/show_bug.cgi?id=19822>
+
+        * http/tests/loading/location-hash-reload-cycle-expected.txt: Added.
+        * http/tests/loading/location-hash-reload-cycle.html: Added.
+
 2008-07-01  Adam Roben  <aroben@apple.com>
 
         Roll out r34913, as it broke the Windows build due to bad casting
diff --git a/LayoutTests/http/tests/loading/location-hash-reload-cycle-expected.txt b/LayoutTests/http/tests/loading/location-hash-reload-cycle-expected.txt
new file mode 100644 (file)
index 0000000..146e7dc
--- /dev/null
@@ -0,0 +1,6 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didFinishLoadForFrame
+This test checks that no loader actions occur when setting window.location.hash to the empty string or "#". If this test fails when run in a browser, it will reload continuously. If this test fails when run in DumpRenderTree, the FrameLoader callback output will contain willPerformClientRedirectToURL callbacks.
diff --git a/LayoutTests/http/tests/loading/location-hash-reload-cycle.html b/LayoutTests/http/tests/loading/location-hash-reload-cycle.html
new file mode 100644 (file)
index 0000000..ecf7bc0
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<script>
+function runTests()
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+    
+    window.location.hash = "";
+    window.location.hash = "#";
+}
+</script>
+</head>
+<body onload="runTests();">
+<p>This test checks that no loader actions occur when setting window.location.hash to the empty string or "#". If this test fails when run in a browser, it will reload continuously. If this test fails when run in DumpRenderTree, the FrameLoader callback output will contain willPerformClientRedirectToURL callbacks.</p>
+</body>
+</html>
index 8c5ba167e43728dc8b41641c947961d3623afee0..9cb0f9931c6ef323955e4381e874de46274e02aa 100644 (file)
@@ -1,3 +1,17 @@
+2008-07-01  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Brady Eidson.
+
+        Bug 19822: REGRESSION (r30243): setting location.hash to "#" causes a reload
+        <https://bugs.webkit.org/show_bug.cgi?id=19822>
+
+        Change JSLocation::setHash() to not schedule navigation in the case
+        where the old fragment is the null String and the new fragment is an
+        empty String.
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::setHash):
+
 2008-06-30  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Adam.
index 77be340a040df1c73d8f13338453d2144563686c..5dccd8f8c6288296d926f4a121f3556cd6c32c4a 100644 (file)
@@ -213,10 +213,11 @@ void JSLocation::setHash(ExecState* exec, JSValue* value)
     ASSERT(frame);
 
     KURL url = frame->loader()->url();
+    String oldRef = url.ref();
     String str = value->toString(exec);
     if (str.startsWith("#"))
         str = str.substring(1);
-    if (url.ref() == str)
+    if (url.ref() == str || (oldRef.isNull() && str.isEmpty()))
         return;
     url.setRef(str);