Bug 1082924 - Add CSP type for fetch API. r=tvyas,baku

--HG--
extra : transplant_source : i%D8%5C%7C%9D%FEQL%C1G%B8%3B2%06%AA%AE%3A%09%29%7E
This commit is contained in:
Nikhil Marathe 2014-10-13 15:09:58 -07:00
Родитель da52e5aaa0
Коммит a4c280a3c0
6 изменённых файлов: 13 добавлений и 4 удалений

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

@ -111,6 +111,7 @@ NS_CP_ContentTypeName(uint32_t contentType)
CASE_RETURN( TYPE_CSP_REPORT );
CASE_RETURN( TYPE_XSLT );
CASE_RETURN( TYPE_BEACON );
CASE_RETURN( TYPE_FETCH );
default:
return "<Unknown Type>";
}

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

@ -24,7 +24,7 @@ typedef unsigned long nsContentPolicyType;
* by launching a dialog to prompt the user for something).
*/
[scriptable,uuid(b6a71698-c117-441d-86b9-480cf06e3952)]
[scriptable,uuid(8afe3e5c-f916-48fd-8075-9579d3502e1d)]
interface nsIContentPolicy : nsISupports
{
/**
@ -150,6 +150,12 @@ interface nsIContentPolicy : nsISupports
*/
const nsContentPolicyType TYPE_BEACON = 19;
/**
* Indicates a load initiated by the fetch() function from the Fetch
* specification.
*/
const nsContentPolicyType TYPE_FETCH = 20;
/* When adding new content types, please update nsContentBlocker,
* NS_CP_ContentTypeName, nsCSPContext, all nsIContentPolicy
* implementations, and other things that are not listed here that are

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

@ -709,6 +709,7 @@ CSP_ContentTypeToDirective(nsContentPolicyType aType)
case nsIContentPolicy::TYPE_WEBSOCKET:
case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
case nsIContentPolicy::TYPE_BEACON:
case nsIContentPolicy::TYPE_FETCH:
return CSP_CONNECT_SRC;
case nsIContentPolicy::TYPE_OBJECT:

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

@ -120,7 +120,8 @@ nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType,
aContentType == nsIContentPolicy::TYPE_DOCUMENT ||
aContentType == nsIContentPolicy::TYPE_SUBDOCUMENT ||
aContentType == nsIContentPolicy::TYPE_SCRIPT ||
aContentType == nsIContentPolicy::TYPE_XSLT) {
aContentType == nsIContentPolicy::TYPE_XSLT ||
aContentType == nsIContentPolicy::TYPE_FETCH) {
*aDecision = nsIContentPolicy::REJECT_TYPE;
}

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

@ -383,6 +383,7 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
// purposes and to avoid the assertion and warning for the default case.
case TYPE_CSP_REPORT:
case TYPE_DTD:
case TYPE_FETCH:
case TYPE_FONT:
case TYPE_OBJECT:
case TYPE_SCRIPT:

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

@ -45,10 +45,9 @@ InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult
copy->mOrigin = NS_ConvertUTF16toUTF8(location.mOrigin);
}
copy->mContext = nsIContentPolicy::TYPE_FETCH;
copy->mMode = mMode;
copy->mCredentialsMode = mCredentialsMode;
// FIXME(nsm): Add ContentType fetch to nsIContentPolicy and friends.
// Then set copy's mContext to that.
return copy.forget();
}