Bug 653364 - HashChange event should have isTrusted property. r=bz
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 28 Apr 2011 16:13:03 -0400
changeset 69024 5efc266040c70127c38e63e0e3f99a8a93bc2afa
parent 69023 89b1fa4c4e3d9b18a4f7e2bcc4f92716c2d09c10
child 69025 2e000b193b234fad6fbff95a88b623e0f5b11bd7
push id19830
push userjlebar@mozilla.com
push dateThu, 05 May 2011 20:38:40 +0000
treeherdermozilla-central@5efc266040c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs653364
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 653364 - HashChange event should have isTrusted property. r=bz
dom/base/nsDOMClassInfo.cpp
dom/tests/mochitest/general/Makefile.in
dom/tests/mochitest/general/test_bug628069_1.html
dom/tests/mochitest/general/test_bug628069_2.html
dom/tests/mochitest/general/test_bug653364.html
dom/tests/mochitest/whatwg/test_bug500328.html
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2615,17 +2615,17 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(PopStateEvent, nsIDOMPopStateEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopStateEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(HashChangeEvent, nsIDOMHashChangeEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHashChangeEvent)
-    DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
+    DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   if (nsDOMTouchEvent::PrefEnabled()) {
     DOM_CLASSINFO_MAP_BEGIN(HTMLDocument, nsIDOMHTMLDocument)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLDocument)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentTouch)
       DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
--- a/dom/tests/mochitest/general/Makefile.in
+++ b/dom/tests/mochitest/general/Makefile.in
@@ -49,16 +49,17 @@ include $(topsrcdir)/config/rules.mk
 		489127.html \
 		historyframes.html \
 		test_497898.html \
 		test_bug504220.html \
 		test_bug628069_1.html \
 		test_bug628069_2.html \
 		file_bug628069.html \
 		test_bug631440.html \
+		test_bug653364.html \
 		test_consoleAPI.html \
 		test_domWindowUtils.html \
 		test_domWindowUtils_scrollXY.html \
 		test_innerScreen.xul \
 		test_offsets.html \
 		test_offsets.js \
 		test_offsets.xul \
 		test_windowProperties.html \
--- a/dom/tests/mochitest/general/test_bug628069_1.html
+++ b/dom/tests/mochitest/general/test_bug628069_1.html
@@ -36,15 +36,16 @@ function childLoad() {
 
   // This should trigger a hashchange, so control should flow down to
   // childHashchange.
 }
 
 function childHashchange(e) {
   is(e.oldURL, gOrigURL, 'event.oldURL');
   is(e.newURL, gOrigURL + '#hash', 'event.newURL');
+  is(e.isTrusted, true, 'Hashchange event should be trusted.');
   popup.close();
   SimpleTest.finish();
 }
 
 </script>
 </body>
 </html>
--- a/dom/tests/mochitest/general/test_bug628069_2.html
+++ b/dom/tests/mochitest/general/test_bug628069_2.html
@@ -22,16 +22,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 628069 **/
 
 gotHashChange = 0;
 document.addEventListener("hashChange", function(e) {
   gotHashChange = 1;
   is(e.oldURL, "oldURL");
   is(e.newURL, "newURL");
+  is(e.isTrusted, false, "Hashchange event shouldn't be trusted.");
 }, true);
 
 let hc = document.createEvent("HashChangeEvent");
 hc.initHashChangeEvent("hashChange", true, false, "oldURL", "newURL");
 document.documentElement.dispatchEvent(hc);
 is(gotHashChange, 1, 'Document received hashchange event.');
 
 </script>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/general/test_bug653364.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=653364
+-->
+<head>
+  <title>Test for Bug 653364</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=653364">Mozilla Bug 653364</a>
+<p id="display"></p>
+<div id="content">
+  <iframe id="frame" style="height:100px; width:100px; border:0"></iframe>
+  <div id="status" style="display: none"></div>
+</div>
+<pre id="test">
+<script type="application/javascript;version=1.7">
+
+/** Test for Bug 653364 **/
+
+gotPopState = 0;
+document.addEventListener("popState", function(e) {
+  gotPopState = 1;
+  is(e.state.foo, 'bar', "PopState event should have state we set.");
+  is(e.isTrusted, false, "PopState event shouldn't be trusted.");
+}, true);
+
+let ps = document.createEvent("PopStateEvent");
+ps.initPopStateEvent("popState", true, false, {'foo': 'bar'});
+document.documentElement.dispatchEvent(ps);
+is(gotPopState, 1, 'Document received PopState event.');
+
+</script>
+</body>
+</html>
--- a/dom/tests/mochitest/whatwg/test_bug500328.html
+++ b/dom/tests/mochitest/whatwg/test_bug500328.html
@@ -269,16 +269,17 @@ function runTest() {
   statusMsg("About to go back to page 1.");
   // We don't have to yield here because this back() and the resulting popstate
   // are completely synchronous.  In fact, if we did yield, JS would throw an
   // error because we'd be calling gGen.next from within gGen.next.
   iframeCw.history.back();
 
   statusMsg("Awake after going back to page 1.");
   popstateExpected("Going back to page 1 should trigger a popstate.");
+  is(gLastPopStateEvent.isTrusted, true, 'Popstate event should be trusted.');
   is(JSON.stringify(gLastPopStateEvent.state), JSON.stringify(testObj1),
      "Wrong state object popped after going back to page 1.");
   ok(gLastPopStateEvent.state === iframeCw.history.state,
      "Wrong state object in document after going back to page 1.");
   ok(iframeCw.location.toString().match(/file_bug500328_1.html$/),
       "Going back to page 1 hould take us to original page.");
 
   iframeCw.history.back();