2007-12-11 00:18:04 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=368835
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 368835</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=368835">
|
|
|
|
Mozilla Bug 368835
|
|
|
|
</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
function dataContainerEventHandler(aEvent)
|
|
|
|
{
|
|
|
|
var value = "";
|
|
|
|
var isPassed = true;
|
|
|
|
try {
|
|
|
|
value = aEvent.getData("data1");
|
|
|
|
isPassed = true;
|
|
|
|
} catch (e) {
|
|
|
|
isPassed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(isPassed, "getData shouldn't fail.");
|
|
|
|
ok(value == "data1", "Wrong value of data.");
|
|
|
|
|
2013-05-16 07:10:30 -07:00
|
|
|
is(aEvent.getData("document"), document);
|
|
|
|
is(aEvent.getData("window"), window);
|
|
|
|
is(aEvent.getData("event"), aEvent);
|
|
|
|
is(aEvent.getData("null"), null);
|
|
|
|
is(aEvent.getData("1"), 1);
|
|
|
|
is(aEvent.getData("1.1"), 1.1);
|
|
|
|
is(aEvent.getData("true"), true);
|
|
|
|
|
2007-12-11 00:18:04 -08:00
|
|
|
try {
|
|
|
|
aEvent.setData("data3", "data3");
|
|
|
|
isPassed = false;
|
|
|
|
} catch (e) {
|
|
|
|
isPassed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(isPassed, "setData should fail during event dispatching.");
|
|
|
|
}
|
|
|
|
|
|
|
|
function doTest()
|
|
|
|
{
|
|
|
|
var isPassed;
|
|
|
|
var event = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
event = document.createEvent("datacontainerevents");
|
|
|
|
isPassed = true;
|
|
|
|
} catch (e) {
|
|
|
|
isPassed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(isPassed, "Document should know about 'datacontainerevents' event class.");
|
|
|
|
ok(("setData" in event), "nsIDOMDataContainerEvent isn't available.");
|
|
|
|
|
|
|
|
event.initEvent("dataContainerEvent", true, true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
event.setData("data1", "data1");
|
2013-05-16 07:10:30 -07:00
|
|
|
event.setData("document", document);
|
|
|
|
event.setData("window", window);
|
|
|
|
event.setData("event", event);
|
|
|
|
event.setData("null", null);
|
|
|
|
event.setData("1", 1);
|
|
|
|
event.setData("1.1", 1.1);
|
|
|
|
event.setData("true", true);
|
2007-12-11 00:18:04 -08:00
|
|
|
isPassed = true;
|
|
|
|
} catch (e) {
|
|
|
|
isPassed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(isPassed, "setData shouldn't fail when event is initialized.");
|
|
|
|
|
|
|
|
document.body.addEventListener("dataContainerEvent",
|
|
|
|
dataContainerEventHandler, true);
|
|
|
|
document.body.dispatchEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addLoadEvent(doTest);
|
|
|
|
addLoadEvent(SimpleTest.finish);
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|