dom/plugins/test/mochitest/test_bug777098.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=777098
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 777098</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="application/javascript" src="utils.js"></script>
    11   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    12 </head>
    13 <body onload="go();">
    14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777098">Mozilla Bug 777098</a>
    15 <pre id="test">
    16 <script type="application/javascript">
    18 /** Test for passing dead NPObjects back into plugins. **/
    19 SimpleTest.waitForExplicitFinish();
    20 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    22 function go() {
    23   var plugin = document.getElementById('plugin');
    25   // Get wrapped npobject from plugin (plugin.__proto__)
    26   var val = plugin.getObjectValue();
    28   // Force a re-instantiate by re-setting dummy uri,
    29   // making val a wrapper for a dead plugin
    30   plugin.data = plugin.data;
    32   // The correct behavior is an exception, if plugin.checkObjectValue succeeds
    33   // the plugin wasn't torn down for some reason, and if we crash... that's bad
    34   function pluginCheck() {
    35     try {
    36       plugin.checkObjectValue(val);
    37     } catch (e) {
    38       return true;
    39     }
    40     return false;
    41   }
    43   // Spin the event loop so the instantiation can complete
    44   window.setTimeout(function () {
    45     ok(pluginCheck(), "Shouldn't explode");
    47     // All done.
    48     SimpleTest.finish();
    49   }, 0);
    50 }
    52 </script>
    53 </pre>
    55 <object data="data:text/plain,a" width=200 height=200 type="application/x-test" id="plugin"></object>
    57 </body>
    58 </html>

mercurial