dom/plugins/test/mochitest/test_bug967694.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_bug967694.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +<!doctype html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test for Bug 967694</title>
     1.8 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="application/javascript" src="utils.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.11 +
    1.12 +  <meta http-equiv="content-type" content="text/html; charset=utf-8">
    1.13 +</head>
    1.14 +<body>
    1.15 +<script type="application/javascript">
    1.16 +
    1.17 +// Touching a plugin from chrome scope should not spawn it, bug should
    1.18 +// synchronously spawn it from content scope
    1.19 +
    1.20 +setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.21 +
    1.22 +var plugin;
    1.23 +var spPlugin;
    1.24 +
    1.25 +function recreatePlugin() {
    1.26 +  if (plugin) {
    1.27 +    document.body.removeChild(plugin);
    1.28 +  }
    1.29 +  plugin = document.createElement("embed");
    1.30 +  plugin.type = "application/x-test";
    1.31 +
    1.32 +  document.body.appendChild(plugin);
    1.33 +  // Plugin should now be queued for async spawning.
    1.34 +  spPlugin = SpecialPowers.wrap(plugin);
    1.35 +
    1.36 +  is(spPlugin.displayedType, spPlugin.TYPE_PLUGIN, "Should be configured as plugin");
    1.37 +  ok(!spPlugin.hasRunningPlugin, "Should not be spawned yet");
    1.38 +}
    1.39 +
    1.40 +recreatePlugin();
    1.41 +
    1.42 +// Try various JS operations with chrome context
    1.43 +var thrown = false;
    1.44 +// Get and set non-existent Property
    1.45 +var hi = spPlugin._testShouldntExist;
    1.46 +spPlugin._testShouldntExist = 5;
    1.47 +// Call some test-plugin function
    1.48 +try {
    1.49 +  var val = spPlugin.getObjectValue();
    1.50 +} catch (e) {
    1.51 +  thrown = true;
    1.52 +}
    1.53 +
    1.54 +ok(thrown, "Function call should have thrown");
    1.55 +ok(!spPlugin.hasRunningPlugin, "Plugin should not have spawned");
    1.56 +
    1.57 +// Try property access from content
    1.58 +var hi = plugin._testShouldntExistContent;
    1.59 +ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
    1.60 +
    1.61 +// Property set
    1.62 +recreatePlugin();
    1.63 +plugin._testShouldntExistContent = 5;
    1.64 +ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
    1.65 +
    1.66 +// Call test plugin function. Should succeed.
    1.67 +recreatePlugin();
    1.68 +thrown = false;
    1.69 +try {
    1.70 +  var value = plugin.getObjectValue();
    1.71 +} catch (e) {
    1.72 +  thrown = true;
    1.73 +}
    1.74 +
    1.75 +ok(!thrown, "Call should have succeeded");
    1.76 +ok(spPlugin.hasRunningPlugin, "Call should have synchronously spawned plugin");
    1.77 +ok(plugin.checkObjectValue(value), "Plugin should recognize self");
    1.78 +
    1.79 +</script>
    1.80 +</body>
    1.81 +</html>

mercurial