|
1 <!doctype html> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for Bug 967694</title> |
|
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="application/javascript" src="utils.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
8 |
|
9 <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
10 </head> |
|
11 <body> |
|
12 <script type="application/javascript"> |
|
13 |
|
14 // Touching a plugin from chrome scope should not spawn it, bug should |
|
15 // synchronously spawn it from content scope |
|
16 |
|
17 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
18 |
|
19 var plugin; |
|
20 var spPlugin; |
|
21 |
|
22 function recreatePlugin() { |
|
23 if (plugin) { |
|
24 document.body.removeChild(plugin); |
|
25 } |
|
26 plugin = document.createElement("embed"); |
|
27 plugin.type = "application/x-test"; |
|
28 |
|
29 document.body.appendChild(plugin); |
|
30 // Plugin should now be queued for async spawning. |
|
31 spPlugin = SpecialPowers.wrap(plugin); |
|
32 |
|
33 is(spPlugin.displayedType, spPlugin.TYPE_PLUGIN, "Should be configured as plugin"); |
|
34 ok(!spPlugin.hasRunningPlugin, "Should not be spawned yet"); |
|
35 } |
|
36 |
|
37 recreatePlugin(); |
|
38 |
|
39 // Try various JS operations with chrome context |
|
40 var thrown = false; |
|
41 // Get and set non-existent Property |
|
42 var hi = spPlugin._testShouldntExist; |
|
43 spPlugin._testShouldntExist = 5; |
|
44 // Call some test-plugin function |
|
45 try { |
|
46 var val = spPlugin.getObjectValue(); |
|
47 } catch (e) { |
|
48 thrown = true; |
|
49 } |
|
50 |
|
51 ok(thrown, "Function call should have thrown"); |
|
52 ok(!spPlugin.hasRunningPlugin, "Plugin should not have spawned"); |
|
53 |
|
54 // Try property access from content |
|
55 var hi = plugin._testShouldntExistContent; |
|
56 ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn"); |
|
57 |
|
58 // Property set |
|
59 recreatePlugin(); |
|
60 plugin._testShouldntExistContent = 5; |
|
61 ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn"); |
|
62 |
|
63 // Call test plugin function. Should succeed. |
|
64 recreatePlugin(); |
|
65 thrown = false; |
|
66 try { |
|
67 var value = plugin.getObjectValue(); |
|
68 } catch (e) { |
|
69 thrown = true; |
|
70 } |
|
71 |
|
72 ok(!thrown, "Call should have succeeded"); |
|
73 ok(spPlugin.hasRunningPlugin, "Call should have synchronously spawned plugin"); |
|
74 ok(plugin.checkObjectValue(value), "Plugin should recognize self"); |
|
75 |
|
76 </script> |
|
77 </body> |
|
78 </html> |