mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
fe0509a62e
- Bug 904479 - Added createPromiseWithId() that returns id of resolver r=kanru,nsm (2ac672d882) - Bug 1166580 - Disable mozHasPendingMessage tests on non-browser platform. r=me (03c689964b) - Bug 1162281 - Invalid system message handler in an App Manifest can break the entire system. r=fabrice (e192a95f9c) - Bug 1198988 - Turn off some useless dump() calls r=ferjm (34fc83b236) - Bug 1164498: Remove |DispatchBluetoothReply|, r=btian (6143335efa) - Bug 1001757 - Add ability to store core apps outside of profile on desktop b2g; r=fabrice (f6b605e7aa) - Bug 1155245 - Set the app status correctly for hosted certified apps in developer mode. r=fabrice (131178b80e) - Bug 1179052 - Add some raptor markers to b2g gecko startup r=gwagner (222256fad8) - Bug 1163904 - handle -url command line argument. r=fabrice (ee61af1ff9) - Bug 1167275 - JS error in shell.js handleCmdLine() r=me (32e75c604f) - Bug 1167197 - Fix GMPProvider on Android r=cpearce Bug 1181209 - Make changes to Gecko needed for b2gdroid to boot. r=fabrice (b35d3a372f) - Bug 1158544 - Remove FTPChannelChild::mWasOpened and make the base class mWasOpened protected; r=mcmanus (9111e1bc00) - Bug 1171716 - Part 2: Use NS_ReleaseOnMainThread in nsBaseChannel. r=froydnj (f138124f14) - partial of Bug 1177175 - Add a UITour target inside the TP panel. (603cc719b3) - Bug 1175545 - Dont process alt-svc on 421 r=hurley (ad0f2f6e91) - Bug 1191291 - convert nsHttpChannel::RetargetDeliveryTo warning to log r=michal.novotny (b9c6003df8) - Bug 1182487 - Don't try to write to HTTP cache entry in nsHttpChannel when entry is open for reading only. r=michal (b36d7014a0) - Bug 1173069 - Don't accumulate the cache hit telemetry for intercepted channels; r=mayhemer,jdm (aaed79183d) - Bug 1208755 HttpBaseChannel::ShouldIntercept() should not assume every channel has a LoadInfo. r=ckerschb (d55be94901) - Bug 1201229 - Return an empty string for a header when an error occurs; r=dragana (256d0462c8) - Bug 1048048 - add preload content policy types - web platform test updates (r=dveditz) (baa1004dd6) - Bug 1048048 - add preload content policy types - csp changes (r=dveditz) (17914dadba) - Bug 1048048 - add preload content policy types for stylesheets (r=cam) (29af13263a) - Bug 1048048 - add preload content policy types (r=ehsan) (f58a32d51b) - Bug 1201747 - Don't inspect the subject principal in StorageAllowedForPrincipal. r=mystor (4f2c100882) - Bug 1176829 - Remove custom elements base element queue. r=smaug (03a520c13d) - Bug 1176829 follow-up, finish removing unused member to fix bustage. CLOSED TREE (29c6150af8) - Bug 1179909: Build fix. r=me CLOSED TREE (40e3bdb971) - Bug 1188932 - Allow the User-Agent header to be explicitly set by requests, r=bkelly, r=jgraham (37aacbd37d)
254 lines
8.0 KiB
C++
254 lines
8.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "InternalRequest.h"
|
|
|
|
#include "nsIContentPolicy.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsStreamUtils.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
#include "mozilla/dom/ScriptSettings.h"
|
|
#include "mozilla/dom/workers/Workers.h"
|
|
|
|
#include "WorkerPrivate.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
// The global is used to extract the principal.
|
|
already_AddRefed<InternalRequest>
|
|
InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult& aRv) const
|
|
{
|
|
nsRefPtr<InternalRequest> copy = new InternalRequest();
|
|
copy->mURL.Assign(mURL);
|
|
copy->SetMethod(mMethod);
|
|
copy->mHeaders = new InternalHeaders(*mHeaders);
|
|
copy->SetUnsafeRequest();
|
|
|
|
copy->mBodyStream = mBodyStream;
|
|
copy->mForceOriginHeader = true;
|
|
// The "client" is not stored in our implementation. Fetch API users should
|
|
// use the appropriate window/document/principal and other Gecko security
|
|
// mechanisms as appropriate.
|
|
copy->mSameOriginDataURL = true;
|
|
copy->mPreserveContentCodings = true;
|
|
// The default referrer is already about:client.
|
|
|
|
copy->mContentPolicyType = nsIContentPolicy::TYPE_FETCH;
|
|
copy->mMode = mMode;
|
|
copy->mCredentialsMode = mCredentialsMode;
|
|
copy->mCacheMode = mCacheMode;
|
|
copy->mRedirectMode = mRedirectMode;
|
|
copy->mCreatedByFetchEvent = mCreatedByFetchEvent;
|
|
return copy.forget();
|
|
}
|
|
|
|
already_AddRefed<InternalRequest>
|
|
InternalRequest::Clone()
|
|
{
|
|
nsRefPtr<InternalRequest> clone = new InternalRequest(*this);
|
|
|
|
if (!mBodyStream) {
|
|
return clone.forget();
|
|
}
|
|
|
|
nsCOMPtr<nsIInputStream> clonedBody;
|
|
nsCOMPtr<nsIInputStream> replacementBody;
|
|
|
|
nsresult rv = NS_CloneInputStream(mBodyStream, getter_AddRefs(clonedBody),
|
|
getter_AddRefs(replacementBody));
|
|
if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; }
|
|
|
|
clone->mBodyStream.swap(clonedBody);
|
|
if (replacementBody) {
|
|
mBodyStream.swap(replacementBody);
|
|
}
|
|
|
|
return clone.forget();
|
|
}
|
|
|
|
InternalRequest::InternalRequest(const InternalRequest& aOther)
|
|
: mMethod(aOther.mMethod)
|
|
, mURL(aOther.mURL)
|
|
, mHeaders(new InternalHeaders(*aOther.mHeaders))
|
|
, mContentPolicyType(aOther.mContentPolicyType)
|
|
, mReferrer(aOther.mReferrer)
|
|
, mMode(aOther.mMode)
|
|
, mCredentialsMode(aOther.mCredentialsMode)
|
|
, mResponseTainting(aOther.mResponseTainting)
|
|
, mCacheMode(aOther.mCacheMode)
|
|
, mRedirectMode(aOther.mRedirectMode)
|
|
, mAuthenticationFlag(aOther.mAuthenticationFlag)
|
|
, mForceOriginHeader(aOther.mForceOriginHeader)
|
|
, mPreserveContentCodings(aOther.mPreserveContentCodings)
|
|
, mSameOriginDataURL(aOther.mSameOriginDataURL)
|
|
, mSandboxedStorageAreaURLs(aOther.mSandboxedStorageAreaURLs)
|
|
, mSkipServiceWorker(aOther.mSkipServiceWorker)
|
|
, mSynchronous(aOther.mSynchronous)
|
|
, mUnsafeRequest(aOther.mUnsafeRequest)
|
|
, mUseURLCredentials(aOther.mUseURLCredentials)
|
|
, mCreatedByFetchEvent(aOther.mCreatedByFetchEvent)
|
|
{
|
|
// NOTE: does not copy body stream... use the fallible Clone() for that
|
|
}
|
|
|
|
InternalRequest::~InternalRequest()
|
|
{
|
|
}
|
|
|
|
void
|
|
InternalRequest::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
|
|
{
|
|
mContentPolicyType = aContentPolicyType;
|
|
}
|
|
|
|
/* static */
|
|
RequestContext
|
|
InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aContentPolicyType)
|
|
{
|
|
RequestContext context = RequestContext::Internal;
|
|
switch (aContentPolicyType) {
|
|
case nsIContentPolicy::TYPE_OTHER:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
|
|
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD:
|
|
case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER:
|
|
context = RequestContext::Script;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_WORKER:
|
|
context = RequestContext::Worker;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER:
|
|
context = RequestContext::Sharedworker;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
|
|
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
|
|
context = RequestContext::Image;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
|
|
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD:
|
|
context = RequestContext::Style;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_OBJECT:
|
|
context = RequestContext::Object;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_EMBED:
|
|
context = RequestContext::Embed;
|
|
break;
|
|
case nsIContentPolicy::TYPE_DOCUMENT:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_IFRAME:
|
|
context = RequestContext::Iframe;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_FRAME:
|
|
context = RequestContext::Frame;
|
|
break;
|
|
case nsIContentPolicy::TYPE_REFRESH:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_XBL:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_PING:
|
|
context = RequestContext::Ping;
|
|
break;
|
|
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;
|
|
case nsIContentPolicy::TYPE_DTD:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_FONT:
|
|
context = RequestContext::Font;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_AUDIO:
|
|
context = RequestContext::Audio;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_VIDEO:
|
|
context = RequestContext::Video;
|
|
break;
|
|
case nsIContentPolicy::TYPE_INTERNAL_TRACK:
|
|
context = RequestContext::Track;
|
|
break;
|
|
case nsIContentPolicy::TYPE_WEBSOCKET:
|
|
context = RequestContext::Internal;
|
|
break;
|
|
case nsIContentPolicy::TYPE_CSP_REPORT:
|
|
context = RequestContext::Cspreport;
|
|
break;
|
|
case nsIContentPolicy::TYPE_XSLT:
|
|
context = RequestContext::Xslt;
|
|
break;
|
|
case nsIContentPolicy::TYPE_BEACON:
|
|
context = RequestContext::Beacon;
|
|
break;
|
|
case nsIContentPolicy::TYPE_FETCH:
|
|
context = RequestContext::Fetch;
|
|
break;
|
|
case nsIContentPolicy::TYPE_IMAGESET:
|
|
context = RequestContext::Imageset;
|
|
break;
|
|
case nsIContentPolicy::TYPE_WEB_MANIFEST:
|
|
context = RequestContext::Manifest;
|
|
break;
|
|
default:
|
|
MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
|
|
break;
|
|
}
|
|
return context;
|
|
}
|
|
|
|
bool
|
|
InternalRequest::IsNavigationRequest() const
|
|
{
|
|
// https://fetch.spec.whatwg.org/#navigation-request-context
|
|
//
|
|
// A navigation request context is one of "form", "frame", "hyperlink",
|
|
// "iframe", "internal" (as long as context frame type is not "none"),
|
|
// "location", "metarefresh", and "prerender".
|
|
//
|
|
// TODO: include equivalent check for "form" context
|
|
// TODO: include equivalent check for "prerender" context
|
|
return mContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
|
|
mContentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT ||
|
|
mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME ||
|
|
mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME ||
|
|
mContentPolicyType == nsIContentPolicy::TYPE_REFRESH;
|
|
}
|
|
|
|
bool
|
|
InternalRequest::IsWorkerRequest() const
|
|
{
|
|
// https://fetch.spec.whatwg.org/#worker-request-context
|
|
//
|
|
// A worker request context is one of "serviceworker", "sharedworker", and
|
|
// "worker".
|
|
//
|
|
// Note, service workers are not included here because currently there is
|
|
// no way to generate a Request with a "serviceworker" RequestContext.
|
|
// ServiceWorker scripts cannot be intercepted.
|
|
return mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
|
|
mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER;
|
|
}
|
|
|
|
bool
|
|
InternalRequest::IsClientRequest() const
|
|
{
|
|
return IsNavigationRequest() || IsWorkerRequest();
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|