Bug 1191107 - Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource (r=sicking,ehsan)

This commit is contained in:
Christoph Kerschbaumer 2015-08-06 11:17:24 -07:00
Родитель e42fb810bc
Коммит 1c05a94924
15 изменённых файлов: 77 добавлений и 50 удалений

Просмотреть файл

@ -781,7 +781,7 @@ EventSource::InitChannelAndRequestEventSource()
mSrc,
doc,
securityFlags,
nsIContentPolicy::TYPE_DATAREQUEST,
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
mLoadGroup, // loadGroup
nullptr, // aCallbacks
loadFlags); // aLoadFlags
@ -791,7 +791,7 @@ EventSource::InitChannelAndRequestEventSource()
mSrc,
mPrincipal,
securityFlags,
nsIContentPolicy::TYPE_DATAREQUEST,
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
mLoadGroup, // loadGroup
nullptr, // aCallbacks
loadFlags); // aLoadFlags

Просмотреть файл

@ -92,38 +92,40 @@ inline const char *
NS_CP_ContentTypeName(uint32_t contentType)
{
switch (contentType) {
CASE_RETURN( TYPE_OTHER );
CASE_RETURN( TYPE_SCRIPT );
CASE_RETURN( TYPE_IMAGE );
CASE_RETURN( TYPE_STYLESHEET );
CASE_RETURN( TYPE_OBJECT );
CASE_RETURN( TYPE_DOCUMENT );
CASE_RETURN( TYPE_SUBDOCUMENT );
CASE_RETURN( TYPE_REFRESH );
CASE_RETURN( TYPE_XBL );
CASE_RETURN( TYPE_PING );
CASE_RETURN( TYPE_XMLHTTPREQUEST );
CASE_RETURN( TYPE_OBJECT_SUBREQUEST );
CASE_RETURN( TYPE_DTD );
CASE_RETURN( TYPE_FONT );
CASE_RETURN( TYPE_MEDIA );
CASE_RETURN( TYPE_WEBSOCKET );
CASE_RETURN( TYPE_CSP_REPORT );
CASE_RETURN( TYPE_XSLT );
CASE_RETURN( TYPE_BEACON );
CASE_RETURN( TYPE_FETCH );
CASE_RETURN( TYPE_IMAGESET );
CASE_RETURN( TYPE_WEB_MANIFEST );
CASE_RETURN( TYPE_INTERNAL_SCRIPT );
CASE_RETURN( TYPE_INTERNAL_WORKER );
CASE_RETURN( TYPE_INTERNAL_SHARED_WORKER );
CASE_RETURN( TYPE_INTERNAL_EMBED );
CASE_RETURN( TYPE_INTERNAL_OBJECT );
CASE_RETURN( TYPE_INTERNAL_FRAME );
CASE_RETURN( TYPE_INTERNAL_IFRAME );
CASE_RETURN( TYPE_INTERNAL_AUDIO );
CASE_RETURN( TYPE_INTERNAL_VIDEO );
CASE_RETURN( TYPE_INTERNAL_TRACK );
CASE_RETURN( TYPE_OTHER );
CASE_RETURN( TYPE_SCRIPT );
CASE_RETURN( TYPE_IMAGE );
CASE_RETURN( TYPE_STYLESHEET );
CASE_RETURN( TYPE_OBJECT );
CASE_RETURN( TYPE_DOCUMENT );
CASE_RETURN( TYPE_SUBDOCUMENT );
CASE_RETURN( TYPE_REFRESH );
CASE_RETURN( TYPE_XBL );
CASE_RETURN( TYPE_PING );
CASE_RETURN( TYPE_XMLHTTPREQUEST );
CASE_RETURN( TYPE_OBJECT_SUBREQUEST );
CASE_RETURN( TYPE_DTD );
CASE_RETURN( TYPE_FONT );
CASE_RETURN( TYPE_MEDIA );
CASE_RETURN( TYPE_WEBSOCKET );
CASE_RETURN( TYPE_CSP_REPORT );
CASE_RETURN( TYPE_XSLT );
CASE_RETURN( TYPE_BEACON );
CASE_RETURN( TYPE_FETCH );
CASE_RETURN( TYPE_IMAGESET );
CASE_RETURN( TYPE_WEB_MANIFEST );
CASE_RETURN( TYPE_INTERNAL_SCRIPT );
CASE_RETURN( TYPE_INTERNAL_WORKER );
CASE_RETURN( TYPE_INTERNAL_SHARED_WORKER );
CASE_RETURN( TYPE_INTERNAL_EMBED );
CASE_RETURN( TYPE_INTERNAL_OBJECT );
CASE_RETURN( TYPE_INTERNAL_FRAME );
CASE_RETURN( TYPE_INTERNAL_IFRAME );
CASE_RETURN( TYPE_INTERNAL_AUDIO );
CASE_RETURN( TYPE_INTERNAL_VIDEO );
CASE_RETURN( TYPE_INTERNAL_TRACK );
CASE_RETURN( TYPE_INTERNAL_XMLHTTPREQUEST );
CASE_RETURN( TYPE_INTERNAL_EVENTSOURCE );
default:
return "<Unknown Type>";
}

Просмотреть файл

@ -7923,6 +7923,10 @@ nsContentUtils::InternalContentPolicyTypeToExternal(nsContentPolicyType aType)
case nsIContentPolicy::TYPE_INTERNAL_TRACK:
return nsIContentPolicy::TYPE_MEDIA;
case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
return nsIContentPolicy::TYPE_XMLHTTPREQUEST;
default:
return aType;
}

