зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1334509 - Remove support for the NPNURLVCookie NPAPI; r=bsmedberg
This commit is contained in:
Родитель
1349e18be0
Коммит
c358786407
|
@ -510,23 +510,6 @@ GetDocumentFromNPP(NPP npp)
|
|||
return doc;
|
||||
}
|
||||
|
||||
static already_AddRefed<nsIChannel>
|
||||
GetChannelFromNPP(NPP npp)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = GetDocumentFromNPP(npp);
|
||||
if (!doc)
|
||||
return nullptr;
|
||||
nsCOMPtr<nsPIDOMWindowOuter> domwindow = doc->GetWindow();
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (domwindow) {
|
||||
nsCOMPtr<nsIDocShell> docShell = domwindow->GetDocShell();
|
||||
if (docShell) {
|
||||
docShell->GetCurrentDocumentChannel(getter_AddRefs(channel));
|
||||
}
|
||||
}
|
||||
return channel.forget();
|
||||
}
|
||||
|
||||
static NPIdentifier
|
||||
doGetIdentifier(JSContext *cx, const NPUTF8* name)
|
||||
{
|
||||
|
@ -2490,29 +2473,9 @@ _getvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|||
break;
|
||||
}
|
||||
case NPNURLVCookie:
|
||||
{
|
||||
nsCOMPtr<nsICookieService> cookieService =
|
||||
do_GetService(NS_COOKIESERVICE_CONTRACTID);
|
||||
|
||||
if (!cookieService)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
// Make an nsURI from the url argument
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), nsDependentCString(url)))) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = GetChannelFromNPP(instance);
|
||||
|
||||
if (NS_FAILED(cookieService->GetCookieString(uri, channel, value)) ||
|
||||
!*value) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
*len = strlen(*value);
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
// NPNURLVCookie is no longer supported.
|
||||
*value = nullptr;
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
default:
|
||||
// Fall through and return an error...
|
||||
|
@ -2541,36 +2504,9 @@ _setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|||
|
||||
switch (variable) {
|
||||
case NPNURLVCookie:
|
||||
{
|
||||
if (!value || 0 == len)
|
||||
return NPERR_INVALID_PARAM;
|
||||
// NPNURLVCookie is no longer supported.
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsCOMPtr<nsICookieService> cookieService = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsCOMPtr<nsIURI> uriIn;
|
||||
rv = ioService->NewURI(nsDependentCString(url), nullptr, nullptr, getter_AddRefs(uriIn));
|
||||
if (NS_FAILED(rv))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = GetChannelFromNPP(instance);
|
||||
|
||||
char *cookie = (char*)value;
|
||||
char c = cookie[len];
|
||||
cookie[len] = '\0';
|
||||
rv = cookieService->SetCookieString(uriIn, nullptr, cookie, channel);
|
||||
cookie[len] = c;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
break;
|
||||
case NPNURLVProxy:
|
||||
// We don't support setting proxy values, fall through...
|
||||
default:
|
||||
|
|
|
@ -651,13 +651,10 @@ struct ParamTraits<NPNURLVariable>
|
|||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
{
|
||||
int intval;
|
||||
if (ReadParam(aMsg, aIter, &intval)) {
|
||||
switch (intval) {
|
||||
case NPNURLVCookie:
|
||||
case NPNURLVProxy:
|
||||
*aResult = paramType(intval);
|
||||
return true;
|
||||
}
|
||||
if (ReadParam(aMsg, aIter, &intval) &&
|
||||
intval == NPNURLVProxy) {
|
||||
*aResult = paramType(intval);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1617,9 +1617,7 @@ _getvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|||
if (!npp || !value || !len)
|
||||
return NPERR_INVALID_PARAM;
|
||||
|
||||
switch (variable) {
|
||||
case NPNURLVCookie:
|
||||
case NPNURLVProxy:
|
||||
if (variable == NPNURLVProxy) {
|
||||
nsCString v;
|
||||
NPError result;
|
||||
InstCast(npp)->
|
||||
|
@ -1647,9 +1645,7 @@ _setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|||
if (!url)
|
||||
return NPERR_INVALID_URL;
|
||||
|
||||
switch (variable) {
|
||||
case NPNURLVCookie:
|
||||
case NPNURLVProxy:
|
||||
if (variable == NPNURLVProxy) {
|
||||
NPError result;
|
||||
InstCast(npp)->CallNPN_SetValueForURL(variable, nsCString(url),
|
||||
nsDependentCString(value, len),
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/* 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);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<!-- 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>
|
|
@ -72,7 +72,6 @@ support-files = cocoa_focus.html
|
|||
[test_cocoa_window_focus.html]
|
||||
skip-if = toolkit != "cocoa" # Bug 1194534
|
||||
support-files = cocoa_window_focus.html
|
||||
[test_cookies.html]
|
||||
[test_copyText.html]
|
||||
skip-if = (toolkit != "gtk2") && (toolkit != "gtk3")
|
||||
[test_crash_nested_loop.html]
|
||||
|
@ -121,10 +120,6 @@ 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]
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>NPAPI Cookie Tests</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="plugin-utils.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="runTests()">
|
||||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
|
||||
function runTests() {
|
||||
var pluginElement = document.getElementById("plugin1");
|
||||
pluginElement.setCookie("foo");
|
||||
is(pluginElement.getCookie(), "foo", "Cookie was set and retrieved correctly via NPAPI.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
|
||||
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
|
||||
</body>
|
||||
</html>
|
|
@ -1,75 +0,0 @@
|
|||
<!-- 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() {
|
||||
resolve();
|
||||
}, {once: true});
|
||||
});
|
||||
}
|
||||
|
||||
// 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>
|
|
@ -12,7 +12,7 @@
|
|||
<script type="application/javascript">
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
</script>
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTestsCallback()">
|
||||
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
|
||||
<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
|
||||
</body>
|
||||
|
@ -23,11 +23,6 @@ SimpleTest.waitForExplicitFinish();
|
|||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
function runTests() {
|
||||
// Allow all cookies, then run the actual tests
|
||||
SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, runTestsCallback);
|
||||
}
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
|
@ -58,9 +53,6 @@ function runTestsCallback() {
|
|||
is(state1, false, "Browser returned incorrect private mode state.");
|
||||
is(state2, false, "Browser returned incorrect private mode state.");
|
||||
|
||||
pluginElement1.setCookie("foo");
|
||||
is(pluginElement1.getCookie(), "foo", "Cookie was set and retrieved correctly in public mode.");
|
||||
|
||||
// open a window with private mode and get the references of the elements.
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
|
@ -101,16 +93,9 @@ function runTestsCallback() {
|
|||
is(officialState1, true, "Querying private mode reported incorrectly");
|
||||
is(officialState2, true, "Querying private mode reported incorrectly");
|
||||
|
||||
// It would be nice to assert that we don't see the public cookie in private mode,
|
||||
// but the NPAPI complains when the resulting string is empty.
|
||||
// is(pluginElement1.getCookie(), "", "Public cookie was not retrieved in private mode.");
|
||||
pluginElement1.setCookie("bar");
|
||||
is(pluginElement1.getCookie(), "bar", "Cookie was set and retrieved correctly in private mode.");
|
||||
|
||||
aWin.close();
|
||||
|
||||
pluginElement1 = document.getElementById("plugin1");
|
||||
is(pluginElement1.getCookie(), "foo", "Private cookie was not retrieved in public mode.");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
|
|
@ -407,14 +407,6 @@ overridden windowproc.
|
|||
widget, if the plugin is windowed. If it's not windowed they're passed to
|
||||
the overriden windowproc (but hopefully never sent by the browser anyway).
|
||||
|
||||
== Getting and Setting Cookies ==
|
||||
|
||||
* setCookie(string)
|
||||
Sets the given string as the cookie for window's URL.
|
||||
|
||||
* getCookie()
|
||||
Returns the cookie string for the window's URL, the cookie set by setCookie.
|
||||
|
||||
== FPU Control ==
|
||||
|
||||
x86-only on some OSes:
|
||||
|
|
|
@ -140,8 +140,6 @@ static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argC
|
|||
static bool getJavaCodebase(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool checkObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool enableFPExceptions(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool setCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool asyncCallbackTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool checkGCRace(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
@ -215,8 +213,6 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||
"getJavaCodebase",
|
||||
"checkObjectValue",
|
||||
"enableFPExceptions",
|
||||
"setCookie",
|
||||
"getCookie",
|
||||
"getAuthInfo",
|
||||
"asyncCallbackTest",
|
||||
"checkGCRace",
|
||||
|
@ -291,8 +287,6 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
|
|||
getJavaCodebase,
|
||||
checkObjectValue,
|
||||
enableFPExceptions,
|
||||
setCookie,
|
||||
getCookie,
|
||||
getAuthInfo,
|
||||
asyncCallbackTest,
|
||||
checkGCRace,
|
||||
|
@ -3012,84 +3006,6 @@ static bool enableFPExceptions(NPObject* npobj, const NPVariant* args, uint32_t
|
|||
#endif
|
||||
}
|
||||
|
||||
// caller is responsible for freeing return buffer
|
||||
static char* URLForInstanceWindow(NPP instance) {
|
||||
char *outString = nullptr;
|
||||
|
||||
NPObject* windowObject = nullptr;
|
||||
NPError err = NPN_GetValue(instance, NPNVWindowNPObject, &windowObject);
|
||||
if (err != NPERR_NO_ERROR || !windowObject)
|
||||
return nullptr;
|
||||
|
||||
NPIdentifier locationIdentifier = NPN_GetStringIdentifier("location");
|
||||
NPVariant locationVariant;
|
||||
if (NPN_GetProperty(instance, windowObject, locationIdentifier, &locationVariant)) {
|
||||
NPObject *locationObject = locationVariant.value.objectValue;
|
||||
if (locationObject) {
|
||||
NPIdentifier hrefIdentifier = NPN_GetStringIdentifier("href");
|
||||
NPVariant hrefVariant;
|
||||
if (NPN_GetProperty(instance, locationObject, hrefIdentifier, &hrefVariant)) {
|
||||
const NPString* hrefString = &NPVARIANT_TO_STRING(hrefVariant);
|
||||
if (hrefString) {
|
||||
outString = (char *)malloc(hrefString->UTF8Length + 1);
|
||||
if (outString) {
|
||||
strcpy(outString, hrefString->UTF8Characters);
|
||||
outString[hrefString->UTF8Length] = '\0';
|
||||
}
|
||||
}
|
||||
NPN_ReleaseVariantValue(&hrefVariant);
|
||||
}
|
||||
}
|
||||
NPN_ReleaseVariantValue(&locationVariant);
|
||||
}
|
||||
|
||||
NPN_ReleaseObject(windowObject);
|
||||
|
||||
return outString;
|
||||
}
|
||||
|
||||
static bool
|
||||
setCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (argCount != 1)
|
||||
return false;
|
||||
if (!NPVARIANT_IS_STRING(args[0]))
|
||||
return false;
|
||||
const NPString* cookie = &NPVARIANT_TO_STRING(args[0]);
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
|
||||
char* url = URLForInstanceWindow(npp);
|
||||
if (!url)
|
||||
return false;
|
||||
NPError err = NPN_SetValueForURL(npp, NPNURLVCookie, url, cookie->UTF8Characters, cookie->UTF8Length);
|
||||
free(url);
|
||||
|
||||
return (err == NPERR_NO_ERROR);
|
||||
}
|
||||
|
||||
static bool
|
||||
getCookie(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (argCount != 0)
|
||||
return false;
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
|
||||
char* url = URLForInstanceWindow(npp);
|
||||
if (!url)
|
||||
return false;
|
||||
char* cookie = nullptr;
|
||||
unsigned int length = 0;
|
||||
NPError err = NPN_GetValueForURL(npp, NPNURLVCookie, url, &cookie, &length);
|
||||
free(url);
|
||||
if (err != NPERR_NO_ERROR || !cookie)
|
||||
return false;
|
||||
|
||||
STRINGZ_TO_NPVARIANT(cookie, *result);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче