Bug 640035 - Port |Bug 635844 - Update pushState to latest spec. Again.| to SeaMonkey. (mochitest-browser-chrome: permanent "browser_500328.js | Test timed out"); (Av1) Just copy it.
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 10 Mar 2011 11:20:15 +0100
changeset 7297 407379b3fee96a95223ad20318f0d9a84a8dc60b
parent 7296 a5df7cbbe13f1ea59979e825fe01cf9122ed161e
child 7316 141c656b38ea3cca9da1caef32153c9eb9dc266a
push idunknown
push userunknown
push dateunknown
bugs640035, 635844
Bug 640035 - Port |Bug 635844 - Update pushState to latest spec. Again.| to SeaMonkey. (mochitest-browser-chrome: permanent "browser_500328.js | Test timed out"); (Av1) Just copy it. r=iann.
suite/common/tests/browser/browser_500328.js
--- a/suite/common/tests/browser/browser_500328.js
+++ b/suite/common/tests/browser/browser_500328.js
@@ -39,22 +39,22 @@ function checkState(tab) {
   // from the popState event are as we expect them to be.
   //
   // We also add a node to the document's body when after going back and make
   // sure it's still there after we go forward -- this is to test that the two
   // history entries correspond to the same document.
 
   let popStateCount = 0;
 
-  tab.linkedBrowser.addEventListener("popstate", function(aEvent) {
+  let handler = function(aEvent) {
     let contentWindow = tab.linkedBrowser.contentWindow;
     if (popStateCount == 0) {
       popStateCount++;
-      ok(aEvent.state, "Event should have a state property.");
-      is(JSON.stringify(aEvent.state), JSON.stringify({obj1:1}),
+      //ok(aEvent.state, "Event should have a state property.");
+      is(JSON.stringify(tab.linkedBrowser.contentWindow.history.state), JSON.stringify({obj1:1}),
          "first popstate object.");
 
       // Add a node with id "new-elem" to the document.
       let doc = contentWindow.document;
       ok(!doc.getElementById("new-elem"),
          "doc shouldn't contain new-elem before we add it.");
       let elem = doc.createElement("div");
       elem.id = "new-elem";
@@ -72,21 +72,25 @@ function checkState(tab) {
       // previous entry, which is bad.
       let doc = contentWindow.document;
       let newElem = doc.getElementById("new-elem");
       ok(newElem, "doc should contain new-elem.");
       newElem.parentNode.removeChild(newElem);
       ok(!doc.getElementById("new-elem"), "new-elem should be removed.");
 
       // Clean up after ourselves and finish the test.
-      tab.linkedBrowser.removeEventListener("popstate", arguments.callee, false);
+      tab.linkedBrowser.removeEventListener("popstate", arguments.callee, true);
+      tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
       getBrowser().removeTab(tab);
       finish();
     }
-  }, true);
+  };
+
+  tab.linkedBrowser.addEventListener("load", handler, true);
+  tab.linkedBrowser.addEventListener("popstate", handler, true);
 
   tab.linkedBrowser.contentWindow.history.back();
 }
 
 function test() {
   // Tests session restore functionality of history.pushState and
   // history.replaceState().  (Bug 500328)
 
@@ -111,17 +115,17 @@ function test() {
       // After these push/replaceState calls, the window should have three
       // history entries:
       //   testURL (state object: null)      <-- oldest
       //   testURL (state object: {obj1:1})
       //   page2   (state object: {obj3:3})  <-- newest
       let contentWindow = tab.linkedBrowser.contentWindow;
       let history = contentWindow.history;
       history.pushState({obj1:1}, "title-obj1");
-      history.pushState({obj2:2}, "title-obj2", "page2");
+      history.pushState({obj2:2}, "title-obj2", "?foo");
       history.replaceState({obj3:3}, "title-obj3");
 
       let state = ss.getTabState(tab);
 
       // In order to make sure that setWindowState actually modifies the
       // window's state, we modify the state here.  checkState will fail if
       // this change isn't overwritten by setWindowState.
       history.replaceState({should_be_overwritten:true}, "title-overwritten");