1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_pluginstream_referer.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +<head> 1.5 + <title>Do plugin stream requests send the Referer header correctly?</title> 1.6 + <script type="application/javascript" 1.7 + src="/tests/SimpleTest/SimpleTest.js"></script> 1.8 + <script type="application/javascript" src="utils.js"></script> 1.9 + <link rel="stylesheet" type="text/css" 1.10 + href="/tests/SimpleTest/test.css" /> 1.11 + 1.12 +<body onload="runTests()"> 1.13 + <script class="testbody" type="application/javascript"> 1.14 + SimpleTest.waitForExplicitFinish(); 1.15 + setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.16 + 1.17 + var pending = 3; 1.18 + function testDone() { 1.19 + --pending; 1.20 + if (0 == pending) 1.21 + SimpleTest.finish() 1.22 + } 1.23 + 1.24 + function runTests() { 1.25 + var p = document.getElementById('plugin1'); 1.26 + var p2 = document.getElementById('plugin2'); 1.27 + 1.28 + ok(p.streamTest('plugin-stream-referer.sjs', false, null, null, 1.29 + function(r, t) { 1.30 + is(r, 0, "GET plugin-stream-referer.sjs"); 1.31 + is(t, "Referer found: " + window.location, 1.32 + "GET Referer correct"); 1.33 + testDone(); 1.34 + }, null, true), "referer GET"); 1.35 + 1.36 + ok(p.streamTest('plugin-stream-referer.sjs', true, "Dummy Data", null, 1.37 + function(r, t) { 1.38 + is(r, 0, "POST plugin-stream-referer.sjs"); 1.39 + is(t, "No Referer found", "POST Referer absent"); 1.40 + testDone(); 1.41 + }, null, true), "referer POST"); 1.42 + 1.43 + ok(p2.streamTest('plugin-stream-referer.sjs', false, null, null, 1.44 + function(r, t) { 1.45 + is(r, 0, "GET plugin-stream-referer.sjs (2)"); 1.46 + var expectedreferer = String(window.location).replace("test_pluginstream_referer.html", "loremipsum.xtest"); 1.47 + is(t, "Referer found: " + expectedreferer, 1.48 + "GET Referer correct with plugin src"); 1.49 + testDone(); 1.50 + }, null, true), "referer GET (2)"); 1.51 + 1.52 + } 1.53 + </script> 1.54 + 1.55 + <p id="display"></p> 1.56 + 1.57 + <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> 1.58 + <embed id="plugin2" type="application/x-test" src="loremipsum.xtest" width="200" height="200"></embed>