OLD | NEW |
| (Empty) |
1 <html> | |
2 <script> | |
3 function runTest() | |
4 { | |
5 if (window.testRunner) | |
6 testRunner.dumpAsText(); | |
7 | |
8 var plugin = document.getElementById("testPlugin"); | |
9 var result = document.getElementById('result'); | |
10 | |
11 // First test NPN_Enumerate from the plugin's side | |
12 var testObject = { "one" : 1, "two" : 2, "three" : 3, 4 : 4 } | |
13 var outArray = []; | |
14 plugin.testEnumerate(testObject, outArray); | |
15 | |
16 if (outArray.sort().toString() != '4,one,three,two') { | |
17 result.innerHTML = 'FAILURE: Array returned from plugin was ' + outArray
.toString(); | |
18 return; | |
19 } | |
20 | |
21 // Now try enumerating a plugin object's properties | |
22 var propNames = []; | |
23 for (var v in plugin.testObject) { | |
24 propNames.push(v); | |
25 } | |
26 | |
27 if (propNames.sort().toString() != 'bar,foo') { | |
28 result.innerHTML = 'FAILURE: Plugin object properties was ' + propNames.
toString(); | |
29 return; | |
30 } | |
31 | |
32 // Now try enumerating a plugin object's properties using Object.keys | |
33 var keys = Object.keys(plugin.testObject); | |
34 if (keys.sort().toString() != 'bar,foo') { | |
35 result.innerHTML = 'FAILURE: Plugin object properties returned by Object
.keys were ' + keys.toString(); | |
36 return; | |
37 } | |
38 | |
39 result.innerHTML = 'SUCCESS'; | |
40 } | |
41 </script> | |
42 | |
43 <body onload="runTest();"> | |
44 <embed id="testPlugin" type="application/x-webkit-test-netscape" width="200" hei
ght="200"></embed> | |
45 This tests that a plugin can enumerate an object's properties using NPN_Enumerat
e. It also tests that JavaScript can enumerate a plugin object's properties. If
this test is successful the text "SUCCESS" will be show below. | |
46 <div id="result">FAILURE</div> | |
47 </body> | |
48 </html> | |
OLD | NEW |