dom/plugins/test/mochitest/test_bug967694.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial