Bug 653364 - HashChange event should have isTrusted property. r=bz

--HG--
extra : rebase_source : 6829b06980ed01c38e0cc5b88a9428fc784c1bb0
This commit is contained in:
Justin Lebar 2011-04-28 16:13:03 -04:00
Родитель e58e8b7ac3
Коммит de8d6b2b66
6 изменённых файлов: 44 добавлений и 1 удалений

Просмотреть файл

@ -2620,7 +2620,7 @@ nsDOMClassInfo::Init()
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()) {

Просмотреть файл

@ -54,6 +54,7 @@ _TEST_FILES = \
test_bug628069_2.html \
file_bug628069.html \
test_bug631440.html \
test_bug653364.html \
test_consoleAPI.html \
test_domWindowUtils.html \
test_domWindowUtils_scrollXY.html \

Просмотреть файл

@ -41,6 +41,7 @@ function childLoad() {
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();
}

Просмотреть файл

@ -27,6 +27,7 @@ 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");

Просмотреть файл

@ -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>

Просмотреть файл

@ -274,6 +274,7 @@ function runTest() {
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,