Просмотреть файл

@ -20,7 +20,7 @@ interface nsIPrincipal;
* by launching a dialog to prompt the user for something).
*/
[scriptable,uuid(b545899e-42bd-434c-8fec-a0af3448ea15)]
[scriptable,uuid(3663021e-5670-496f-887b-b408d6526b5b)]
interface nsIContentPolicy : nsIContentPolicyBase
{
/**

Просмотреть файл

@ -24,7 +24,7 @@ typedef unsigned long nsContentPolicyType;
* by launching a dialog to prompt the user for something).
*/
[scriptable,uuid(11b8d725-7c2b-429e-b51f-8b5b542d5009)]
[scriptable,uuid(20f7b9bf-d7d5-4987-ade8-b7dc0398d44a)]
interface nsIContentPolicyBase : nsISupports
{
/**
@ -257,6 +257,20 @@ interface nsIContentPolicyBase : nsISupports
*/
const nsContentPolicyType TYPE_INTERNAL_TRACK = 32;
/**
* Indicates an internal constant for an XMLHttpRequest.
*
* This will be mapped to TYPE_XMLHTTPREQUEST.
*/
const nsContentPolicyType TYPE_INTERNAL_XMLHTTPREQUEST = 33;
/**
* Indicates an internal constant for EventSource.
*
* This will be mapped to TYPE_DATAREQUEST.
*/
const nsContentPolicyType TYPE_INTERNAL_EVENTSOURCE = 34;
/* When adding new content types, please update nsContentBlocker,
* NS_CP_ContentTypeName, nsCSPContext, all nsIContentPolicy
* implementations, the static_assert in dom/cache/DBSchema.cpp,

Просмотреть файл

@ -1711,7 +1711,7 @@ nsXMLHttpRequest::Open(const nsACString& inMethod, const nsACString& url,
rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
uri,
mPrincipal,
doc,
@ -1765,7 +1765,7 @@ nsXMLHttpRequest::Open(const nsACString& inMethod, const nsACString& url,
uri,
doc,
secFlags,
nsIContentPolicy::TYPE_XMLHTTPREQUEST,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
loadGroup,
nullptr, // aCallbacks
nsIRequest::LOAD_BACKGROUND);
@ -1775,7 +1775,7 @@ nsXMLHttpRequest::Open(const nsACString& inMethod, const nsACString& url,
uri,
mPrincipal,
secFlags,
nsIContentPolicy::TYPE_XMLHTTPREQUEST,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
loadGroup,
nullptr, // aCallbacks
nsIRequest::LOAD_BACKGROUND);

4
dom/cache/DBSchema.cpp поставляемый
Просмотреть файл

@ -141,7 +141,9 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 &&
nsIContentPolicy::TYPE_INTERNAL_IFRAME == 29 &&
nsIContentPolicy::TYPE_INTERNAL_AUDIO == 30 &&
nsIContentPolicy::TYPE_INTERNAL_VIDEO == 31 &&
nsIContentPolicy::TYPE_INTERNAL_TRACK == 32,
nsIContentPolicy::TYPE_INTERNAL_TRACK == 32 &&
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST == 33 &&
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE == 34,
"nsContentPolicytType values are as expected");
namespace {

Просмотреть файл

@ -152,9 +152,12 @@ InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aConte
case nsIContentPolicy::TYPE_PING:
context = RequestContext::Ping;
break;
case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
context = RequestContext::Xmlhttprequest;
break;
case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
context = RequestContext::Eventsource;
break;
case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
context = RequestContext::Plugin;
break;

Просмотреть файл

@ -60,12 +60,12 @@ namespace dom {
* track | TYPE_INTERNAL_TRACK
* video | TYPE_INTERNAL_VIDEO
* worker | TYPE_INTERNAL_WORKER
* xmlhttprequest | TYPE_XMLHTTPREQUEST
* xmlhttprequest | TYPE_INTERNAL_XMLHTTPREQUEST
* eventsource | TYPE_INTERNAL_EVENTSOURCE
* xslt | TYPE_XSLT
*
* TODO: Figure out if TYPE_REFRESH maps to anything useful
* TODO: Figure out if TYPE_DTD maps to anything useful
* TODO: Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource
* TODO: Figure out if TYPE_WEBSOCKET maps to anything useful
* TODO: Add a content type for prefetch
* TODO: Use the content type for manifest when it becomes available

Просмотреть файл

@ -348,7 +348,7 @@ XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
}
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
uri,
principal,
callingDoc ? callingDoc.get() :
@ -445,7 +445,7 @@ XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
callingDoc ? callingDoc.get() :
static_cast<nsIDocument*>(this),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_XMLHTTPREQUEST,
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
loadGroup,
req,
nsIRequest::LOAD_BACKGROUND);

Просмотреть файл

@ -55,7 +55,9 @@ static const char *kTypeString[] = {
"", // TYPE_INTERNAL_IFRAME
"", // TYPE_INTERNAL_AUDIO
"", // TYPE_INTERNAL_VIDEO
"" // TYPE_INTERNAL_TRACK
"", // TYPE_INTERNAL_TRACK
"", // TYPE_INTERNAL_XMLHTTPREQUEST
"" // TYPE_INTERNAL_EVENTSOURCE
};
#define NUMBER_OF_TYPES MOZ_ARRAY_LENGTH(kTypeString)

Просмотреть файл

@ -210,7 +210,7 @@ BookmarkImporter.prototype = {
let channel = NetUtil.newChannel({
uri,
loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri),
contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
});
let streamLoader = Cc["@mozilla.org/network/stream-loader;1"]
.createInstance(Ci.nsIStreamLoader);

Просмотреть файл

@ -529,7 +529,7 @@ Livemark.prototype = {
let channel = NetUtil.newChannel({
uri: this.feedURI.spec,
loadingPrincipal: Services.scriptSecurityManager.getNoAppCodebasePrincipal(this.feedURI),
contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
}).QueryInterface(Ci.nsIHttpChannel);
channel.loadGroup = loadgroup;
channel.loadFlags |= Ci.nsIRequest.LOAD_BACKGROUND |

Просмотреть файл

@ -41,7 +41,7 @@ add_test(function test_addParam() {
NetUtil.asyncFetch({
uri: NetUtil.newURI(aFile),
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DATAREQUEST
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST
}, function(inputStream, status) {
do_check_true(Components.isSuccessCode(status));

Просмотреть файл

@ -1262,7 +1262,7 @@ function getLocale() {
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_DATAREQUEST);
Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST);
try {
var inputStream = channel.open();
gLocale = readStringFromInputStream(inputStream);