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.

     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"/>
     9   <meta http-equiv="content-type" content="text/html; charset=utf-8">
    10 </head>
    11 <body>
    12 <script type="application/javascript">
    14 // Touching a plugin from chrome scope should not spawn it, bug should
    15 // synchronously spawn it from content scope
    17 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    19 var plugin;
    20 var spPlugin;
    22 function recreatePlugin() {
    23   if (plugin) {
    24     document.body.removeChild(plugin);
    25   }
    26   plugin = document.createElement("embed");
    27   plugin.type = "application/x-test";
    29   document.body.appendChild(plugin);
    30   // Plugin should now be queued for async spawning.
    31   spPlugin = SpecialPowers.wrap(plugin);
    33   is(spPlugin.displayedType, spPlugin.TYPE_PLUGIN, "Should be configured as plugin");
    34   ok(!spPlugin.hasRunningPlugin, "Should not be spawned yet");
    35 }
    37 recreatePlugin();
    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 }
    51 ok(thrown, "Function call should have thrown");
    52 ok(!spPlugin.hasRunningPlugin, "Plugin should not have spawned");
    54 // Try property access from content
    55 var hi = plugin._testShouldntExistContent;
    56 ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
    58 // Property set
    59 recreatePlugin();
    60 plugin._testShouldntExistContent = 5;
    61 ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
    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 }
    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");
    76 </script>
    77 </body>
    78 </html>

mercurial