2007-07-04 Matt Perry <mpComplete@gmail.com>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2007 06:08:56 +0000 (06:08 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2007 06:08:56 +0000 (06:08 +0000)
        Fix for http://bugs.webkit.org/show_bug.cgi?id=13400
        Bug 13400: REGRESSION (r20809-20814): No back entry created for navigations created by assigning to document.location
        <rdar://problem/5153025>

        Treat userGesture as always true for setLocation, forcing a back/forward
        entry to be created.

        * bindings/js/JSHTMLDocumentCustom.cpp:
        (WebCore::JSHTMLDocument::setLocation):

2007-07-04  Matt Perry  <mpComplete@gmail.com>

        Test for http://bugs.webkit.org/show_bug.cgi?id=13400
        Bug 13400: REGRESSION (r20809-20814): No back entry created for navigations created by assigning to document.location
        <rdar://problem/5153025>

        Test that assigning to document.location in various ways adds an
        item to the back/forward list.

        * http/tests/navigation/document-location-click-expected.txt: Added.
        * http/tests/navigation/document-location-click-timeout-expected.txt: Added.
        * http/tests/navigation/document-location-click-timeout.html: Added.
        * http/tests/navigation/document-location-click.html: Added.
        * http/tests/navigation/document-location-mouseover-expected.txt: Added.
        * http/tests/navigation/document-location-mouseover.html: Added.
        * http/tests/navigation/document-location-onload-expected.txt: Added.
        * http/tests/navigation/document-location-onload.html: Added.
        * http/tests/navigation/resources/document-location.js: Added.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/document-location-click-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-click-timeout-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-click-timeout.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-click.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-mouseover-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-mouseover.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-onload-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-location-onload.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/document-location.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/JSHTMLDocumentCustom.cpp

index ab458d6..9da484c 100644 (file)
@@ -1,3 +1,22 @@
+2007-07-04  Matt Perry  <mpComplete@gmail.com>
+
+        Test for http://bugs.webkit.org/show_bug.cgi?id=13400
+        Bug 13400: REGRESSION (r20809-20814): No back entry created for navigations created by assigning to document.location
+        <rdar://problem/5153025>
+
+        Test that assigning to document.location in various ways adds an
+        item to the back/forward list.
+
+        * http/tests/navigation/document-location-click-expected.txt: Added.
+        * http/tests/navigation/document-location-click-timeout-expected.txt: Added.
+        * http/tests/navigation/document-location-click-timeout.html: Added.
+        * http/tests/navigation/document-location-click.html: Added.
+        * http/tests/navigation/document-location-mouseover-expected.txt: Added.
+        * http/tests/navigation/document-location-mouseover.html: Added.
+        * http/tests/navigation/document-location-onload-expected.txt: Added.
+        * http/tests/navigation/document-location-onload.html: Added.
+        * http/tests/navigation/resources/document-location.js: Added.
+
 2007-07-04  Darin Adler  <darin@apple.com>
 
         - take out infinity tests from the test for bug 5292262 (see below) for now since they
diff --git a/LayoutTests/http/tests/navigation/document-location-click-expected.txt b/LayoutTests/http/tests/navigation/document-location-click-expected.txt
new file mode 100644 (file)
index 0000000..21b9d50
--- /dev/null
@@ -0,0 +1,6 @@
+This tests that assigning to document.location from a button click adds a back/forward item. Navigate
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-location-click.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-location-click.html?1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-location-click-timeout-expected.txt b/LayoutTests/http/tests/navigation/document-location-click-timeout-expected.txt
new file mode 100644 (file)
index 0000000..c62d6fb
--- /dev/null
@@ -0,0 +1,6 @@
+This tests that assigning to document.location from a timeout in a button click adds a back/forward item. Navigate
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-location-click-timeout.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-location-click-timeout.html?1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-location-click-timeout.html b/LayoutTests/http/tests/navigation/document-location-click-timeout.html
new file mode 100644 (file)
index 0000000..4573845
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script src="resources/document-location.js"></script>
+<script>
+  function runTest() {
+    // Simulate clicking the Navigate button.
+    var button = document.getElementById("navigate");
+    var x = button.offsetLeft + button.offsetWidth / 2;
+    var y = button.offsetTop + button.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown(); 
+    eventSender.mouseUp(); 
+  }
+</script>
+</head>
+<body onload="start()">
+This tests that assigning to document.location from a timeout in a button click
+adds a back/forward item.
+<button onclick="setTimeout('setLocation()', 0)" id="navigate">Navigate</button>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-location-click.html b/LayoutTests/http/tests/navigation/document-location-click.html
new file mode 100644 (file)
index 0000000..2037172
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script src="resources/document-location.js"></script>
+<script>
+  function runTest() {
+    // Simulate clicking the Navigate button.
+    var button = document.getElementById("navigate");
+    var x = button.offsetLeft + button.offsetWidth / 2;
+    var y = button.offsetTop + button.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown(); 
+    eventSender.mouseUp(); 
+  }
+</script>
+</head>
+<body onload="start()">
+This tests that assigning to document.location from a button click adds a
+back/forward item.
+<button onclick="setLocation()" id="navigate">Navigate</button>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-location-mouseover-expected.txt b/LayoutTests/http/tests/navigation/document-location-mouseover-expected.txt
new file mode 100644 (file)
index 0000000..87649e2
--- /dev/null
@@ -0,0 +1,6 @@
+This tests that assigning to document.location from a button click adds a back/forward item. Navigate
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-location-mouseover.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-location-mouseover.html?1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-location-mouseover.html b/LayoutTests/http/tests/navigation/document-location-mouseover.html
new file mode 100644 (file)
index 0000000..8813e55
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script src="resources/document-location.js"></script>
+<script>
+  function runTest() {
+    // Simulate mousing over the Navigate button.
+    var button = document.getElementById("navigate");
+    var x = button.offsetLeft + button.offsetWidth / 2;
+    var y = button.offsetTop + button.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseMoveTo(0, 0);
+  }
+</script>
+</head>
+<body onload="start()">
+This tests that assigning to document.location from a button click adds a
+back/forward item.
+<button onmouseover="setLocation()" id="navigate">Navigate</button>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-location-onload-expected.txt b/LayoutTests/http/tests/navigation/document-location-onload-expected.txt
new file mode 100644 (file)
index 0000000..1581cb7
--- /dev/null
@@ -0,0 +1,6 @@
+This tests that assigning to document.location from a timeout from the onload handler adds a back/forward item.
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-location-onload.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-location-onload.html?1  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-location-onload.html b/LayoutTests/http/tests/navigation/document-location-onload.html
new file mode 100644 (file)
index 0000000..8a12e8e
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+<head>
+<script src="resources/document-location.js"></script>
+<script>
+  function runTest() {
+    setTimeout('setLocation()', 0);
+  }
+</script>
+</head>
+<body onload="start()">
+This tests that assigning to document.location from a timeout from the onload
+handler adds a back/forward item.
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/resources/document-location.js b/LayoutTests/http/tests/navigation/resources/document-location.js
new file mode 100644 (file)
index 0000000..1db48cd
--- /dev/null
@@ -0,0 +1,21 @@
+function start() {
+  if (window.layoutTestController) {
+    var n = document.location.search.substring(1);
+    if (!n) {
+      // page just opened
+      layoutTestController.dumpBackForwardList();
+      layoutTestController.dumpAsText();
+      layoutTestController.waitUntilDone();
+
+      runTest();
+    } else {
+      // loaded the ?1 navigation
+      layoutTestController.notifyDone();
+    }
+  }
+}
+
+function setLocation() {
+  document.location = "?1"
+}
+
index 83754ca..952c9a9 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-04  Matt Perry  <mpComplete@gmail.com>
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=13400
+        Bug 13400: REGRESSION (r20809-20814): No back entry created for navigations created by assigning to document.location
+        <rdar://problem/5153025>
+
+        Treat userGesture as always true for setLocation, forcing a back/forward
+        entry to be created.
+
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::JSHTMLDocument::setLocation):
+
 2007-07-04  Adam Roben  <aroben@apple.com>
 
         Restore MouseEventWithHitTestResults::targetNode's old behavior
index b8ddda9..168cae0 100644 (file)
@@ -115,9 +115,8 @@ void JSHTMLDocument::setLocation(ExecState* exec, JSValue* value)
     if (activeFrame)
         str = activeFrame->document()->completeURL(str);
 
-    // We want a new history item if this JS was called via a user gesture
-    bool userGesture = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture();
-    frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture);
+    // We always want a new history item when assigning to document.location.
+    frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), false, true);
 }
 
 // Custom functions