Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test for Bug 738396</title>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/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="text/javascript">
13 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED,
14 "Java Test Plug-in");
16 SpecialPowers.pushPrefEnv({ "set": [
17 ['plugin.java.mime', 'application/x-java-test']
18 ] }, loadFrame);
19 SimpleTest.waitForExplicitFinish();
21 function loadFrame() {
22 var iframe = document.createElement("iframe");
23 iframe.src = "./file_bug738396.html";
24 iframe.addEventListener("load", function() {
25 runTest(iframe.contentDocument);
26 });
27 document.body.appendChild(iframe);
28 }
30 function runTest(doc) {
31 // Check that the canonicalized version of the codebase 'good' was passed
32 // to the plugin in all cases
33 var a = doc.createElement('a');
34 a.href = "good";
35 var goodCodebase = a.href;
36 var codebasevis = doc.getElementById("codebasevis")
37 .querySelectorAll("applet, object, embed");
38 for (var elem of codebasevis) {
39 var codebase = null;
40 try {
41 codebase = elem.getJavaCodebase();
42 } catch (e) {}
43 is(codebase, goodCodebase,
44 "Check that the test plugin sees the proper codebase");
45 }
46 // Check that none of the applets in blockedcodebase were allowed to spawn
47 var blockedcodebase = doc.getElementById("blockedcodebase")
48 .querySelectorAll("applet, object, embed");
49 for (var elem of blockedcodebase) {
50 var spawned = false;
51 try {
52 elem.getObjectValue();
53 spawned = true;
54 } catch (e) {}
55 ok(!spawned, "Plugin should not be allowed to spawn");
56 }
58 // With no codebase, the codebase should resolve to "."
59 a.href = ".";
60 goodCodebase = a.href;
61 var nocodebase = doc.getElementById("nocodebase")
62 .querySelectorAll("applet, object, embed");
63 for (var elem of nocodebase) {
64 var codebase = null;
65 try {
66 codebase = elem.getJavaCodebase();
67 } catch (e) {}
68 is(codebase, goodCodebase, "Codebase should resolve to '.'");
69 }
71 // With empty codebase, the codebase should resolve to "/"
72 a.href = "/";
73 goodCodebase = a.href;
74 var nocodebase = doc.getElementById("emptycodebase")
75 .querySelectorAll("applet, object, embed");
76 for (var elem of nocodebase) {
77 var codebase = null;
78 try {
79 codebase = elem.getJavaCodebase();
80 } catch (e) {}
81 is(codebase, goodCodebase, "Codebase should resolve to '/'");
82 }
84 SimpleTest.finish();
85 }
86 </script>
87 </body>
88 </html>