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