1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_bug738396.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +<!doctype html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for Bug 738396</title> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="utils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.11 + 1.12 + <meta http-equiv="content-type" content="text/html; charset=utf-8"> 1.13 +</head> 1.14 +<body> 1.15 + <script type="text/javascript"> 1.16 + setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, 1.17 + "Java Test Plug-in"); 1.18 + 1.19 + SpecialPowers.pushPrefEnv({ "set": [ 1.20 + ['plugin.java.mime', 'application/x-java-test'] 1.21 + ] }, loadFrame); 1.22 + SimpleTest.waitForExplicitFinish(); 1.23 + 1.24 + function loadFrame() { 1.25 + var iframe = document.createElement("iframe"); 1.26 + iframe.src = "./file_bug738396.html"; 1.27 + iframe.addEventListener("load", function() { 1.28 + runTest(iframe.contentDocument); 1.29 + }); 1.30 + document.body.appendChild(iframe); 1.31 + } 1.32 + 1.33 + function runTest(doc) { 1.34 + // Check that the canonicalized version of the codebase 'good' was passed 1.35 + // to the plugin in all cases 1.36 + var a = doc.createElement('a'); 1.37 + a.href = "good"; 1.38 + var goodCodebase = a.href; 1.39 + var codebasevis = doc.getElementById("codebasevis") 1.40 + .querySelectorAll("applet, object, embed"); 1.41 + for (var elem of codebasevis) { 1.42 + var codebase = null; 1.43 + try { 1.44 + codebase = elem.getJavaCodebase(); 1.45 + } catch (e) {} 1.46 + is(codebase, goodCodebase, 1.47 + "Check that the test plugin sees the proper codebase"); 1.48 + } 1.49 + // Check that none of the applets in blockedcodebase were allowed to spawn 1.50 + var blockedcodebase = doc.getElementById("blockedcodebase") 1.51 + .querySelectorAll("applet, object, embed"); 1.52 + for (var elem of blockedcodebase) { 1.53 + var spawned = false; 1.54 + try { 1.55 + elem.getObjectValue(); 1.56 + spawned = true; 1.57 + } catch (e) {} 1.58 + ok(!spawned, "Plugin should not be allowed to spawn"); 1.59 + } 1.60 + 1.61 + // With no codebase, the codebase should resolve to "." 1.62 + a.href = "."; 1.63 + goodCodebase = a.href; 1.64 + var nocodebase = doc.getElementById("nocodebase") 1.65 + .querySelectorAll("applet, object, embed"); 1.66 + for (var elem of nocodebase) { 1.67 + var codebase = null; 1.68 + try { 1.69 + codebase = elem.getJavaCodebase(); 1.70 + } catch (e) {} 1.71 + is(codebase, goodCodebase, "Codebase should resolve to '.'"); 1.72 + } 1.73 + 1.74 + // With empty codebase, the codebase should resolve to "/" 1.75 + a.href = "/"; 1.76 + goodCodebase = a.href; 1.77 + var nocodebase = doc.getElementById("emptycodebase") 1.78 + .querySelectorAll("applet, object, embed"); 1.79 + for (var elem of nocodebase) { 1.80 + var codebase = null; 1.81 + try { 1.82 + codebase = elem.getJavaCodebase(); 1.83 + } catch (e) {} 1.84 + is(codebase, goodCodebase, "Codebase should resolve to '/'"); 1.85 + } 1.86 + 1.87 + SimpleTest.finish(); 1.88 + } 1.89 +</script> 1.90 +</body> 1.91 +</html>