mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1254856 - Add a mochitest to ensure that we send the proper cookies. r=ckerschb
This commit is contained in:
parent
432a47934a
commit
adba9c694d
17
dom/plugins/test/mochitest/file_checkcookie.sjs
Normal file
17
dom/plugins/test/mochitest/file_checkcookie.sjs
Normal file
@ -0,0 +1,17 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
function handleRequest(request, response) {
|
||||
try {
|
||||
var cookie = request.getHeader("Cookie");
|
||||
} catch (e) {
|
||||
cookie = "EMPTY_COOKIE";
|
||||
}
|
||||
|
||||
// avoid confusing cache behaviors.
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
// allow XHR requests accross origin.
|
||||
response.setHeader("Access-control-allow-origin", "*");
|
||||
response.setHeader("Content-type", "text/plain", false);
|
||||
response.setStatusLine(request.httpVersion, "200", "OK");
|
||||
response.write(cookie);
|
||||
}
|
9
dom/plugins/test/mochitest/file_setcookie.html
Normal file
9
dom/plugins/test/mochitest/file_setcookie.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=UTF-8>
|
||||
<body>
|
||||
<script>document.cookie = "found=another_cookie";</script>
|
||||
</body>
|
||||
</html>
|
@ -96,6 +96,10 @@ skip-if = toolkit != "gtk2"
|
||||
support-files = plugin_scroll_invalidation.html
|
||||
[test_plugin_scroll_painting.html]
|
||||
skip-if = true # Bug 596491
|
||||
[test_pluginstream_3rdparty.html]
|
||||
support-files =
|
||||
file_checkcookie.sjs
|
||||
file_setcookie.html
|
||||
[test_pluginstream_asfile.html]
|
||||
[test_pluginstream_asfileonly.html]
|
||||
[test_pluginstream_err.html]
|
||||
@ -133,4 +137,4 @@ skip-if = toolkit == "cocoa"
|
||||
[test_zero_opacity.html]
|
||||
[test_bug1165981.html]
|
||||
skip-if = !(os == "win" && processor == "x86_64" && !e10s) # Bug 1253957
|
||||
[test_bug1245545.html]
|
||||
[test_bug1245545.html]
|
||||
|
@ -1,10 +1,15 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function frameLoaded() {
|
||||
function frameLoaded(finishWhenCalled = true, lastObject = false) {
|
||||
var testframe = document.getElementById('testframe');
|
||||
var embed = document.getElementsByTagName('embed')[0];
|
||||
function getNode(list) {
|
||||
if (list.length === 0)
|
||||
return undefined;
|
||||
return lastObject ? list[list.length - 1] : list[0];
|
||||
}
|
||||
var embed = getNode(document.getElementsByTagName('embed'));
|
||||
if (undefined === embed)
|
||||
embed = document.getElementsByTagName('object')[0];
|
||||
embed = getNode(document.getElementsByTagName('object'));
|
||||
|
||||
// In the file:// URI case, this ends up being cross-origin.
|
||||
// Skip these checks in that case.
|
||||
@ -28,5 +33,7 @@
|
||||
}
|
||||
|
||||
is(embed.getError(), "pass", "plugin reported error");
|
||||
SimpleTest.finish();
|
||||
if (finishWhenCalled) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
76
dom/plugins/test/mochitest/test_pluginstream_3rdparty.html
Normal file
76
dom/plugins/test/mochitest/test_pluginstream_3rdparty.html
Normal file
@ -0,0 +1,76 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<html>
|
||||
<head>
|
||||
<title>NPAPI NPN_GetURL NPStream Test</title>
|
||||
<meta charset=UTF-8>
|
||||
<script type="text/javascript"
|
||||
src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="pluginstream.js"></script>
|
||||
<script type="text/javascript" src="plugin-utils.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript">
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
|
||||
<iframe id="testframe" name="testframe"></iframe>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* Tests that we still properly do or don't send cookies for requests from
|
||||
* plugins when the user has disabled 3rd-party cookies. See
|
||||
* pluginstream.js where we verify that we get the same content as for XHR
|
||||
* requests.
|
||||
*/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function get_embed_elt() {
|
||||
var e = document.createElement("embed");
|
||||
e.setAttribute("streammode", "normal");
|
||||
e.setAttribute("streamchunksize", "1024");
|
||||
e.setAttribute("frame", "testframe");
|
||||
e.setAttribute("id", "embedtest");
|
||||
e.setAttribute("style", "width: 400px; height: 100px;");
|
||||
e.setAttribute("type", "application/x-test");
|
||||
return e;
|
||||
}
|
||||
|
||||
function* test_runner() {
|
||||
function create_embed(host) {
|
||||
var e = get_embed_elt();
|
||||
|
||||
const url =
|
||||
`http://${host}/tests/dom/plugins/test/mochitest/file_checkcookie.sjs`;
|
||||
e.setAttribute('geturl', url);
|
||||
document.body.appendChild(e);
|
||||
|
||||
return new Promise(resolve => {
|
||||
$('testframe').addEventListener("load", function loaded() {
|
||||
$('testframe').removeEventListener("load", loaded);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Same origin
|
||||
yield create_embed("mochi.test:8888");
|
||||
yield create_embed("example.org");
|
||||
}
|
||||
|
||||
document.cookie = "found=a_cookie";
|
||||
var example_iframe = document.createElement("iframe");
|
||||
example_iframe.src = "http://example.org/tests/dom/plugins/test/mochitest/file_setcookie.html";
|
||||
example_iframe.addEventListener("load", () => {
|
||||
$('testframe').addEventListener("load", () => frameLoaded(false, true));
|
||||
SpecialPowers.pushPrefEnv({ set: [[ 'network.cookie.cookieBehavior', 1 ]] },
|
||||
() => (spawn_task(test_runner).then(SimpleTest.finish)));
|
||||
});
|
||||
document.body.appendChild(example_iframe);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user