content/base/test/test_bug827160.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4bc99aa972cc
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=827160
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 827160</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="/tests/SimpleTest/SpecialPowers.js"></script>
11 <script type="application/javascript" src="utils.js"></script>
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 </head>
14 <body>
15 <a target="_blank" href=https://bugzilla.mozilla.org/show_bug.cgi?id=827160">Mozilla Bug 827160</a>
16
17 <script type="application/javascript">
18
19 // Make sure the test plugin is not click-to-play
20 var pluginHost = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
21 .getService(SpecialPowers.Ci.nsIPluginHost);
22 var pluginTags = pluginHost.getPluginTags();
23 for (var tag of pluginTags) {
24 if (tag.name == "Test Plug-in" || tag.name == "Second Test Plug-in") {
25 var oldEnabledState = tag.enabledState;
26 tag.enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;
27 SimpleTest.registerCleanupFunction(function() {
28 tag.enabledState = oldEnabledState;
29 });
30 }
31 }
32
33 </script>
34
35 <!-- Should load test plugin application/x-test -->
36 <object id="shouldLoad" data="data:application/x-test,foo"></object>
37 <!-- Should load test plugin application/x-test2, ignoring type="" -->
38 <object id="shouldIgnoreType" type="application/x-test" data="data:application/x-test2,foo"></object>
39 <!-- Should load nothing, channel type does not match type and typeMustMatch is present -->
40 <object id="shouldNotLoad" type="application/x-test" data="data:application/x-test2,foo" typemustmatch></object>
41 <!-- Should not load test plugin application/x-test2, no type field is present -->
42 <object id="shouldNotLoadMissingType" data="data:application/x-test2,foo" typemustmatch></object>
43 <!-- Should load, no data field is present -->
44 <object id="shouldLoadMissingData" type="application/x-test" typemustmatch></object>
45 <pre id="test">
46
47 <script type="application/javascript">
48 SimpleTest.waitForExplicitFinish();
49
50 window.addEventListener("load", function () {
51 const OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
52 is(SpecialPowers.wrap(document.getElementById("shouldLoad")).displayedType, OBJLC.TYPE_PLUGIN, "Testing object load without type, failed expected load");
53 is(SpecialPowers.wrap(document.getElementById("shouldIgnoreType")).displayedType, OBJLC.TYPE_PLUGIN, "Testing object load with type, failed expected load");
54 is(SpecialPowers.wrap(document.getElementById("shouldNotLoad")).displayedType, OBJLC.TYPE_NULL, "Testing object load with typemustmatch, load success even though failure expected");
55 is(SpecialPowers.wrap(document.getElementById("shouldNotLoadMissingType")).displayedType, OBJLC.TYPE_NULL, "Testing object load with typemustmatch and with type, load success even though failure expected");
56 is(SpecialPowers.wrap(document.getElementById("shouldLoadMissingData")).displayedType, OBJLC.TYPE_PLUGIN, "Testing object load with typemustmatch and without data, failed expected load");
57 SimpleTest.finish();
58 }, false);
59
60 </script>
61 </pre>
62 </body>
63 </html>

mercurial