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 | <head> |
michael@0 | 2 | <title>Do plugin stream requests send the Referer header correctly?</title> |
michael@0 | 3 | <script type="application/javascript" |
michael@0 | 4 | src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 5 | <script type="application/javascript" src="utils.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" |
michael@0 | 7 | href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <body onload="runTests()"> |
michael@0 | 10 | <script class="testbody" type="application/javascript"> |
michael@0 | 11 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 12 | setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
michael@0 | 13 | |
michael@0 | 14 | var pending = 3; |
michael@0 | 15 | function testDone() { |
michael@0 | 16 | --pending; |
michael@0 | 17 | if (0 == pending) |
michael@0 | 18 | SimpleTest.finish() |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function runTests() { |
michael@0 | 22 | var p = document.getElementById('plugin1'); |
michael@0 | 23 | var p2 = document.getElementById('plugin2'); |
michael@0 | 24 | |
michael@0 | 25 | ok(p.streamTest('plugin-stream-referer.sjs', false, null, null, |
michael@0 | 26 | function(r, t) { |
michael@0 | 27 | is(r, 0, "GET plugin-stream-referer.sjs"); |
michael@0 | 28 | is(t, "Referer found: " + window.location, |
michael@0 | 29 | "GET Referer correct"); |
michael@0 | 30 | testDone(); |
michael@0 | 31 | }, null, true), "referer GET"); |
michael@0 | 32 | |
michael@0 | 33 | ok(p.streamTest('plugin-stream-referer.sjs', true, "Dummy Data", null, |
michael@0 | 34 | function(r, t) { |
michael@0 | 35 | is(r, 0, "POST plugin-stream-referer.sjs"); |
michael@0 | 36 | is(t, "No Referer found", "POST Referer absent"); |
michael@0 | 37 | testDone(); |
michael@0 | 38 | }, null, true), "referer POST"); |
michael@0 | 39 | |
michael@0 | 40 | ok(p2.streamTest('plugin-stream-referer.sjs', false, null, null, |
michael@0 | 41 | function(r, t) { |
michael@0 | 42 | is(r, 0, "GET plugin-stream-referer.sjs (2)"); |
michael@0 | 43 | var expectedreferer = String(window.location).replace("test_pluginstream_referer.html", "loremipsum.xtest"); |
michael@0 | 44 | is(t, "Referer found: " + expectedreferer, |
michael@0 | 45 | "GET Referer correct with plugin src"); |
michael@0 | 46 | testDone(); |
michael@0 | 47 | }, null, true), "referer GET (2)"); |
michael@0 | 48 | |
michael@0 | 49 | } |
michael@0 | 50 | </script> |
michael@0 | 51 | |
michael@0 | 52 | <p id="display"></p> |
michael@0 | 53 | |
michael@0 | 54 | <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> |
michael@0 | 55 | <embed id="plugin2" type="application/x-test" src="loremipsum.xtest" width="200" height="200"></embed> |