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

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

mercurial