gecko/dom/plugins/test/mochitest/test_npruntime_identifiers.html

60 lines
1.5 KiB
HTML

<html>
<head>
<title>NPN_Invoke Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<script class="testbody" type="application/javascript">
////
// This test exercises NP identifiers by querying the reflector to make sure
// that identifiers are translated to values correctly.
SimpleTest.waitForExplicitFinish();
var testsRun = 0;
function doTest() {
SpecialPowers.gc();
var reflector = document.getElementById("subframe").contentDocument.getElementById("plugin1").getReflector();
var i, prop, randomnumber;
for (i = 0; i < 20; ++i) {
randomnumber=Math.floor(Math.random()*1001);
prop = "prop" + randomnumber;
is(reflector[prop], prop, "Property " + prop);
}
for (i = -10; i < 10; ++i) {
is(reflector[i], i, "Property " + i);
prop = "prop" + i;
is(reflector[prop], prop, "Property " + prop);
}
is(reflector.a, 'a', "Property .a");
is(reflector['a'], 'a', "Property ['a']");
reflector = null;
SpecialPowers.gc();
++testsRun;
if (testsRun == 3) {
SimpleTest.finish();
}
else {
document.getElementById('subframe').contentWindow.location.reload(true);
}
}
</script>
<iframe id="subframe" src="npruntime_identifiers_subpage.html" onload="doTest()"></iframe>
</body>
</html>