mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:25:44 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1101651 - Part 3: Update cppunitest.ini file. r=dminor (ee84778e0) - Bug 1177887 - Deref *after* changing the value held by RefPtr. - r=waldo (d5171f34a) - Bug 1119086 - already_AddRefed should define copy/move assignment operators. r=nfroyd (9e4431f30) - Bug 1155059: Patch 0 - add do_AddRef() r=froydnj (b128156c9) - Bug 1096093 - Add infrastructure for LookAndFeel metric caching, and allowing the parent process to send down cache to content process. r=jimm. (1c45a3b01) - Bug 1153988 - create nsNullPrincipals directly, rather than going through do_CreateInstance; r=smaug (bf6f60873) - Bug 1149280 part 1. Make nullprincipal creation faster. r=smaug (0ebf3b6c5) - Bug 1149280 part 2. Drop the useless mScheme member of nsNullPrincipalURI. r=smaug (a3e0f165d) - Bug 1162412 - Part 1 - don't treat plain facingMode constraint as required. r=jesup (8a2bd8ed4) - Bug 1162412 - Part 2 - order devices by shortest fitness distance. r=jesup (a24175d0b) - Bug 1162412 - Part 3 - treat plain values as exact in advanced. r=jesup (6a81a6126) - Bug 1161433: reject empty gUM contraints with NotSupportedError. r=jib (e92264c39) - Bug 1162720 - Test enumerateDevices. r=jesup, r=drno (495754307) - Bug 1162720 - Rename CallbackRunnable::New to NewRunnableFrom. r=jesup (2b6dad718) - Bug 1164292 - Hoist refcounting into nsJSPrincipals. r=gabor (0fe536dcc) - Bug 1150045 - De-anonymize Expanded Principals. r=bholley (c469e4155) - Bug 1132745 part 1: remove music.baidu.com from CSSUnprefixingService whitelist. r=miketaylr (e4088e511) - Bug 1132745 part 2: Add Mozilla China team's requested additional domains to CSSUnprefixingService whitelist. r=miketaylr (3c5272527) - Bug 1132745 followup: Fix a typo in a CSS Unprefixing Service whitelisted domain. (no review) (1c4dfb146) - Bug 1162106: Add top .jp sites to CSS unprefixing service whitelist. r=dholbert (484868159) - Bug 1164292 - Re-implement dumpImpl in terms of GetScriptLocation. r=gabor (da8dca812) - Bug 1164292 - Rebrand nsBasePrincipal into mozilla::BasePrincipal and give it its own file. r=gabor (aa316e820) - Bug 1164292 - Make all nsIPrincipal implementations inherit BasePrincipal and hoist some repeated code. r=gabor (47ec1edc8) - Bug 1164292 - Switch nsIPrincipal::origin to ACString. r=gabor (55fd6ffda) - rearrange code (2e750c960) - Bug 1157898 part 2. Make code of the form "NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());" use Failed and StealNSResult instead. r=peterv (359a431d6) - Bug 1157898 part 5. Eliminate the remaining non-ErrorResult consumers of ErrorResult::ErrorCode and make it protected. r=peterv (89364a5ef) - Bug 1158557 - Don't throttle rAF for documents with live static clones. r=smaug (8b11781df) - Bug 1152551, part 1 - Remove leading tabs in dom/. r=baku (1853422ea) - Bug 1150064, part 1 - Implement the Animation.finish() method. r=birtles, r=smaug (72ca03012) - Bug 1150064, part 2 - Add Web Platform tests for the Animation.finish() method. r=birtles (05e90625d) - Bug 1150807 part 1 - Fix SilentlySetCurrentTime to not set the start time when it is unresolved; r=jwatt (bc8f471ec) - Bug 1150807 part 2 - Expose Animation::Cancel in WebIDL; r=smaug (f32332d44) - Bug 1150807 part 3 - Call PostUpdate from Cancel; r=jwatt (391f56488) - Bug 1150807 part 4 - Don't play/pause an idle animation when animation-play-state changes; r=jwatt (5eed021af) - Bug 1150807 part 5 - Tests for Animation.cancel(); r=jwatt (ad6776e1d) - Bug 1157989 part 1 - Line up methods in dom/animation/Animation with the API; r=jwatt (dc8874f43) - Bug 1157989 part 2 - Make Silently* methods protected; r=jwatt (7039f1aaa) - Bug 1157989 part 3 - Make LimitBehavior enum a scoped enum; r=jwatt (ffd876b36) - Bug 1157989 part 4 - Make method comment style consistent; r=jwatt (e656f44ae)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et 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 "mozilla/BasePrincipal.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
NS_IF_ADDREF(*aCsp = mCSP);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// If CSP was already set, it should not be destroyed! Instead, it should
|
||||
// get set anew when a new principal is created.
|
||||
if (mCSP)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mCSP = aCsp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetIsNullPrincipal(bool* aIsNullPrincipal)
|
||||
{
|
||||
*aIsNullPrincipal = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
} // namespace mozilla
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_BasePrincipal_h
|
||||
#define mozilla_BasePrincipal_h
|
||||
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/*
|
||||
* Base class from which all nsIPrincipal implementations inherit. Use this for
|
||||
* default implementations and other commonalities between principal
|
||||
* implementations.
|
||||
*
|
||||
* We should merge nsJSPrincipals into this class at some point.
|
||||
*/
|
||||
class BasePrincipal : public nsJSPrincipals
|
||||
{
|
||||
public:
|
||||
BasePrincipal() {}
|
||||
NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp);
|
||||
NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp);
|
||||
NS_IMETHOD GetIsNullPrincipal(bool* aIsNullPrincipal) override;
|
||||
|
||||
virtual bool IsOnCSSUnprefixingWhitelist() override { return false; }
|
||||
|
||||
protected:
|
||||
virtual ~BasePrincipal() {}
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_BasePrincipal_h */
|
||||
@@ -20,7 +20,12 @@ EXPORTS += [
|
||||
'nsNullPrincipalURI.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla = [
|
||||
'BasePrincipal.h'
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'BasePrincipal.cpp',
|
||||
'DomainPolicy.cpp',
|
||||
'nsJSPrincipals.cpp',
|
||||
'nsNullPrincipal.cpp',
|
||||
|
||||
@@ -20,7 +20,7 @@ interface nsIContentSecurityPolicy;
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
|
||||
|
||||
[scriptable, builtinclass, uuid(264fe8ca-c382-11e4-95a6-782bcbaebb28)]
|
||||
[scriptable, builtinclass, uuid(7e024afa-afd4-48e7-ba11-1c7b9620b1b2)]
|
||||
interface nsIPrincipal : nsISerializable
|
||||
{
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ interface nsIPrincipal : nsISerializable
|
||||
// XXXcaa this should probably be turned into an nsIURI.
|
||||
// The system principal's origin should be some caps namespace
|
||||
// with a chrome URI. All of chrome should probably be the same.
|
||||
readonly attribute string origin;
|
||||
readonly attribute ACString origin;
|
||||
|
||||
/**
|
||||
* Returns whether the other principal is equal to or weaker than this
|
||||
|
||||
+27
-1
@@ -19,6 +19,30 @@
|
||||
// for mozilla::dom::workers::kJSPrincipalsDebugToken
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsJSPrincipals::AddRef()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
|
||||
nsrefcnt count = ++refcount;
|
||||
NS_LOG_ADDREF(this, count, "nsJSPrincipals", sizeof(*this));
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsJSPrincipals::Release()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_PRECONDITION(0 != refcount, "dup release");
|
||||
nsrefcnt count = --refcount;
|
||||
NS_LOG_RELEASE(this, count, "nsJSPrincipals");
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsJSPrincipals::Subsume(JSPrincipals *jsprin, JSPrincipals *other)
|
||||
{
|
||||
@@ -59,7 +83,9 @@ JS_EXPORT_API(void)
|
||||
JSPrincipals::dump()
|
||||
{
|
||||
if (debugToken == nsJSPrincipals::DEBUG_TOKEN) {
|
||||
static_cast<nsJSPrincipals *>(this)->dumpImpl();
|
||||
nsAutoCString str;
|
||||
static_cast<nsJSPrincipals *>(this)->GetScriptLocation(str);
|
||||
fprintf(stderr, "nsIPrincipal (%p) = %s\n", static_cast<void*>(this), str.get());
|
||||
} else if (debugToken == mozilla::dom::workers::kJSPrincipalsDebugToken) {
|
||||
fprintf(stderr, "Web Worker principal singleton (%p)\n", this);
|
||||
} else {
|
||||
|
||||
+13
-12
@@ -9,46 +9,47 @@
|
||||
#include "jsapi.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
struct nsJSPrincipals : nsIPrincipal, JSPrincipals
|
||||
class nsJSPrincipals : public nsIPrincipal, public JSPrincipals
|
||||
{
|
||||
public:
|
||||
/* SpiderMonkey security callbacks. */
|
||||
static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other);
|
||||
static void Destroy(JSPrincipals *jsprin);
|
||||
|
||||
/*
|
||||
* Get a weak reference to nsIPrincipal associated with the given JS
|
||||
* principal.
|
||||
* principal, and vice-versa.
|
||||
*/
|
||||
static nsJSPrincipals* get(JSPrincipals *principals) {
|
||||
nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals);
|
||||
MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
|
||||
return self;
|
||||
}
|
||||
|
||||
static nsJSPrincipals* get(nsIPrincipal *principal) {
|
||||
nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principal);
|
||||
MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
|
||||
return self;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release(void) override;
|
||||
|
||||
nsJSPrincipals() {
|
||||
refcount = 0;
|
||||
setDebugToken(DEBUG_TOKEN);
|
||||
}
|
||||
|
||||
virtual ~nsJSPrincipals() {
|
||||
setDebugToken(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string that can be used as JS script filename in error reports.
|
||||
*/
|
||||
virtual void GetScriptLocation(nsACString &aStr) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() = 0;
|
||||
#endif
|
||||
|
||||
static const uint32_t DEBUG_TOKEN = 0x0bf41760;
|
||||
|
||||
protected:
|
||||
virtual ~nsJSPrincipals() {
|
||||
setDebugToken(0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsJSPrincipals_h__ */
|
||||
|
||||
+14
-118
@@ -15,8 +15,6 @@
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsNullPrincipalURI.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
@@ -39,36 +37,6 @@ NS_IMPL_CI_INTERFACE_GETTER(nsNullPrincipal,
|
||||
nsIPrincipal,
|
||||
nsISerializable)
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsNullPrincipal::AddRef()
|
||||
{
|
||||
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
|
||||
nsrefcnt count = ++refcount;
|
||||
NS_LOG_ADDREF(this, count, "nsNullPrincipal", sizeof(*this));
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsNullPrincipal::Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != refcount, "dup release");
|
||||
nsrefcnt count = --refcount;
|
||||
NS_LOG_RELEASE(this, count, "nsNullPrincipal");
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
nsNullPrincipal::nsNullPrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
nsNullPrincipal::~nsNullPrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsNullPrincipal>
|
||||
nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
{
|
||||
@@ -78,7 +46,15 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
return NS_SUCCEEDED(rv) ? nullPrin.forget() : nullptr;
|
||||
}
|
||||
|
||||
#define NS_NULLPRINCIPAL_PREFIX NS_NULLPRINCIPAL_SCHEME ":"
|
||||
/* static */ already_AddRefed<nsNullPrincipal>
|
||||
nsNullPrincipal::Create(uint32_t aAppId, bool aInMozBrowser)
|
||||
{
|
||||
nsRefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
|
||||
nsresult rv = nullPrin->Init(aAppId, aInMozBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
return nullPrin.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNullPrincipal::Init(uint32_t aAppId, bool aInMozBrowser)
|
||||
@@ -87,11 +63,8 @@ nsNullPrincipal::Init(uint32_t aAppId, bool aInMozBrowser)
|
||||
mAppId = aAppId;
|
||||
mInMozBrowser = aInMozBrowser;
|
||||
|
||||
nsCString str;
|
||||
nsresult rv = GenerateNullPrincipalURI(str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mURI = new nsNullPrincipalURI(str);
|
||||
mURI = nsNullPrincipalURI::Create();
|
||||
NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -102,49 +75,6 @@ nsNullPrincipal::GetScriptLocation(nsACString &aStr)
|
||||
mURI->GetSpec(aStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNullPrincipal::GenerateNullPrincipalURI(nsACString &aStr)
|
||||
{
|
||||
// FIXME: bug 327161 -- make sure the uuid generator is reseeding-resistant.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidgen =
|
||||
do_GetService("@mozilla.org/uuid-generator;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsID id;
|
||||
rv = uuidgen->GenerateUUIDInPlace(&id);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char chars[NSID_LENGTH];
|
||||
id.ToProvidedString(chars);
|
||||
|
||||
uint32_t suffixLen = NSID_LENGTH - 1;
|
||||
uint32_t prefixLen = ArrayLength(NS_NULLPRINCIPAL_PREFIX) - 1;
|
||||
|
||||
// Use an nsCString so we only do the allocation once here and then share
|
||||
// with nsJSPrincipals
|
||||
aStr.SetCapacity(prefixLen + suffixLen);
|
||||
|
||||
aStr.Append(NS_NULLPRINCIPAL_PREFIX);
|
||||
aStr.Append(chars);
|
||||
|
||||
if (aStr.Length() != prefixLen + suffixLen) {
|
||||
NS_WARNING("Out of memory allocating null-principal URI");
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void nsNullPrincipal::dumpImpl()
|
||||
{
|
||||
nsAutoCString str;
|
||||
mURI->GetSpec(str);
|
||||
fprintf(stderr, "nsNullPrincipal (%p) = %s\n", this, str.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* nsIPrincipal implementation
|
||||
*/
|
||||
@@ -177,25 +107,6 @@ nsNullPrincipal::GetURI(nsIURI** aURI)
|
||||
return NS_EnsureSafeToReturn(mURI, aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
NS_IF_ADDREF(*aCsp = mCSP);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// If CSP was already set, it should not be destroyed! Instead, it should
|
||||
// get set anew when a new principal is created.
|
||||
if (mCSP)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mCSP = aCsp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetDomain(nsIURI** aDomain)
|
||||
{
|
||||
@@ -210,19 +121,10 @@ nsNullPrincipal::SetDomain(nsIURI* aDomain)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetOrigin(char** aOrigin)
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetOrigin(nsACString& aOrigin)
|
||||
{
|
||||
*aOrigin = nullptr;
|
||||
|
||||
nsAutoCString str;
|
||||
nsresult rv = mURI->GetSpec(str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aOrigin = ToNewCString(str);
|
||||
NS_ENSURE_TRUE(*aOrigin, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
return mURI->GetSpec(aOrigin);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -318,12 +220,6 @@ nsNullPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
return mURI->GetPath(aBaseDomain);
|
||||
}
|
||||
|
||||
bool
|
||||
nsNullPrincipal::IsOnCSSUnprefixingWhitelist()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* nsISerializable implementation
|
||||
*/
|
||||
|
||||
+33
-17
@@ -18,6 +18,8 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
#define NS_NULLPRINCIPAL_CID \
|
||||
@@ -27,36 +29,50 @@ class nsIURI;
|
||||
|
||||
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
||||
|
||||
class nsNullPrincipal final : public nsJSPrincipals
|
||||
class nsNullPrincipal final : public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
nsNullPrincipal();
|
||||
// This should only be used by deserialization, and the factory constructor.
|
||||
// Other consumers should use the Create and CreateWithInheritedAttributes
|
||||
// methods.
|
||||
nsNullPrincipal() {}
|
||||
|
||||
// Our refcount is managed by nsJSPrincipals. Use this macro to avoid an
|
||||
// extra refcount member.
|
||||
|
||||
// FIXME: bug 327245 -- I sorta wish there were a clean way to share the
|
||||
// nsJSPrincipals munging code between the various principal classes without
|
||||
// giving up the NS_DECL_NSIPRINCIPAL goodness.
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD Equals(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD EqualsConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
||||
NS_IMETHOD GetURI(nsIURI** aURI) override;
|
||||
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
|
||||
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
|
||||
NS_IMETHOD GetOrigin(nsACString& aOrigin) override;
|
||||
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal) override;
|
||||
NS_IMETHOD GetJarPrefix(nsACString& aJarPrefix) override;
|
||||
NS_IMETHOD GetAppStatus(uint16_t* aAppStatus) override;
|
||||
NS_IMETHOD GetAppId(uint32_t* aAppStatus) override;
|
||||
NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement) override;
|
||||
NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) override;
|
||||
NS_IMETHOD GetIsNullPrincipal(bool* aIsNullPrincipal) override;
|
||||
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
||||
|
||||
// Returns null on failure.
|
||||
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
|
||||
|
||||
// Returns null on failure.
|
||||
static already_AddRefed<nsNullPrincipal>
|
||||
Create(uint32_t aAppId = nsIScriptSecurityManager::NO_APP_ID,
|
||||
bool aInMozBrowser = false);
|
||||
|
||||
nsresult Init(uint32_t aAppId = nsIScriptSecurityManager::NO_APP_ID,
|
||||
bool aInMozBrowser = false);
|
||||
|
||||
virtual void GetScriptLocation(nsACString &aStr) override;
|
||||
|
||||
static nsresult GenerateNullPrincipalURI(nsACString &aStr);
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual ~nsNullPrincipal();
|
||||
virtual ~nsNullPrincipal() {}
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
|
||||
+42
-24
@@ -14,29 +14,51 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// nsNullPrincipalURI
|
||||
|
||||
nsNullPrincipalURI::nsNullPrincipalURI(const nsCString &aSpec)
|
||||
nsNullPrincipalURI::nsNullPrincipalURI()
|
||||
: mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
|
||||
{
|
||||
InitializeFromSpec(aSpec);
|
||||
}
|
||||
|
||||
void
|
||||
nsNullPrincipalURI::InitializeFromSpec(const nsCString &aSpec)
|
||||
nsNullPrincipalURI::nsNullPrincipalURI(const nsNullPrincipalURI& aOther)
|
||||
: mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
|
||||
{
|
||||
int32_t dividerPosition = aSpec.FindChar(':');
|
||||
NS_ASSERTION(dividerPosition != -1, "Malformed URI!");
|
||||
mPath.Assign(aOther.mPath);
|
||||
}
|
||||
|
||||
mozilla::DebugOnly<int32_t> n = aSpec.Left(mScheme, dividerPosition);
|
||||
NS_ASSERTION(n == dividerPosition, "Storing the scheme failed!");
|
||||
nsresult
|
||||
nsNullPrincipalURI::Init()
|
||||
{
|
||||
// FIXME: bug 327161 -- make sure the uuid generator is reseeding-resistant.
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidgen = services::GetUUIDGenerator();
|
||||
NS_ENSURE_TRUE(uuidgen, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
int32_t count = aSpec.Length() - dividerPosition - 1;
|
||||
n = aSpec.Mid(mPath, dividerPosition + 1, count);
|
||||
NS_ASSERTION(n == count, "Storing the path failed!");
|
||||
nsID id;
|
||||
nsresult rv = uuidgen->GenerateUUIDInPlace(&id);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ToLowerCase(mScheme);
|
||||
MOZ_ASSERT(mPathBytes == mPath.BeginWriting());
|
||||
|
||||
id.ToProvidedString(mPathBytes);
|
||||
|
||||
MOZ_ASSERT(mPath.Length() == NSID_LENGTH - 1);
|
||||
MOZ_ASSERT(strlen(mPath.get()) == NSID_LENGTH - 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsNullPrincipalURI>
|
||||
nsNullPrincipalURI::Create()
|
||||
{
|
||||
nsRefPtr<nsNullPrincipalURI> uri = new nsNullPrincipalURI();
|
||||
nsresult rv = uri->Init();
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
static NS_DEFINE_CID(kNullPrincipalURIImplementationCID,
|
||||
@@ -147,7 +169,7 @@ nsNullPrincipalURI::SetRef(const nsACString &aRef)
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::GetPrePath(nsACString &_prePath)
|
||||
{
|
||||
_prePath = mScheme + NS_LITERAL_CSTRING(":");
|
||||
_prePath = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -166,7 +188,7 @@ nsNullPrincipalURI::SetPort(int32_t aPort)
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::GetScheme(nsACString &_scheme)
|
||||
{
|
||||
_scheme = mScheme;
|
||||
_scheme = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -179,7 +201,7 @@ nsNullPrincipalURI::SetScheme(const nsACString &aScheme)
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::GetSpec(nsACString &_spec)
|
||||
{
|
||||
_spec = mScheme + NS_LITERAL_CSTRING(":") + mPath;
|
||||
_spec = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":") + mPath;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -230,8 +252,7 @@ nsNullPrincipalURI::SetUserPass(const nsACString &aUserPass)
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::Clone(nsIURI **_newURI)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri =
|
||||
new nsNullPrincipalURI(mScheme + NS_LITERAL_CSTRING(":") + mPath);
|
||||
nsCOMPtr<nsIURI> uri = new nsNullPrincipalURI(*this);
|
||||
uri.forget(_newURI);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -252,7 +273,7 @@ nsNullPrincipalURI::Equals(nsIURI *aOther, bool *_equals)
|
||||
nsresult rv = aOther->QueryInterface(kNullPrincipalURIImplementationCID,
|
||||
(void **)&otherURI);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*_equals = (mScheme == otherURI->mScheme && mPath == otherURI->mPath);
|
||||
*_equals = mPath == otherURI->mPath;
|
||||
NS_RELEASE(otherURI);
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -277,7 +298,7 @@ nsNullPrincipalURI::Resolve(const nsACString &aRelativePath,
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipalURI::SchemeIs(const char *aScheme, bool *_schemeIs)
|
||||
{
|
||||
*_schemeIs = (0 == nsCRT::strcasecmp(mScheme.get(), aScheme));
|
||||
*_schemeIs = (0 == nsCRT::strcasecmp(NS_NULLPRINCIPAL_SCHEME, aScheme));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -298,11 +319,9 @@ nsNullPrincipalURI::Deserialize(const mozilla::ipc::URIParams &aParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCString str;
|
||||
nsresult rv = nsNullPrincipal::GenerateNullPrincipalURI(str);
|
||||
nsresult rv = Init();
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
InitializeFromSpec(str);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,8 +331,7 @@ nsNullPrincipalURI::Deserialize(const mozilla::ipc::URIParams &aParams)
|
||||
size_t
|
||||
nsNullPrincipalURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
|
||||
mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
return mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIIPCSerializableURI.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsID.h"
|
||||
|
||||
// {51fcd543-3b52-41f7-b91b-6b54102236e6}
|
||||
#define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
|
||||
@@ -37,18 +39,22 @@ public:
|
||||
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
||||
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
||||
|
||||
explicit nsNullPrincipalURI(const nsCString &aSpec);
|
||||
// NB: This constructor exists only for deserialization. Everyone
|
||||
// else should call Create.
|
||||
nsNullPrincipalURI();
|
||||
|
||||
// NB: This constructor exists only for deserialization.
|
||||
nsNullPrincipalURI() { }
|
||||
// Returns null on failure.
|
||||
static already_AddRefed<nsNullPrincipalURI> Create();
|
||||
|
||||
private:
|
||||
nsNullPrincipalURI(const nsNullPrincipalURI& aOther);
|
||||
|
||||
~nsNullPrincipalURI() {}
|
||||
|
||||
void InitializeFromSpec(const nsCString &aSpec);
|
||||
nsresult Init();
|
||||
|
||||
nsCString mScheme;
|
||||
nsCString mPath;
|
||||
char mPathBytes[NSID_LENGTH];
|
||||
nsFixedCString mPath;
|
||||
};
|
||||
|
||||
#endif // __nsNullPrincipalURI_h__
|
||||
|
||||
+59
-108
@@ -46,68 +46,6 @@ static bool URIIsImmutable(nsIURI* aURI)
|
||||
!isMutable;
|
||||
}
|
||||
|
||||
// Static member variables
|
||||
const char nsBasePrincipal::sInvalid[] = "Invalid";
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsBasePrincipal::AddRef()
|
||||
{
|
||||
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
|
||||
// XXXcaa does this need to be threadsafe? See bug 143559.
|
||||
nsrefcnt count = ++refcount;
|
||||
NS_LOG_ADDREF(this, count, "nsBasePrincipal", sizeof(*this));
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsBasePrincipal::Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != refcount, "dup release");
|
||||
nsrefcnt count = --refcount;
|
||||
NS_LOG_RELEASE(this, count, "nsBasePrincipal");
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
nsBasePrincipal::nsBasePrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
nsBasePrincipal::~nsBasePrincipal(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBasePrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
||||
{
|
||||
NS_IF_ADDREF(*aCsp = mCSP);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBasePrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
||||
{
|
||||
// If CSP was already set, it should not be destroyed! Instead, it should
|
||||
// get set anew when a new principal is created.
|
||||
if (mCSP)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mCSP = aCsp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void nsPrincipal::dumpImpl()
|
||||
{
|
||||
nsAutoCString str;
|
||||
GetScriptLocation(str);
|
||||
fprintf(stderr, "nsPrincipal (%p) = %s\n", static_cast<void*>(this), str.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMPL_CLASSINFO(nsPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
|
||||
NS_PRINCIPAL_CID)
|
||||
NS_IMPL_QUERY_INTERFACE_CI(nsPrincipal,
|
||||
@@ -116,8 +54,6 @@ NS_IMPL_QUERY_INTERFACE_CI(nsPrincipal,
|
||||
NS_IMPL_CI_INTERFACE_GETTER(nsPrincipal,
|
||||
nsIPrincipal,
|
||||
nsISerializable)
|
||||
NS_IMPL_ADDREF_INHERITED(nsPrincipal, nsBasePrincipal)
|
||||
NS_IMPL_RELEASE_INHERITED(nsPrincipal, nsBasePrincipal)
|
||||
|
||||
// Called at startup:
|
||||
/* static */ void
|
||||
@@ -169,14 +105,12 @@ nsPrincipal::GetScriptLocation(nsACString &aStr)
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsPrincipal::GetOriginForURI(nsIURI* aURI, char **aOrigin)
|
||||
nsPrincipal::GetOriginForURI(nsIURI* aURI, nsACString& aOrigin)
|
||||
{
|
||||
if (!aURI) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aOrigin = nullptr;
|
||||
|
||||
nsCOMPtr<nsIURI> origin = NS_GetInnermostURI(aURI);
|
||||
if (!origin) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -210,29 +144,21 @@ nsPrincipal::GetOriginForURI(nsIURI* aURI, char **aOrigin)
|
||||
hostPort.AppendInt(port, 10);
|
||||
}
|
||||
|
||||
nsAutoCString scheme;
|
||||
rv = origin->GetScheme(scheme);
|
||||
rv = origin->GetScheme(aOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aOrigin = ToNewCString(scheme + NS_LITERAL_CSTRING("://") + hostPort);
|
||||
aOrigin.AppendLiteral("://");
|
||||
aOrigin.Append(hostPort);
|
||||
}
|
||||
else {
|
||||
// Some URIs (e.g., nsSimpleURI) don't support asciiHost. Just
|
||||
// get the full spec.
|
||||
nsAutoCString spec;
|
||||
// XXX nsMozIconURI and nsJARURI don't implement this correctly, they
|
||||
// both fall back to GetSpec. That needs to be fixed.
|
||||
rv = origin->GetAsciiSpec(spec);
|
||||
rv = origin->GetAsciiSpec(aOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aOrigin = ToNewCString(spec);
|
||||
}
|
||||
|
||||
return *aOrigin ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetOrigin(char **aOrigin)
|
||||
nsPrincipal::GetOrigin(nsACString& aOrigin)
|
||||
{
|
||||
return GetOriginForURI(mCodebase, aOrigin);
|
||||
}
|
||||
@@ -478,13 +404,6 @@ nsPrincipal::GetUnknownAppId(bool* aUnknownAppId)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetIsNullPrincipal(bool* aIsNullPrincipal)
|
||||
{
|
||||
*aIsNullPrincipal = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
{
|
||||
@@ -638,7 +557,6 @@ IsOnFullDomainWhitelist(nsIURI* aURI)
|
||||
// 0th entry only active when testing:
|
||||
NS_LITERAL_CSTRING("test1.example.org"),
|
||||
NS_LITERAL_CSTRING("map.baidu.com"),
|
||||
NS_LITERAL_CSTRING("music.baidu.com"),
|
||||
NS_LITERAL_CSTRING("3g.163.com"),
|
||||
NS_LITERAL_CSTRING("3glogo.gtimg.com"), // for 3g.163.com
|
||||
NS_LITERAL_CSTRING("info.3g.qq.com"), // for 3g.qq.com
|
||||
@@ -646,6 +564,42 @@ IsOnFullDomainWhitelist(nsIURI* aURI)
|
||||
NS_LITERAL_CSTRING("img.m.baidu.com"), // for [shucheng|ks].baidu.com
|
||||
NS_LITERAL_CSTRING("m.mogujie.com"),
|
||||
NS_LITERAL_CSTRING("touch.qunar.com"),
|
||||
NS_LITERAL_CSTRING("mjs.sinaimg.cn"), // for sina.cn
|
||||
NS_LITERAL_CSTRING("static.qiyi.com"), // for m.iqiyi.com
|
||||
NS_LITERAL_CSTRING("cdn.kuaidi100.com"), // for m.kuaidi100.com
|
||||
NS_LITERAL_CSTRING("m.pc6.com"),
|
||||
NS_LITERAL_CSTRING("m.haosou.com"),
|
||||
NS_LITERAL_CSTRING("m.mi.com"),
|
||||
NS_LITERAL_CSTRING("wappass.baidu.com"),
|
||||
NS_LITERAL_CSTRING("m.video.baidu.com"),
|
||||
NS_LITERAL_CSTRING("m.video.baidu.com"),
|
||||
NS_LITERAL_CSTRING("imgcache.gtimg.cn"), // for m.v.qq.com
|
||||
NS_LITERAL_CSTRING("i.yimg.jp"), // for *.yahoo.co.jp
|
||||
NS_LITERAL_CSTRING("ai.yimg.jp"), // for *.yahoo.co.jp
|
||||
NS_LITERAL_CSTRING("daily.c.yimg.jp"), // for sp.daily.co.jp
|
||||
NS_LITERAL_CSTRING("stat100.ameba.jp"), // for ameblo.jp
|
||||
NS_LITERAL_CSTRING("user.ameba.jp"), // for ameblo.jp
|
||||
NS_LITERAL_CSTRING("www.goo.ne.jp"),
|
||||
NS_LITERAL_CSTRING("s.tabelog.jp"),
|
||||
NS_LITERAL_CSTRING("x.gnst.jp"), // for mobile.gnavi.co.jp
|
||||
NS_LITERAL_CSTRING("c.x.gnst.jp"), // for mobile.gnavi.co.jp
|
||||
NS_LITERAL_CSTRING("www.smbc-card.com"),
|
||||
NS_LITERAL_CSTRING("static.card.jp.rakuten-static.com"), // for rakuten-card.co.jp
|
||||
NS_LITERAL_CSTRING("img.mixi.net"), // for mixi.jp
|
||||
NS_LITERAL_CSTRING("girlschannel.net"),
|
||||
NS_LITERAL_CSTRING("www.fancl.co.jp"),
|
||||
NS_LITERAL_CSTRING("s.cosme.net"),
|
||||
NS_LITERAL_CSTRING("www.sapporobeer.jp"),
|
||||
NS_LITERAL_CSTRING("www.mapion.co.jp"),
|
||||
NS_LITERAL_CSTRING("touch.navitime.co.jp"),
|
||||
NS_LITERAL_CSTRING("sp.mbga.jp"),
|
||||
NS_LITERAL_CSTRING("ava-a.sp.mbga.jp"), // for sp.mbga.jp
|
||||
NS_LITERAL_CSTRING("www.ntv.co.jp"),
|
||||
NS_LITERAL_CSTRING("mobile.suntory.co.jp"), // for suntory.jp
|
||||
NS_LITERAL_CSTRING("www.aeonsquare.net"),
|
||||
NS_LITERAL_CSTRING("mw.nikkei.com"),
|
||||
NS_LITERAL_CSTRING("www.nhk.or.jp"),
|
||||
NS_LITERAL_CSTRING("www.tokyo-sports.co.jp"),
|
||||
};
|
||||
static const size_t sNumFullDomainsOnWhitelist =
|
||||
MOZ_ARRAY_LENGTH(sFullDomainsOnWhitelist);
|
||||
@@ -765,8 +719,6 @@ NS_IMPL_QUERY_INTERFACE_CI(nsExpandedPrincipal,
|
||||
NS_IMPL_CI_INTERFACE_GETTER(nsExpandedPrincipal,
|
||||
nsIPrincipal,
|
||||
nsIExpandedPrincipal)
|
||||
NS_IMPL_ADDREF_INHERITED(nsExpandedPrincipal, nsBasePrincipal)
|
||||
NS_IMPL_RELEASE_INHERITED(nsExpandedPrincipal, nsBasePrincipal)
|
||||
|
||||
nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr <nsIPrincipal> > &aWhiteList)
|
||||
{
|
||||
@@ -790,10 +742,10 @@ nsExpandedPrincipal::SetDomain(nsIURI* aDomain)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsExpandedPrincipal::GetOrigin(char** aOrigin)
|
||||
nsExpandedPrincipal::GetOrigin(nsACString& aOrigin)
|
||||
{
|
||||
*aOrigin = ToNewCString(NS_LITERAL_CSTRING(EXPANDED_PRINCIPAL_SPEC));
|
||||
return *aOrigin ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
aOrigin.AssignLiteral(EXPANDED_PRINCIPAL_SPEC);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
typedef nsresult (NS_STDCALL nsIPrincipal::*nsIPrincipalMemFn)(nsIPrincipal* aOther,
|
||||
@@ -955,13 +907,6 @@ nsExpandedPrincipal::GetUnknownAppId(bool* aUnknownAppId)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsExpandedPrincipal::GetIsNullPrincipal(bool* aIsNullPrincipal)
|
||||
{
|
||||
*aIsNullPrincipal = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsExpandedPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
{
|
||||
@@ -980,16 +925,22 @@ nsExpandedPrincipal::IsOnCSSUnprefixingWhitelist()
|
||||
void
|
||||
nsExpandedPrincipal::GetScriptLocation(nsACString& aStr)
|
||||
{
|
||||
// Is that a good idea to list it's principals?
|
||||
aStr.Assign(EXPANDED_PRINCIPAL_SPEC);
|
||||
}
|
||||
aStr.AppendLiteral(" (");
|
||||
|
||||
#ifdef DEBUG
|
||||
void nsExpandedPrincipal::dumpImpl()
|
||||
{
|
||||
fprintf(stderr, "nsExpandedPrincipal (%p)\n", static_cast<void*>(this));
|
||||
for (size_t i = 0; i < mPrincipals.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aStr.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
nsAutoCString spec;
|
||||
nsJSPrincipals::get(mPrincipals.ElementAt(i))->GetScriptLocation(spec);
|
||||
|
||||
aStr.Append(spec);
|
||||
|
||||
}
|
||||
aStr.Append(")");
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Methods implementing nsISerializable //
|
||||
|
||||
+11
-42
@@ -11,48 +11,24 @@
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
class nsBasePrincipal : public nsJSPrincipals
|
||||
class nsPrincipal final : public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
nsBasePrincipal();
|
||||
|
||||
protected:
|
||||
virtual ~nsBasePrincipal();
|
||||
|
||||
public:
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release(void);
|
||||
NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp);
|
||||
NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp);
|
||||
public:
|
||||
|
||||
static const char sInvalid[];
|
||||
|
||||
protected:
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() = 0;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
};
|
||||
|
||||
class nsPrincipal final : public nsBasePrincipal
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD Equals(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD EqualsConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
||||
NS_IMETHOD GetURI(nsIURI** aURI) override;
|
||||
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
|
||||
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
|
||||
NS_IMETHOD GetOrigin(char** aOrigin) override;
|
||||
NS_IMETHOD GetOrigin(nsACString& aOrigin) override;
|
||||
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal) override;
|
||||
@@ -61,12 +37,8 @@ public:
|
||||
NS_IMETHOD GetAppId(uint32_t* aAppStatus) override;
|
||||
NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement) override;
|
||||
NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) override;
|
||||
NS_IMETHOD GetIsNullPrincipal(bool* aIsNullPrincipal) override;
|
||||
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
||||
virtual bool IsOnCSSUnprefixingWhitelist() override;
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() override;
|
||||
#endif
|
||||
|
||||
nsPrincipal();
|
||||
|
||||
@@ -98,7 +70,7 @@ public:
|
||||
/**
|
||||
* Computes the puny-encoded origin of aURI.
|
||||
*/
|
||||
static nsresult GetOriginForURI(nsIURI* aURI, char **aOrigin);
|
||||
static nsresult GetOriginForURI(nsIURI* aURI, nsACString& aOrigin);
|
||||
|
||||
/**
|
||||
* Called at startup to setup static data, e.g. about:config pref-observers.
|
||||
@@ -124,7 +96,7 @@ protected:
|
||||
uint16_t GetAppStatus();
|
||||
};
|
||||
|
||||
class nsExpandedPrincipal : public nsIExpandedPrincipal, public nsBasePrincipal
|
||||
class nsExpandedPrincipal : public nsIExpandedPrincipal, public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
explicit nsExpandedPrincipal(nsTArray< nsCOMPtr<nsIPrincipal> > &aWhiteList);
|
||||
@@ -133,16 +105,18 @@ protected:
|
||||
virtual ~nsExpandedPrincipal();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIEXPANDEDPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) AddRef() override { return nsJSPrincipals::AddRef(); };
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) Release() override { return nsJSPrincipals::Release(); };
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD Equals(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD EqualsConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
||||
NS_IMETHOD GetURI(nsIURI** aURI) override;
|
||||
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
|
||||
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
|
||||
NS_IMETHOD GetOrigin(char** aOrigin) override;
|
||||
NS_IMETHOD GetOrigin(nsACString& aOrigin) override;
|
||||
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal) override;
|
||||
@@ -151,13 +125,8 @@ public:
|
||||
NS_IMETHOD GetAppId(uint32_t* aAppStatus) override;
|
||||
NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement) override;
|
||||
NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) override;
|
||||
NS_IMETHOD GetIsNullPrincipal(bool* aIsNullPrincipal) override;
|
||||
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
||||
virtual bool IsOnCSSUnprefixingWhitelist() override;
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() override;
|
||||
#endif
|
||||
|
||||
virtual void GetScriptLocation(nsACString &aStr) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -281,7 +281,7 @@ nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
nsAutoCString origin;
|
||||
NS_ENSURE_SUCCESS(aPrin->GetOrigin(getter_Copies(origin)),
|
||||
NS_ENSURE_SUCCESS(aPrin->GetOrigin(origin),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
nsString appOrigin;
|
||||
NS_ENSURE_SUCCESS(app->GetOrigin(appOrigin),
|
||||
@@ -294,7 +294,7 @@ nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
nsAutoCString appOriginPunned;
|
||||
NS_ENSURE_SUCCESS(nsPrincipal::GetOriginForURI(appURI, getter_Copies(appOriginPunned)),
|
||||
NS_ENSURE_SUCCESS(nsPrincipal::GetOriginForURI(appURI, appOriginPunned),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
if (!appOriginPunned.Equals(origin)) {
|
||||
@@ -704,10 +704,10 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
||||
auto themeOrigin = Preferences::GetCString("b2g.theme.origin");
|
||||
if (themeOrigin) {
|
||||
nsAutoCString targetOrigin;
|
||||
nsPrincipal::GetOriginForURI(targetBaseURI, getter_Copies(targetOrigin));
|
||||
nsPrincipal::GetOriginForURI(targetBaseURI, targetOrigin);
|
||||
if (targetOrigin.Equals(themeOrigin)) {
|
||||
nsAutoCString pOrigin;
|
||||
aPrincipal->GetOrigin(getter_Copies(pOrigin));
|
||||
aPrincipal->GetOrigin(pOrigin);
|
||||
return nsContentUtils::IsExactSitePermAllow(aPrincipal, "themeable") ||
|
||||
pOrigin.Equals(themeOrigin)
|
||||
? NS_OK : NS_ERROR_DOM_BAD_URI;
|
||||
@@ -1003,7 +1003,8 @@ nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, uint32_t aAppId,
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
uriPrinc->GetPrincipal(getter_AddRefs(principal));
|
||||
if (!principal) {
|
||||
return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, result);
|
||||
principal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
principal.forget(result);
|
||||
@@ -1098,15 +1099,16 @@ nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI,
|
||||
NS_URIChainHasFlags(aURI,
|
||||
nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
|
||||
&inheritsPrincipal);
|
||||
if (NS_FAILED(rv) || inheritsPrincipal) {
|
||||
return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, result);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = CreateCodebasePrincipal(aURI, aAppId, aInMozBrowser,
|
||||
getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_IF_ADDREF(*result = principal);
|
||||
if (NS_FAILED(rv) || inheritsPrincipal) {
|
||||
principal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
} else {
|
||||
rv = CreateCodebasePrincipal(aURI, aAppId, aInMozBrowser,
|
||||
getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
principal.forget(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -29,28 +29,6 @@ NS_IMPL_CI_INTERFACE_GETTER(nsSystemPrincipal,
|
||||
nsIPrincipal,
|
||||
nsISerializable)
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsSystemPrincipal::AddRef()
|
||||
{
|
||||
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
|
||||
nsrefcnt count = ++refcount;
|
||||
NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this));
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsSystemPrincipal::Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != refcount, "dup release");
|
||||
nsrefcnt count = --refcount;
|
||||
NS_LOG_RELEASE(this, count, "nsSystemPrincipal");
|
||||
if (count == 0) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const char SYSTEM_PRINCIPAL_SPEC[] = "[System Principal]";
|
||||
|
||||
void
|
||||
@@ -59,14 +37,6 @@ nsSystemPrincipal::GetScriptLocation(nsACString &aStr)
|
||||
aStr.Assign(SYSTEM_PRINCIPAL_SPEC);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void nsSystemPrincipal::dumpImpl()
|
||||
{
|
||||
fprintf(stderr, "nsSystemPrincipal (%p)\n", this);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// Methods implementing nsIPrincipal //
|
||||
///////////////////////////////////////
|
||||
@@ -119,10 +89,10 @@ nsSystemPrincipal::GetURI(nsIURI** aURI)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetOrigin(char** aOrigin)
|
||||
nsSystemPrincipal::GetOrigin(nsACString& aOrigin)
|
||||
{
|
||||
*aOrigin = ToNewCString(NS_LITERAL_CSTRING(SYSTEM_PRINCIPAL_SPEC));
|
||||
return *aOrigin ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
aOrigin.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -187,13 +157,6 @@ nsSystemPrincipal::GetUnknownAppId(bool* aUnknownAppId)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetIsNullPrincipal(bool* aIsNullPrincipal)
|
||||
{
|
||||
*aIsNullPrincipal = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
{
|
||||
@@ -201,13 +164,6 @@ nsSystemPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsSystemPrincipal::IsOnCSSUnprefixingWhitelist()
|
||||
{
|
||||
// chrome stylesheets should not be fed to the CSS Unprefixing Service.
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Methods implementing nsISerializable //
|
||||
//////////////////////////////////////////
|
||||
@@ -225,15 +181,3 @@ nsSystemPrincipal::Write(nsIObjectOutputStream* aStream)
|
||||
// no-op: CID is sufficient to identify the mSystemPrincipal singleton
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Constructor, Destructor, initialization //
|
||||
/////////////////////////////////////////////
|
||||
|
||||
nsSystemPrincipal::nsSystemPrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
nsSystemPrincipal::~nsSystemPrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
+28
-17
@@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- 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/. */
|
||||
@@ -11,34 +12,44 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
#define NS_SYSTEMPRINCIPAL_CID \
|
||||
{ 0x4a6212db, 0xaccb, 0x11d3, \
|
||||
{ 0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb }}
|
||||
#define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
|
||||
|
||||
|
||||
class nsSystemPrincipal final : public nsJSPrincipals
|
||||
class nsSystemPrincipal final : public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
// Our refcount is managed by nsJSPrincipals. Use this macro to avoid
|
||||
// an extra refcount member.
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD Equals(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD EqualsConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
||||
NS_IMETHOD GetURI(nsIURI** aURI) override;
|
||||
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
|
||||
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
|
||||
NS_IMETHOD GetOrigin(nsACString& aOrigin) override;
|
||||
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) override;
|
||||
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal) override;
|
||||
NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp);
|
||||
NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp);
|
||||
NS_IMETHOD GetJarPrefix(nsACString& aJarPrefix) override;
|
||||
NS_IMETHOD GetAppStatus(uint16_t* aAppStatus) override;
|
||||
NS_IMETHOD GetAppId(uint32_t* aAppStatus) override;
|
||||
NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement) override;
|
||||
NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) override;
|
||||
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
||||
|
||||
nsSystemPrincipal();
|
||||
nsSystemPrincipal() {}
|
||||
|
||||
virtual void GetScriptLocation(nsACString &aStr) override;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void dumpImpl() override;
|
||||
#endif
|
||||
virtual void GetScriptLocation(nsACString &aStr) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsSystemPrincipal(void);
|
||||
|
||||
// XXX Probably unnecessary. See bug 143559.
|
||||
NS_DECL_OWNINGTHREAD
|
||||
virtual ~nsSystemPrincipal(void) {}
|
||||
};
|
||||
|
||||
#endif // nsSystemPrincipal_h__
|
||||
|
||||
@@ -1652,7 +1652,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_DISALLOW_INHERIT_OWNER) {
|
||||
inheritOwner = false;
|
||||
owner = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
owner = nsNullPrincipal::Create();
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
@@ -12234,7 +12234,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
||||
// Ensure that we have an owner. Otherwise javascript: URIs will
|
||||
// pick it up from the about:blank page we just loaded, and we
|
||||
// don't really want even that in this case.
|
||||
owner = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
owner = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(owner, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
@@ -13917,8 +13917,7 @@ nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
|
||||
nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
|
||||
if (!print || !print->IsInitializedForPrintPreview()) {
|
||||
Stop(nsIWebNavigation::STOP_ALL);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_STATE(principal);
|
||||
nsresult rv = CreateAboutBlankContentViewer(principal, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
+95
-48
@@ -32,6 +32,25 @@ Animation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
return dom::AnimationBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Animation interface:
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
Animation::SetEffect(KeyframeEffectReadonly* aEffect)
|
||||
{
|
||||
if (mEffect) {
|
||||
mEffect->SetParentTime(Nullable<TimeDuration>());
|
||||
}
|
||||
mEffect = aEffect;
|
||||
if (mEffect) {
|
||||
mEffect->SetParentTime(GetCurrentTime());
|
||||
}
|
||||
UpdateRelevance();
|
||||
}
|
||||
|
||||
void
|
||||
Animation::SetStartTime(const Nullable<TimeDuration>& aNewStartTime)
|
||||
{
|
||||
@@ -73,6 +92,7 @@ Animation::SetStartTime(const Nullable<TimeDuration>& aNewStartTime)
|
||||
PostUpdate();
|
||||
}
|
||||
|
||||
// http://w3c.github.io/web-animations/#current-time
|
||||
Nullable<TimeDuration>
|
||||
Animation::GetCurrentTime() const
|
||||
{
|
||||
@@ -92,27 +112,6 @@ Animation::GetCurrentTime() const
|
||||
return result;
|
||||
}
|
||||
|
||||
// Implements http://w3c.github.io/web-animations/#silently-set-the-current-time
|
||||
void
|
||||
Animation::SilentlySetCurrentTime(const TimeDuration& aSeekTime)
|
||||
{
|
||||
if (!mHoldTime.IsNull() ||
|
||||
!mTimeline ||
|
||||
mTimeline->GetCurrentTime().IsNull() ||
|
||||
mPlaybackRate == 0.0
|
||||
/*or, once supported, if we have a pending pause task*/) {
|
||||
mHoldTime.SetValue(aSeekTime);
|
||||
if (!mTimeline || mTimeline->GetCurrentTime().IsNull()) {
|
||||
mStartTime.SetNull();
|
||||
}
|
||||
} else {
|
||||
mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
|
||||
(aSeekTime.MultDouble(1 / mPlaybackRate)));
|
||||
}
|
||||
|
||||
mPreviousCurrentTime.SetNull();
|
||||
}
|
||||
|
||||
// Implements http://w3c.github.io/web-animations/#set-the-current-time
|
||||
void
|
||||
Animation::SetCurrentTime(const TimeDuration& aSeekTime)
|
||||
@@ -143,18 +142,6 @@ Animation::SetPlaybackRate(double aPlaybackRate)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
Nullable<TimeDuration> previousTime = GetCurrentTime();
|
||||
mPlaybackRate = aPlaybackRate;
|
||||
if (!previousTime.IsNull()) {
|
||||
ErrorResult rv;
|
||||
SilentlySetCurrentTime(previousTime.Value());
|
||||
MOZ_ASSERT(!rv.Failed(), "Should not assert for non-null time");
|
||||
}
|
||||
}
|
||||
|
||||
AnimationPlayState
|
||||
Animation::PlayState() const
|
||||
{
|
||||
@@ -217,6 +204,38 @@ Animation::GetFinished(ErrorResult& aRv)
|
||||
return mFinished;
|
||||
}
|
||||
|
||||
void
|
||||
Animation::Cancel()
|
||||
{
|
||||
DoCancel();
|
||||
PostUpdate();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/web-animations/#finish-an-animation
|
||||
void
|
||||
Animation::Finish(ErrorResult& aRv)
|
||||
{
|
||||
if (mPlaybackRate == 0 ||
|
||||
(mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
TimeDuration limit =
|
||||
mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);
|
||||
|
||||
SetCurrentTime(limit);
|
||||
|
||||
if (mPendingState == PendingState::PlayPending) {
|
||||
CancelPendingTasks();
|
||||
if (mReady) {
|
||||
mReady->MaybeResolve(this);
|
||||
}
|
||||
}
|
||||
UpdateFinishedState(true);
|
||||
PostUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
Animation::Play(LimitBehavior aLimitBehavior)
|
||||
{
|
||||
@@ -227,12 +246,16 @@ Animation::Play(LimitBehavior aLimitBehavior)
|
||||
void
|
||||
Animation::Pause()
|
||||
{
|
||||
// TODO: The DoPause() call should not be synchronous (bug 1109390). See
|
||||
// http://w3c.github.io/web-animations/#pausing-an-animation-section
|
||||
DoPause();
|
||||
PostUpdate();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// JS wrappers for Animation interface:
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Nullable<double>
|
||||
Animation::GetStartTimeAsDouble() const
|
||||
{
|
||||
@@ -265,18 +288,7 @@ Animation::SetCurrentTimeAsDouble(const Nullable<double>& aCurrentTime,
|
||||
return SetCurrentTime(TimeDuration::FromMilliseconds(aCurrentTime.Value()));
|
||||
}
|
||||
|
||||
void
|
||||
Animation::SetEffect(KeyframeEffectReadonly* aEffect)
|
||||
{
|
||||
if (mEffect) {
|
||||
mEffect->SetParentTime(Nullable<TimeDuration>());
|
||||
}
|
||||
mEffect = aEffect;
|
||||
if (mEffect) {
|
||||
mEffect->SetParentTime(GetCurrentTime());
|
||||
}
|
||||
UpdateRelevance();
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
Animation::Tick()
|
||||
@@ -349,8 +361,41 @@ Animation::GetCurrentOrPendingStartTime() const
|
||||
return result;
|
||||
}
|
||||
|
||||
// http://w3c.github.io/web-animations/#silently-set-the-current-time
|
||||
void
|
||||
Animation::Cancel()
|
||||
Animation::SilentlySetCurrentTime(const TimeDuration& aSeekTime)
|
||||
{
|
||||
if (!mHoldTime.IsNull() ||
|
||||
mStartTime.IsNull() ||
|
||||
!mTimeline ||
|
||||
mTimeline->GetCurrentTime().IsNull() ||
|
||||
mPlaybackRate == 0.0) {
|
||||
mHoldTime.SetValue(aSeekTime);
|
||||
if (!mTimeline || mTimeline->GetCurrentTime().IsNull()) {
|
||||
mStartTime.SetNull();
|
||||
}
|
||||
} else {
|
||||
mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
|
||||
(aSeekTime.MultDouble(1 / mPlaybackRate)));
|
||||
}
|
||||
|
||||
mPreviousCurrentTime.SetNull();
|
||||
}
|
||||
|
||||
void
|
||||
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
Nullable<TimeDuration> previousTime = GetCurrentTime();
|
||||
mPlaybackRate = aPlaybackRate;
|
||||
if (!previousTime.IsNull()) {
|
||||
ErrorResult rv;
|
||||
SilentlySetCurrentTime(previousTime.Value());
|
||||
MOZ_ASSERT(!rv.Failed(), "Should not assert for non-null time");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Animation::DoCancel()
|
||||
{
|
||||
if (mPendingState != PendingState::NotPending) {
|
||||
CancelPendingTasks();
|
||||
@@ -493,6 +538,7 @@ Animation::ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
|
||||
}
|
||||
}
|
||||
|
||||
// http://w3c.github.io/web-animations/#play-an-animation
|
||||
void
|
||||
Animation::DoPlay(LimitBehavior aLimitBehavior)
|
||||
{
|
||||
@@ -556,6 +602,7 @@ Animation::DoPlay(LimitBehavior aLimitBehavior)
|
||||
UpdateTiming();
|
||||
}
|
||||
|
||||
// http://w3c.github.io/web-animations/#pause-an-animation
|
||||
void
|
||||
Animation::DoPause()
|
||||
{
|
||||
|
||||
+56
-42
@@ -73,35 +73,43 @@ public:
|
||||
virtual CSSAnimation* AsCSSAnimation() { return nullptr; }
|
||||
virtual CSSTransition* AsCSSTransition() { return nullptr; }
|
||||
|
||||
// Flag to pass to DoPlay to indicate that it should not carry out finishing
|
||||
// behavior (reset the current time to the beginning of the active duration).
|
||||
enum LimitBehavior {
|
||||
AutoRewind = 0,
|
||||
Continue = 1
|
||||
/**
|
||||
* Flag to pass to Play to indicate whether or not it should automatically
|
||||
* rewind the current time to the start point if the animation is finished.
|
||||
* For regular calls to play() from script we should do this, but when a CSS
|
||||
* animation's animation-play-state changes we shouldn't rewind the animation.
|
||||
*/
|
||||
enum class LimitBehavior {
|
||||
AutoRewind,
|
||||
Continue
|
||||
};
|
||||
|
||||
// Animation methods
|
||||
// Animation interface methods
|
||||
|
||||
KeyframeEffectReadonly* GetEffect() const { return mEffect; }
|
||||
void SetEffect(KeyframeEffectReadonly* aEffect);
|
||||
DocumentTimeline* Timeline() const { return mTimeline; }
|
||||
Nullable<TimeDuration> GetStartTime() const { return mStartTime; }
|
||||
void SetStartTime(const Nullable<TimeDuration>& aNewStartTime);
|
||||
Nullable<TimeDuration> GetCurrentTime() const;
|
||||
void SilentlySetCurrentTime(const TimeDuration& aNewCurrentTime);
|
||||
void SetCurrentTime(const TimeDuration& aNewCurrentTime);
|
||||
double PlaybackRate() const { return mPlaybackRate; }
|
||||
void SetPlaybackRate(double aPlaybackRate);
|
||||
void SilentlySetPlaybackRate(double aPlaybackRate);
|
||||
AnimationPlayState PlayState() const;
|
||||
virtual Promise* GetReady(ErrorResult& aRv);
|
||||
virtual Promise* GetFinished(ErrorResult& aRv);
|
||||
void Cancel();
|
||||
virtual void Finish(ErrorResult& aRv);
|
||||
virtual void Play(LimitBehavior aLimitBehavior);
|
||||
virtual void Pause();
|
||||
bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; }
|
||||
|
||||
// Wrapper functions for Animation DOM methods when called
|
||||
// from script. We often use the same methods internally and from
|
||||
// script but when called from script we (or one of our subclasses) perform
|
||||
// extra steps such as flushing style or converting the return type.
|
||||
// from script.
|
||||
//
|
||||
// We often use the same methods internally and from script but when called
|
||||
// from script we (or one of our subclasses) perform extra steps such as
|
||||
// flushing style or converting the return type.
|
||||
Nullable<double> GetStartTimeAsDouble() const;
|
||||
void SetStartTimeAsDouble(const Nullable<double>& aStartTime);
|
||||
Nullable<double> GetCurrentTimeAsDouble() const;
|
||||
@@ -109,12 +117,18 @@ public:
|
||||
ErrorResult& aRv);
|
||||
virtual AnimationPlayState PlayStateFromJS() const { return PlayState(); }
|
||||
virtual void PlayFromJS() { Play(LimitBehavior::AutoRewind); }
|
||||
// PauseFromJS is currently only here for symmetry with PlayFromJS but
|
||||
// in future we will likely have to flush style in
|
||||
// CSSAnimation::PauseFromJS so we leave it for now.
|
||||
/**
|
||||
* PauseFromJS is currently only here for symmetry with PlayFromJS but
|
||||
* in future we will likely have to flush style in
|
||||
* CSSAnimation::PauseFromJS so we leave it for now.
|
||||
*/
|
||||
void PauseFromJS() { Pause(); }
|
||||
// Wrapper functions for Animation DOM methods when called from style.
|
||||
//
|
||||
// Typically these DOM methods also notify style of changes but when
|
||||
// we are calling from style we don't need to do this.
|
||||
void CancelFromStyle() { DoCancel(); }
|
||||
|
||||
void SetEffect(KeyframeEffectReadonly* aEffect);
|
||||
void Tick();
|
||||
|
||||
/**
|
||||
@@ -169,17 +183,17 @@ public:
|
||||
* animation from any PendingAnimationTracker it may have been added to.
|
||||
*/
|
||||
void TriggerOnNextTick(const Nullable<TimeDuration>& aReadyTime);
|
||||
|
||||
// Testing only: Start or pause a pending animation using the current timeline
|
||||
// time. This is used to support existing tests that expect animations to
|
||||
// begin immediately. Ideally we would rewrite the those tests and get rid of
|
||||
// this method, but there are a lot of them.
|
||||
//
|
||||
// As with TriggerOnNextTick, the caller of this method is responsible for
|
||||
// removing the animation from any PendingAnimationTracker it may have been
|
||||
// added to.
|
||||
/**
|
||||
* Testing only: Start or pause a pending animation using the current
|
||||
* timeline time. This is used to support existing tests that expect
|
||||
* animations to begin immediately. Ideally we would rewrite the those tests
|
||||
* and get rid of this method, but there are a lot of them.
|
||||
*
|
||||
* As with TriggerOnNextTick, the caller of this method is responsible for
|
||||
* removing the animation from any PendingAnimationTracker it may have been
|
||||
* added to.
|
||||
*/
|
||||
void TriggerNow();
|
||||
|
||||
/**
|
||||
* When StartOnNextTick is called, we store the ready time but we don't apply
|
||||
* it until the next tick. In the meantime, GetStartTime() will return null.
|
||||
@@ -200,8 +214,6 @@ public:
|
||||
*/
|
||||
Nullable<TimeDuration> GetCurrentOrPendingStartTime() const;
|
||||
|
||||
void Cancel();
|
||||
|
||||
const nsString& Name() const
|
||||
{
|
||||
return mEffect ? mEffect->Name() : EmptyString();
|
||||
@@ -242,30 +254,32 @@ public:
|
||||
(PlayState() == AnimationPlayState::Running ||
|
||||
mPendingState == PendingState::PlayPending);
|
||||
}
|
||||
|
||||
bool IsRelevant() const { return mIsRelevant; }
|
||||
void UpdateRelevance();
|
||||
|
||||
void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
|
||||
void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
|
||||
|
||||
// Returns true if this animation does not currently need to update
|
||||
// style on the main thread (e.g. because it is empty, or is
|
||||
// running on the compositor).
|
||||
/**
|
||||
* Returns true if this animation does not currently need to update
|
||||
* style on the main thread (e.g. because it is empty, or is
|
||||
* running on the compositor).
|
||||
*/
|
||||
bool CanThrottle() const;
|
||||
|
||||
// Updates |aStyleRule| with the animation values of this animation's effect,
|
||||
// if any.
|
||||
// Any properties already contained in |aSetProperties| are not changed. Any
|
||||
// properties that are changed are added to |aSetProperties|.
|
||||
// |aNeedsRefreshes| will be set to true if this animation expects to update
|
||||
// the style rule on the next refresh driver tick as well (because it
|
||||
// is running and has an effect to sample).
|
||||
/**
|
||||
* Updates |aStyleRule| with the animation values of this animation's effect,
|
||||
* if any.
|
||||
* Any properties already contained in |aSetProperties| are not changed. Any
|
||||
* properties that are changed are added to |aSetProperties|.
|
||||
* |aNeedsRefreshes| will be set to true if this animation expects to update
|
||||
* the style rule on the next refresh driver tick as well (because it
|
||||
* is running and has an effect to sample).
|
||||
*/
|
||||
void ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
|
||||
nsCSSPropertySet& aSetProperties,
|
||||
bool& aNeedsRefreshes);
|
||||
|
||||
protected:
|
||||
void SilentlySetCurrentTime(const TimeDuration& aNewCurrentTime);
|
||||
void SilentlySetPlaybackRate(double aPlaybackRate);
|
||||
void DoCancel();
|
||||
void DoPlay(LimitBehavior aLimitBehavior);
|
||||
void DoPause();
|
||||
void ResumeAt(const TimeDuration& aReadyTime);
|
||||
|
||||
@@ -572,7 +572,8 @@ function assert_records(expected, desc) {
|
||||
// Test that starting a single animation that is cancelled by updating
|
||||
// the animation-iteration-count property dispatches an added notification
|
||||
// and then a removed notification.
|
||||
addAsyncAnimTest("single_animation_cancelled_fill", aOptions, function*() {
|
||||
addAsyncAnimTest("single_animation_cancelled_iteration_count",
|
||||
aOptions, function*() {
|
||||
// Start a short, repeated animation.
|
||||
e.style = "animation: anim 0.5s infinite;";
|
||||
|
||||
@@ -604,6 +605,44 @@ function assert_records(expected, desc) {
|
||||
e.style = "";
|
||||
});
|
||||
|
||||
// Test that starting a single animation that is cancelled by calling
|
||||
// cancel() dispatches an added notification and then a removed
|
||||
// notification.
|
||||
addAsyncAnimTest("single_animation_cancelled_api", aOptions, function*() {
|
||||
// Start a short, filled animation.
|
||||
e.style = "animation: anim 100s forwards;";
|
||||
|
||||
// The animation should cause the creation of a single Animation.
|
||||
var animations = e.getAnimations();
|
||||
is(animations.length, 1, "getAnimations().length after animation start");
|
||||
|
||||
// Wait for the single MutationRecord for the Animation addition to
|
||||
// be delivered.
|
||||
yield await_frame();
|
||||
assert_records([{ added: animations, changed: [], removed: [] }],
|
||||
"records after animation start");
|
||||
|
||||
// Cancel the animation
|
||||
animations[0].cancel();
|
||||
|
||||
// Wait for the single MutationRecord for the Animation removal to
|
||||
// be delivered.
|
||||
yield await_frame();
|
||||
assert_records([{ added: [], changed: [], removed: animations }],
|
||||
"records after animation end");
|
||||
|
||||
// Re-trigger the animation
|
||||
animations[0].play();
|
||||
yield await_frame();
|
||||
|
||||
// Wait for the single MutationRecord for the Animation (re-)addition to
|
||||
// be delivered.
|
||||
assert_records([{ added: animations, changed: [], removed: [] }],
|
||||
"records after animation start");
|
||||
|
||||
e.style = "";
|
||||
});
|
||||
|
||||
// Test that updating an animation property dispatches a changed notification.
|
||||
[
|
||||
{ name: "duration", prop: "animationDuration", val: "200s" },
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../testcommon.js"></script>
|
||||
<div id="log"></div>
|
||||
<style>
|
||||
@keyframes translateAnim {
|
||||
to { transform: translate(100px) }
|
||||
}
|
||||
@keyframes marginLeftAnim {
|
||||
to { margin-left: 100px }
|
||||
}
|
||||
@keyframes marginLeftAnim100To200 {
|
||||
from { margin-left: 100px }
|
||||
to { margin-left: 200px }
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: translateAnim 100s' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
assert_not_equals(getComputedStyle(div).transform, 'none',
|
||||
'transform style is animated before cancelling');
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).transform, 'none',
|
||||
'transform style is no longer animated after cancelling');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Animated style is cleared after cancelling a running CSS animation');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: translateAnim 100s forwards' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.finish();
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
assert_not_equals(getComputedStyle(div).transform, 'none',
|
||||
'transform style is filling before cancelling');
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).transform, 'none',
|
||||
'fill style is cleared after cancelling');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Animated style is cleared after cancelling a filling CSS animation');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: translateAnim 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
div.addEventListener('animationend', t.step_func(function() {
|
||||
assert_unreached('Got unexpected end event on cancelled animation');
|
||||
}));
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
// Seek to just before the end then cancel
|
||||
animation.currentTime = 99.9 * 1000;
|
||||
animation.cancel();
|
||||
|
||||
// Then wait a couple of frames and check that no event was dispatched
|
||||
return waitForAnimationFrames(2);
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
}, 'Cancelled CSS animations do not dispatch events');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: marginLeftAnim 100s linear' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
|
||||
animation.currentTime = 50 * 1000;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '50px',
|
||||
'margin-left style is updated when cancelled animation is'
|
||||
+ ' seeked');
|
||||
}, 'After cancelling an animation, it can still be seeked');
|
||||
|
||||
async_test(function(t) {
|
||||
var div =
|
||||
addDiv(t, { style: 'animation: marginLeftAnim100To200 100s linear' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
animation.play();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '100px',
|
||||
'margin-left style is animated after re-starting animation');
|
||||
return animation.ready;
|
||||
})).then(t.step_func(function() {
|
||||
assert_equals(animation.playState, 'running',
|
||||
'Animation succeeds in running after being re-started');
|
||||
t.done();
|
||||
}));
|
||||
}, 'After cancelling an animation, it can still be re-used');
|
||||
|
||||
test(function(t) {
|
||||
var div =
|
||||
addDiv(t, { style: 'animation: marginLeftAnim100To200 100s linear' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
|
||||
// Trigger a change to some animation properties and check that this
|
||||
// doesn't cause the animation to become live again
|
||||
div.style.animationDuration = '200s';
|
||||
flushComputedStyle(div);
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is still not animated after updating'
|
||||
+ ' animation-duration');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is still idle after updating animation-duration');
|
||||
}, 'After cancelling an animation, updating animation properties doesn\'t make'
|
||||
+ ' it live again');
|
||||
|
||||
test(function(t) {
|
||||
var div =
|
||||
addDiv(t, { style: 'animation: marginLeftAnim100To200 100s linear' });
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
|
||||
// Make some changes to animation-play-state and check that the
|
||||
// animation doesn't become live again. This is because it should be
|
||||
// possible to cancel an animation from script such that all future
|
||||
// changes to style are ignored.
|
||||
|
||||
// Redundant change
|
||||
div.style.animationPlayState = 'running';
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is still idle after a redundant change to'
|
||||
+ ' animation-play-state');
|
||||
|
||||
// Pause
|
||||
div.style.animationPlayState = 'paused';
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is still idle after setting'
|
||||
+ ' animation-play-state: paused');
|
||||
|
||||
// Play
|
||||
div.style.animationPlayState = 'running';
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is still idle after re-setting'
|
||||
+ ' animation-play-state: running');
|
||||
|
||||
}, 'After cancelling an animation, updating animation-play-state doesn\'t'
|
||||
+ ' make it live again');
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -627,7 +627,7 @@ async_test(function(t) {
|
||||
'animation has finished');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test Animation.currentTime clamping');
|
||||
}, 'Animation.currentTime clamping');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, {'class': 'animated-div'});
|
||||
@@ -649,7 +649,17 @@ async_test(function(t) {
|
||||
'animation running in reverse has finished and currentTime is zero');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test Animation.currentTime clamping for reversed animation');
|
||||
}, 'Animation.currentTime clamping for reversed animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t, {'class': 'animated-div'});
|
||||
div.style.animation = 'anim 100s';
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
assert_equals(animation.currentTime, null,
|
||||
'The currentTime of a cancelled animation should be null');
|
||||
}, 'Animation.currentTime after cancelling');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../testcommon.js"></script>
|
||||
<div id="log"></div>
|
||||
<style>
|
||||
|
||||
.animated-div {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
@keyframes anim {
|
||||
from { margin-left: 100px; }
|
||||
to { margin-left: 200px; }
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
|
||||
'use strict';
|
||||
|
||||
const ANIM_PROP_VAL = 'anim 100s';
|
||||
const ANIM_DURATION = 100000; // ms
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.playbackRate = 0;
|
||||
|
||||
var threw = false;
|
||||
try {
|
||||
animation.finish();
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert_equals(e.name, 'InvalidStateError',
|
||||
'Exception should be an InvalidStateError exception when ' +
|
||||
'trying to finish an animation with playbackRate == 0');
|
||||
}
|
||||
assert_true(threw,
|
||||
'Expect InvalidStateError exception trying to finish an ' +
|
||||
'animation with playbackRate == 0');
|
||||
}, 'Test exceptions when finishing non-running animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
div.style.animationIterationCount = 'infinite';
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
var threw = false;
|
||||
try {
|
||||
animation.finish();
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert_equals(e.name, 'InvalidStateError',
|
||||
'Exception should be an InvalidStateError exception when ' +
|
||||
'trying to finish an infinite animation');
|
||||
}
|
||||
assert_true(threw,
|
||||
'Expect InvalidStateError exception trying to finish an ' +
|
||||
'infinite animation');
|
||||
}, 'Test exceptions when finishing infinite animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.finish();
|
||||
assert_equals(animation.currentTime, ANIM_DURATION,
|
||||
'After finishing, the currentTime should be set to the end ' +
|
||||
'of the active duration');
|
||||
}, 'Test finishing of animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.currentTime = ANIM_DURATION + 1000; // 1s past effect end
|
||||
|
||||
animation.finish();
|
||||
assert_equals(animation.currentTime, ANIM_DURATION,
|
||||
'After finishing, the currentTime should be set back to the ' +
|
||||
'end of the active duration');
|
||||
}, 'Test finishing of animation with a current time past the effect end');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.currentTime = ANIM_DURATION;
|
||||
|
||||
animation.finished.then(t.step_func(function() {
|
||||
animation.playbackRate = -1;
|
||||
animation.finish();
|
||||
assert_equals(animation.currentTime, 0,
|
||||
'After finishing a reversed animation the currentTime ' +
|
||||
'should be set to zero');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test finishing of reversed animation');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.currentTime = ANIM_DURATION;
|
||||
|
||||
animation.finished.then(t.step_func(function() {
|
||||
animation.playbackRate = -1;
|
||||
|
||||
animation.currentTime = -1000;
|
||||
|
||||
animation.finish();
|
||||
assert_equals(animation.currentTime, 0,
|
||||
'After finishing a reversed animation the currentTime ' +
|
||||
'should be set back to zero');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test finishing of reversed animation with with a current time less ' +
|
||||
'than zero');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.pause();
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.finish();
|
||||
assert_equals(animation.playState, 'paused',
|
||||
'The play state of a paused animation should remain ' +
|
||||
'"paused" even after finish() is called');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test paused state after finishing of animation');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, {'class': 'animated-div'});
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.finish();
|
||||
var marginLeft = parseFloat(getComputedStyle(div).marginLeft);
|
||||
assert_equals(marginLeft, 10,
|
||||
'The computed style should be reset when finish() is ' +
|
||||
'called');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Test resetting of computed style');
|
||||
|
||||
</script>
|
||||
@@ -140,13 +140,11 @@ async_test(function(t) {
|
||||
animation.finished.then(t.step_func(function() {
|
||||
assert_unreached('finished promise is fulfilled');
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
assert_not_equals(animation.finished, previousFinishedPromise,
|
||||
'Finished promise should change after the original is ' +
|
||||
'rejected');
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is idle after animation was cancelled');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
@@ -174,13 +172,11 @@ async_test(function(t) {
|
||||
animation.finished.then(t.step_func(function() {
|
||||
assert_unreached('finished promise was fulfilled');
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
assert_not_equals(animation.finished, previousFinishedPromise,
|
||||
'Finished promise should change after the original is ' +
|
||||
'rejected');
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is idle after animation was cancelled');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
@@ -192,6 +188,72 @@ async_test(function(t) {
|
||||
}, 'finished promise is rejected when an animation is cancelled by changing ' +
|
||||
'the animation property');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
var previousFinishedPromise = animation.finished;
|
||||
|
||||
// Set up listeners on finished promise
|
||||
animation.finished.then(t.step_func(function() {
|
||||
assert_unreached('finished promise was fulfilled');
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
assert_not_equals(animation.finished, previousFinishedPromise,
|
||||
'Finished promise should change after the original is ' +
|
||||
'rejected');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
|
||||
animation.cancel();
|
||||
|
||||
}, 'finished promise is rejected when an animation is cancelled by calling ' +
|
||||
'cancel()');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
var previousFinishedPromise = animation.finished;
|
||||
|
||||
animation.currentTime = ANIM_DURATION;
|
||||
|
||||
animation.finished.then(t.step_func(function() {
|
||||
animation.cancel();
|
||||
assert_not_equals(animation.finished, previousFinishedPromise,
|
||||
'A new finished promise should be created when'
|
||||
+ ' cancelling a finished player');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
}, 'cancelling an already-finished player replaces the finished promise');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
|
||||
// The spec says we still create a new finished promise and reject the old
|
||||
// one even if we're already idle. That behavior might change, but for now
|
||||
// test that we do that.
|
||||
animation.finished.catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'finished promise is rejected with AbortError');
|
||||
t.done();
|
||||
}));
|
||||
|
||||
// Redundant call to cancel();
|
||||
var previousFinishedPromise = animation.finished;
|
||||
animation.cancel();
|
||||
assert_not_equals(animation.finished, previousFinishedPromise,
|
||||
'A redundant call to cancel() should still generate a new'
|
||||
+ ' finished promise');
|
||||
}, 'cancelling an idle player still replaces the finished promise');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = ANIM_PROP_VAL;
|
||||
@@ -286,5 +348,4 @@ async_test(function(t) {
|
||||
}));
|
||||
}, 'Test finished promise changes when animationPlayState set to running');
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -66,4 +66,24 @@ test(function(t) {
|
||||
+ ' animation-play-state (got: ' + animation.playState + ')');
|
||||
}, 'Animation.playState updates when resumed by setting style');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = 'anim 1000s';
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
assert_equals(animation.playState, 'idle');
|
||||
}, 'Animation returns correct playState when cancelled');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = 'anim 1000s';
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
animation.currentTime = 50 * 1000;
|
||||
assert_equals(animation.playState, 'paused',
|
||||
'After seeking an idle animation, it is effectively paused');
|
||||
}, 'After cancelling an animation, seeking it makes it paused');
|
||||
|
||||
</script>
|
||||
|
||||
@@ -96,8 +96,6 @@ async_test(function(t) {
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'ready promise is rejected with AbortError');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is idle after animation was cancelled');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
@@ -128,8 +126,6 @@ async_test(function(t) {
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'ready promise is rejected with AbortError');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Animation is idle after animation was cancelled');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
@@ -141,6 +137,47 @@ async_test(function(t) {
|
||||
}, 'ready promise is rejected when an animation is cancelled by updating'
|
||||
+ ' the animation property');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = 'abc 100s';
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
assert_unreached('ready promise was fulfilled');
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'ready promise is rejected with AbortError');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
|
||||
animation.cancel();
|
||||
}, 'ready promise is rejected when a play-pending animation is cancelled by'
|
||||
+ ' calling cancel()');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = 'abc 100s';
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.pause();
|
||||
|
||||
// Set up listeners on pause-pending ready promise
|
||||
animation.ready.then(t.step_func(function() {
|
||||
assert_unreached('ready promise was fulfilled');
|
||||
})).catch(t.step_func(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'ready promise is rejected with AbortError');
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
|
||||
animation.cancel();
|
||||
}));
|
||||
}, 'ready promise is rejected when a pause-pending animation is cancelled by'
|
||||
+ ' calling cancel()');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: abc 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
@@ -655,7 +655,20 @@ async_test(function(t) {
|
||||
})).then(function() {
|
||||
t.done();
|
||||
});
|
||||
}, 'Animation.startTime after paused');
|
||||
}, 'Animation.startTime after pausing');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, {'class': 'animated-div'});
|
||||
div.style.animation = 'anim 100s';
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.cancel();
|
||||
assert_equals(animation.startTime, null,
|
||||
'The startTime of a cancelled animation should be null');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Animation.startTime after cancelling');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -250,4 +250,23 @@ test(function(t) {
|
||||
+ ' duration changes');
|
||||
}, 'getAnimations returns objects with the same identity');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t);
|
||||
div.style.animation = 'anim1 100s';
|
||||
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'getAnimations returns an animation before cancelling');
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
animation.cancel();
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'getAnimations does not return cancelled animations');
|
||||
|
||||
animation.play();
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'getAnimations returns cancelled animations that have been re-started');
|
||||
|
||||
}, 'getAnimations for CSS Animations that are cancelled');
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../testcommon.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'margin-left: 0px' });
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.style.transition = 'margin-left 100s';
|
||||
div.style.marginLeft = '1000px';
|
||||
flushComputedStyle(div);
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(waitForFrame).then(t.step_func(function() {
|
||||
assert_not_equals(getComputedStyle(div).marginLeft, '1000px',
|
||||
'transform style is animated before cancelling');
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, div.style.marginLeft,
|
||||
'transform style is no longer animated after cancelling');
|
||||
t.done();
|
||||
}));
|
||||
}, 'Animated style is cleared after cancelling a running CSS transition');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'margin-left: 0px' });
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.style.transition = 'margin-left 100s';
|
||||
div.style.marginLeft = '1000px';
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.addEventListener('transitionend', t.step_func(function() {
|
||||
assert_unreached('Got unexpected end event on cancelled transition');
|
||||
}));
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
// Seek to just before the end then cancel
|
||||
animation.currentTime = 99.9 * 1000;
|
||||
animation.cancel();
|
||||
|
||||
// Then wait a couple of frames and check that no event was dispatched
|
||||
return waitForAnimationFrames(2);
|
||||
})).then(t.step_func(function() {
|
||||
t.done();
|
||||
}));
|
||||
}, 'Cancelled CSS transitions do not dispatch events');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'margin-left: 0px' });
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.style.transition = 'margin-left 100s';
|
||||
div.style.marginLeft = '1000px';
|
||||
flushComputedStyle(div);
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '1000px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
animation.play();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is animated after re-starting transition');
|
||||
return animation.ready;
|
||||
})).then(t.step_func(function() {
|
||||
assert_equals(animation.playState, 'running',
|
||||
'Transition succeeds in running after being re-started');
|
||||
t.done();
|
||||
}));
|
||||
}, 'After cancelling a transition, it can still be re-used');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = addDiv(t, { style: 'margin-left: 0px' });
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.style.transition = 'margin-left 100s';
|
||||
div.style.marginLeft = '1000px';
|
||||
flushComputedStyle(div);
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.ready.then(t.step_func(function() {
|
||||
animation.finish();
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '1000px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
animation.play();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '0px',
|
||||
'margin-left style is animated after re-starting transition');
|
||||
return animation.ready;
|
||||
})).then(t.step_func(function() {
|
||||
assert_equals(animation.playState, 'running',
|
||||
'Transition succeeds in running after being re-started');
|
||||
t.done();
|
||||
}));
|
||||
}, 'After cancelling a finished transition, it can still be re-used');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t, { style: 'margin-left: 0px' });
|
||||
flushComputedStyle(div);
|
||||
|
||||
div.style.transition = 'margin-left 100s';
|
||||
div.style.marginLeft = '1000px';
|
||||
flushComputedStyle(div);
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.cancel();
|
||||
assert_equals(getComputedStyle(div).marginLeft, '1000px',
|
||||
'margin-left style is not animated after cancelling');
|
||||
|
||||
// Trigger a change to a transition property and check that this
|
||||
// doesn't cause the animation to become live again
|
||||
div.style.transitionDuration = '200s';
|
||||
flushComputedStyle(div);
|
||||
assert_equals(getComputedStyle(div).marginLeft, '1000px',
|
||||
'margin-left style is still not animated after updating'
|
||||
+ ' transition-duration');
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'Transition is still idle after updating transition-duration');
|
||||
}, 'After cancelling a transition, updating transition properties doesn\'t make'
|
||||
+ ' it live again');
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -4,7 +4,9 @@ support-files =
|
||||
|
||||
[css-animations/test_animations-dynamic-changes.html]
|
||||
[css-animations/test_animation-pausing.html]
|
||||
[css-animations/test_animation-cancel.html]
|
||||
[css-animations/test_animation-currenttime.html]
|
||||
[css-animations/test_animation-finish.html]
|
||||
[css-animations/test_animation-finished.html]
|
||||
[css-animations/test_animation-playstate.html]
|
||||
[css-animations/test_animation-ready.html]
|
||||
@@ -14,6 +16,7 @@ support-files =
|
||||
[css-animations/test_element-get-animations.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[css-transitions/test_animation-pausing.html]
|
||||
[css-transitions/test_animation-cancel.html]
|
||||
[css-transitions/test_animation-currenttime.html]
|
||||
[css-transitions/test_animation-ready.html]
|
||||
[css-transitions/test_animation-starttime.html]
|
||||
|
||||
@@ -13,11 +13,11 @@ using namespace mozilla::dom;
|
||||
|
||||
/* static */ bool
|
||||
InterAppComm::EnabledForScope(JSContext* /* unused */,
|
||||
JS::Handle<JSObject*> /* unused */)
|
||||
JS::Handle<JSObject*> /* unused */)
|
||||
{
|
||||
// Disable the constructors if they're disabled by the preference for sure.
|
||||
if (!Preferences::GetBool("dom.inter-app-communication-api.enabled", false)) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only expose the constructors to the chrome codes for Goanna internal uses.
|
||||
|
||||
@@ -18,7 +18,7 @@ class InterAppComm
|
||||
{
|
||||
public:
|
||||
static bool EnabledForScope(JSContext* /* unused */,
|
||||
JS::Handle<JSObject*> /* unused */);
|
||||
JS::Handle<JSObject*> /* unused */);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsError.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
@@ -348,8 +349,8 @@ DOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
|
||||
// Don't give DOMParsers the system principal. Use a null
|
||||
// principal instead.
|
||||
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
if (!mDocumentURI) {
|
||||
rv = mPrincipal->GetURI(getter_AddRefs(mDocumentURI));
|
||||
@@ -464,9 +465,8 @@ DOMParser::SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult)
|
||||
NS_ENSURE_TRUE(!mAttemptedInit, NS_ERROR_NOT_INITIALIZED);
|
||||
AttemptedInitMarker marker(&mAttemptedInit);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> prin =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> prin = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
|
||||
|
||||
rv = Init(prin, nullptr, nullptr, scriptHandlingObject);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -465,7 +465,12 @@ nsContentUtils::Init()
|
||||
|
||||
sSecurityManager->GetSystemPrincipal(&sSystemPrincipal);
|
||||
MOZ_ASSERT(sSystemPrincipal);
|
||||
NS_ADDREF(sNullSubjectPrincipal = new nsNullPrincipal());
|
||||
|
||||
// We use the constructor here because we want infallible initialization; we
|
||||
// apparently don't care whether sNullSubjectPrincipal has a sane URI or not.
|
||||
nsRefPtr<nsNullPrincipal> nullPrincipal = new nsNullPrincipal();
|
||||
nullPrincipal->Init();
|
||||
nullPrincipal.forget(&sNullSubjectPrincipal);
|
||||
|
||||
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
||||
@@ -108,12 +108,12 @@ nsDOMScriptObjectFactory::Observe(nsISupports *aSubject,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
uint32_t aScriptableFlags,
|
||||
bool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
|
||||
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
+23
-1
@@ -1618,6 +1618,8 @@ nsIDocument::~nsIDocument()
|
||||
if (mNodeInfoManager) {
|
||||
mNodeInfoManager->DropDocumentReference();
|
||||
}
|
||||
|
||||
UnlinkOriginalDocumentIfStatic();
|
||||
}
|
||||
|
||||
|
||||
@@ -2069,13 +2071,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
}
|
||||
tmp->mFirstChild = nullptr;
|
||||
|
||||
tmp->UnlinkOriginalDocumentIfStatic();
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mXPathEvaluator)
|
||||
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentTimeline)
|
||||
@@ -3942,6 +3945,11 @@ nsIDocument::TakeFrameRequestCallbacks(FrameRequestCallbackList& aCallbacks)
|
||||
bool
|
||||
nsIDocument::ShouldThrottleFrameRequests()
|
||||
{
|
||||
if (mStaticCloneCount > 0) {
|
||||
// Even if we're not visible, a static clone may be, so run at full speed.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mIsShowing) {
|
||||
// We're not showing (probably in a background tab or the bf cache).
|
||||
return true;
|
||||
@@ -10248,6 +10256,9 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||
} else {
|
||||
clonedDoc->mOriginalDocument = this;
|
||||
}
|
||||
|
||||
clonedDoc->mOriginalDocument->mStaticCloneCount++;
|
||||
|
||||
int32_t sheetsCount = GetNumberOfStyleSheets();
|
||||
for (int32_t i = 0; i < sheetsCount; ++i) {
|
||||
nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
|
||||
@@ -10285,6 +10296,17 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||
return clonedDoc.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::UnlinkOriginalDocumentIfStatic()
|
||||
{
|
||||
if (IsStaticDocument() && mOriginalDocument) {
|
||||
MOZ_ASSERT(mOriginalDocument->mStaticCloneCount > 0);
|
||||
mOriginalDocument->mStaticCloneCount--;
|
||||
mOriginalDocument = nullptr;
|
||||
}
|
||||
MOZ_ASSERT(!mOriginalDocument);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIDocument::ScheduleFrameRequestCallback(const FrameRequestCallbackHolder& aCallback,
|
||||
int32_t *aHandle)
|
||||
|
||||
@@ -137,11 +137,11 @@ NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource)
|
||||
|
||||
#define NS_MEDIASTREAMPROTOCOLHANDLER_CID \
|
||||
{ 0x27d1fa24, 0x2b73, 0x4db3, \
|
||||
{ 0xab, 0x48, 0xb9, 0x83, 0x83, 0x40, 0xe0, 0x81 } }
|
||||
{ 0xab, 0x48, 0xb9, 0x83, 0x83, 0x40, 0xe0, 0x81 } }
|
||||
|
||||
#define NS_MEDIASOURCEPROTOCOLHANDLER_CID \
|
||||
{ 0x12ef31fc, 0xa8fb, 0x4661, \
|
||||
{ 0x9a, 0x63, 0xfb, 0x61, 0x04,0x5d, 0xb8, 0x61 } }
|
||||
{ 0x9a, 0x63, 0xfb, 0x61, 0x04,0x5d, 0xb8, 0x61 } }
|
||||
|
||||
#define NS_FONTTABLEPROTOCOLHANDLER_CID \
|
||||
{ 0x3fc8f04e, 0xd719, 0x43ca, \
|
||||
|
||||
@@ -1990,6 +1990,12 @@ public:
|
||||
return mOriginalDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this document is a static clone, let the original document know that
|
||||
* we're going away and then release our reference to it.
|
||||
*/
|
||||
void UnlinkOriginalDocumentIfStatic();
|
||||
|
||||
/**
|
||||
* These are called by the parser as it encounters <picture> tags, the end of
|
||||
* said tags, and possible picture <source srcset> sources respectively. These
|
||||
@@ -2933,6 +2939,9 @@ protected:
|
||||
*/
|
||||
int32_t mFrameRequestCallbackCounter;
|
||||
|
||||
// Count of live static clones of this document.
|
||||
uint32_t mStaticCloneCount;
|
||||
|
||||
// Array of nodes that have been blocked to prevent user tracking.
|
||||
// They most likely have had their nsIChannel canceled by the URL
|
||||
// classifier. (Safebrowsing)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsDocument.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::dom::NodeInfo;
|
||||
@@ -182,9 +183,9 @@ nsNodeInfoManager::Init(nsIDocument *aDocument)
|
||||
|
||||
NS_PRECONDITION(!mPrincipal,
|
||||
"Being inited when we already have a principal?");
|
||||
nsresult rv;
|
||||
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_TRUE(mPrincipal, rv);
|
||||
|
||||
mPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
if (aDocument) {
|
||||
mBindingManager = new nsBindingManager(aDocument);
|
||||
|
||||
@@ -339,21 +339,11 @@ ErrorResult::ReportNotEnoughArgsError(JSContext* cx,
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::SuppressException()
|
||||
ErrorResult::ReportGenericError(JSContext* cx)
|
||||
{
|
||||
WouldReportJSException();
|
||||
if (IsErrorWithMessage()) {
|
||||
ClearMessage();
|
||||
} else if (IsJSException()) {
|
||||
JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
|
||||
// Just steal it into a stack value (unrooting it in the process)
|
||||
// that we then allow to die.
|
||||
JS::Rooted<JS::Value> temp(cx);
|
||||
StealJSException(cx, &temp);
|
||||
}
|
||||
// We don't use AssignErrorCode, because we want to override existing error
|
||||
// states, which AssignErrorCode is not allowed to do.
|
||||
mResult = NS_OK;
|
||||
MOZ_ASSERT(!IsErrorWithMessage());
|
||||
MOZ_ASSERT(!IsJSException());
|
||||
dom::Throw(cx, ErrorCode());
|
||||
}
|
||||
|
||||
ErrorResult&
|
||||
@@ -394,6 +384,24 @@ ErrorResult::operator=(ErrorResult&& aRHS)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::SuppressException()
|
||||
{
|
||||
WouldReportJSException();
|
||||
if (IsErrorWithMessage()) {
|
||||
ClearMessage();
|
||||
} else if (IsJSException()) {
|
||||
JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
|
||||
// Just steal it into a stack value (unrooting it in the process)
|
||||
// that we then allow to die.
|
||||
JS::Rooted<JS::Value> temp(cx);
|
||||
StealJSException(cx, &temp);
|
||||
}
|
||||
// We don't use AssignErrorCode, because we want to override existing error
|
||||
// states, which AssignErrorCode is not allowed to do.
|
||||
mResult = NS_OK;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
bool
|
||||
|
||||
@@ -127,7 +127,8 @@ ThrowMethodFailedWithDetails(JSContext* cx, ErrorResult& rv,
|
||||
rv.ReportNotEnoughArgsError(cx, ifaceName, memberName);
|
||||
return false;
|
||||
}
|
||||
return Throw(cx, rv.ErrorCode());
|
||||
rv.ReportGenericError(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if the JSClass is used for DOM objects.
|
||||
|
||||
@@ -119,6 +119,10 @@ public:
|
||||
const char* memberName);
|
||||
bool IsNotEnoughArgsError() const { return ErrorCode() == NS_ERROR_XPC_NOT_ENOUGH_ARGS; }
|
||||
|
||||
// Report a generic error. This should only be used if we're not
|
||||
// some more specific exception type.
|
||||
void ReportGenericError(JSContext* cx);
|
||||
|
||||
// Support for uncatchable exceptions.
|
||||
void ThrowUncatchableException() {
|
||||
Throw(NS_ERROR_UNCATCHABLE_EXCEPTION);
|
||||
@@ -160,14 +164,20 @@ public:
|
||||
return NS_FAILED(mResult);
|
||||
}
|
||||
|
||||
nsresult ErrorCode() const {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
bool ErrorCodeIs(nsresult rv) const {
|
||||
return mResult == rv;
|
||||
}
|
||||
|
||||
// For use in logging ONLY.
|
||||
uint32_t ErrorCodeAsInt() const {
|
||||
return static_cast<uint32_t>(ErrorCode());
|
||||
}
|
||||
|
||||
protected:
|
||||
nsresult ErrorCode() const {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private:
|
||||
friend struct IPC::ParamTraits<ErrorResult>;
|
||||
void SerializeMessage(IPC::Message* aMsg) const;
|
||||
@@ -225,7 +235,7 @@ private:
|
||||
if (res.Failed()) { \
|
||||
nsCString msg; \
|
||||
msg.AppendPrintf("ENSURE_SUCCESS(%s, %s) failed with " \
|
||||
"result 0x%X", #res, #ret, res.ErrorCode()); \
|
||||
"result 0x%X", #res, #ret, res.ErrorCodeAsInt()); \
|
||||
NS_WARNING(msg.get()); \
|
||||
return ret; \
|
||||
} \
|
||||
@@ -236,7 +246,7 @@ private:
|
||||
if (res.Failed()) { \
|
||||
nsCString msg; \
|
||||
msg.AppendPrintf("ENSURE_SUCCESS_VOID(%s) failed with " \
|
||||
"result 0x%X", #res, res.ErrorCode()); \
|
||||
"result 0x%X", #res, res.ErrorCodeAsInt()); \
|
||||
NS_WARNING(msg.get()); \
|
||||
return; \
|
||||
} \
|
||||
|
||||
Vendored
+1
-1
@@ -33,7 +33,7 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut)
|
||||
// TODO: consider using QuotaManager's modified origin here (bug 1112071)
|
||||
|
||||
nsAutoCString origin;
|
||||
nsresult rv = aPrincipal->GetOrigin(getter_Copies(origin));
|
||||
nsresult rv = aPrincipal->GetOrigin(origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
uint32_t appId;
|
||||
|
||||
Vendored
+1
-1
@@ -150,7 +150,7 @@ PrincipalVerifier::VerifyOnMainThread()
|
||||
// is a synthetic [System Principal] string.
|
||||
if (!ssm->IsSystemPrincipal(principal)) {
|
||||
nsAutoCString origin;
|
||||
rv = principal->GetOrigin(getter_Copies(origin));
|
||||
rv = principal->GetOrigin(origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
DispatchToInitiatingThread(rv);
|
||||
return;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
#define DATASTOREDB_VERSION 1
|
||||
#define DATASTOREDB_NAME "DataStoreDB"
|
||||
@@ -103,10 +104,9 @@ DataStoreDB::CreateFactoryIfNeeded()
|
||||
{
|
||||
if (!mFactory) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::Create();
|
||||
if (!principal) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
|
||||
@@ -960,7 +960,7 @@ EventListenerManager::HandleEventSubType(Listener* aListener,
|
||||
ErrorResult rv;
|
||||
listenerHolder.GetWebIDLCallback()->
|
||||
HandleEvent(aCurrentTarget, *(aDOMEvent->InternalDOMEvent()), rv);
|
||||
result = rv.ErrorCode();
|
||||
result = rv.StealNSResult();
|
||||
} else {
|
||||
result = listenerHolder.GetXPCOMCallback()->HandleEvent(aDOMEvent);
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ HTMLCanvasElement::CopyInnerTo(Element* aDest)
|
||||
ErrorResult err;
|
||||
context2d->DrawImage(element,
|
||||
0.0, 0.0, err);
|
||||
rv = err.ErrorCode();
|
||||
rv = err.StealNSResult();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -176,7 +176,7 @@ HTMLOptionsCollection::SetOption(uint32_t aIndex,
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aOption);
|
||||
ErrorResult res;
|
||||
parent->ReplaceChild(*node, *refChild, res);
|
||||
rv = res.ErrorCode();
|
||||
rv = res.StealNSResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "mozilla/a11y/DocAccessibleChild.h"
|
||||
#endif
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ProcessHangMonitorIPC.h"
|
||||
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
||||
@@ -51,6 +52,7 @@
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/plugins/PluginInstanceParent.h"
|
||||
#include "mozilla/plugins/PluginModuleParent.h"
|
||||
#include "mozilla/widget/WidgetMessageUtils.h"
|
||||
|
||||
#if defined(MOZ_CONTENT_SANDBOX)
|
||||
#if defined(XP_WIN)
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
#include "mozilla/plugins/PluginBridge.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@@ -2792,6 +2793,7 @@ ContentParent::RecvAddNewProcess(const uint32_t& aPid,
|
||||
InfallibleTArray<nsString> unusedDictionaries;
|
||||
ClipboardCapabilities clipboardCaps;
|
||||
DomainPolicyClone domainPolicy;
|
||||
|
||||
RecvGetXPCOMProcessAttributes(&isOffline, &isLangRTL, &unusedDictionaries,
|
||||
&clipboardCaps, &domainPolicy);
|
||||
mozilla::unused << content->SendSetOffline(isOffline);
|
||||
@@ -3856,6 +3858,13 @@ ContentParent::RecvGetSystemMemory(const uint64_t& aGetterId)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
|
||||
{
|
||||
aLookAndFeelIntCache = LookAndFeel::GetIntCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvIsSecureURI(const uint32_t& type,
|
||||
const URIParams& uri,
|
||||
@@ -4029,7 +4038,7 @@ ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal,
|
||||
if (!principal) {
|
||||
return true;
|
||||
}
|
||||
principal->GetOrigin(getter_Copies(origin));
|
||||
principal->GetOrigin(origin);
|
||||
nsRefPtr<nsGeolocationSettings> gs = nsGeolocationSettings::GetGeolocationSettings();
|
||||
if (gs) {
|
||||
gs->PutWatchOrigin(mGeolocationWatchID, origin);
|
||||
|
||||
@@ -537,8 +537,7 @@ private:
|
||||
bool* aIsLangRTL,
|
||||
InfallibleTArray<nsString>* dictionaries,
|
||||
ClipboardCapabilities* clipboardCaps,
|
||||
DomainPolicyClone* domainPolicy)
|
||||
override;
|
||||
DomainPolicyClone* domainPolicy) override;
|
||||
|
||||
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
|
||||
|
||||
@@ -744,6 +743,8 @@ private:
|
||||
const bool& aHidden) override;
|
||||
virtual bool RecvGetSystemMemory(const uint64_t& getterId) override;
|
||||
|
||||
virtual bool RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;
|
||||
|
||||
virtual bool RecvDataStoreGetStores(
|
||||
const nsString& aName,
|
||||
const nsString& aOwner,
|
||||
|
||||
@@ -86,6 +86,7 @@ using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
|
||||
using gfxIntSize from "nsSize.h";
|
||||
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
|
||||
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
@@ -722,6 +723,8 @@ parent:
|
||||
sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags)
|
||||
returns (bool isSecureURI);
|
||||
|
||||
sync GetLookAndFeelCache(LookAndFeelInt[] lookAndFeelIntCache);
|
||||
|
||||
PHal();
|
||||
|
||||
PIcc(uint32_t serviceId);
|
||||
|
||||
+2
-3
@@ -411,9 +411,8 @@ nsJSON::DecodeInternal(JSContext* cx,
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
rv = NS_NewInputStreamChannel(getter_AddRefs(jsonChannel),
|
||||
mURI,
|
||||
|
||||
@@ -427,9 +427,8 @@ nsresult nsJSChannel::Init(nsIURI *aURI)
|
||||
// and the underlying Input Stream will not be created...
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
// If the resultant script evaluation actually does return a value, we
|
||||
// treat it as html.
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "VideoUtils.h"
|
||||
#include "Latency.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
// For PR_snprintf
|
||||
#include "prprf.h"
|
||||
@@ -76,6 +77,8 @@
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
|
||||
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
|
||||
// GetTickCount() and conflicts with MediaStream::GetCurrentTime.
|
||||
#ifdef GetCurrentTime
|
||||
@@ -525,22 +528,31 @@ uint32_t
|
||||
VideoDevice::GetBestFitnessDistance(
|
||||
const nsTArray<const MediaTrackConstraintSet*>& aConstraintSets)
|
||||
{
|
||||
// TODO: Minimal kludge to fix plain and ideal facingMode regression, for
|
||||
// smooth landing and uplift. Proper cleanup is forthcoming (1037389).
|
||||
uint64_t distance = 0;
|
||||
|
||||
// Interrogate device-inherent properties first.
|
||||
for (size_t i = 0; i < aConstraintSets.Length(); i++) {
|
||||
auto& c = *aConstraintSets[i];
|
||||
if (!c.mFacingMode.IsConstrainDOMStringParameters() ||
|
||||
c.mFacingMode.GetAsConstrainDOMStringParameters().mIdeal.WasPassed() ||
|
||||
c.mFacingMode.GetAsConstrainDOMStringParameters().mExact.WasPassed()) {
|
||||
nsString deviceFacingMode;
|
||||
GetFacingMode(deviceFacingMode);
|
||||
if (c.mFacingMode.IsString()) {
|
||||
if (c.mFacingMode.GetAsString() != deviceFacingMode) {
|
||||
return UINT32_MAX;
|
||||
if (i == 0) {
|
||||
distance = 1000;
|
||||
}
|
||||
}
|
||||
} else if (c.mFacingMode.IsStringSequence()) {
|
||||
if (!c.mFacingMode.GetAsStringSequence().Contains(deviceFacingMode)) {
|
||||
return UINT32_MAX;
|
||||
if (i == 0) {
|
||||
distance = 1000;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (c.mFacingMode.GetAsConstrainDOMStringParameters().mExact.WasPassed()) {
|
||||
auto& exact = c.mFacingMode.GetAsConstrainDOMStringParameters().mExact.Value();
|
||||
if (exact.IsString()) {
|
||||
if (exact.GetAsString() != deviceFacingMode) {
|
||||
@@ -549,6 +561,19 @@ VideoDevice::GetBestFitnessDistance(
|
||||
} else if (!exact.GetAsStringSequence().Contains(deviceFacingMode)) {
|
||||
return UINT32_MAX;
|
||||
}
|
||||
} else if (c.mFacingMode.GetAsConstrainDOMStringParameters().mIdeal.WasPassed()) {
|
||||
auto& ideal = c.mFacingMode.GetAsConstrainDOMStringParameters().mIdeal.Value();
|
||||
if (ideal.IsString()) {
|
||||
if (ideal.GetAsString() != deviceFacingMode) {
|
||||
if (i == 0) {
|
||||
distance = 1000;
|
||||
}
|
||||
}
|
||||
} else if (!ideal.GetAsStringSequence().Contains(deviceFacingMode)) {
|
||||
if (i == 0) {
|
||||
distance = 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsString s;
|
||||
@@ -558,7 +583,8 @@ VideoDevice::GetBestFitnessDistance(
|
||||
}
|
||||
}
|
||||
// Forward request to underlying object to interrogate per-mode capabilities.
|
||||
return GetSource()->GetBestFitnessDistance(aConstraintSets);
|
||||
distance += uint64_t(GetSource()->GetBestFitnessDistance(aConstraintSets));
|
||||
return uint32_t(std::min(distance, uint64_t(UINT32_MAX)));
|
||||
}
|
||||
|
||||
AudioDevice::AudioDevice(MediaEngineAudioSource* aSource)
|
||||
@@ -1003,7 +1029,7 @@ public:
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
if (mPeerIdentity) {
|
||||
principal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
principal = nsNullPrincipal::Create();
|
||||
trackunion->SetPeerIdentity(mPeerIdentity.forget());
|
||||
} else {
|
||||
principal = window->GetExtantDoc()->NodePrincipal();
|
||||
@@ -1117,13 +1143,23 @@ static void
|
||||
nsTArray<const MediaTrackConstraintSet*> aggregateConstraints;
|
||||
aggregateConstraints.AppendElement(&c);
|
||||
|
||||
std::multimap<uint32_t, nsRefPtr<DeviceType>> ordered;
|
||||
|
||||
for (uint32_t i = 0; i < candidateSet.Length();) {
|
||||
if (candidateSet[i]->GetBestFitnessDistance(aggregateConstraints) == UINT32_MAX) {
|
||||
uint32_t distance = candidateSet[i]->GetBestFitnessDistance(aggregateConstraints);
|
||||
if (distance == UINT32_MAX) {
|
||||
candidateSet.RemoveElementAt(i);
|
||||
} else {
|
||||
ordered.insert(std::pair<uint32_t, nsRefPtr<DeviceType>>(distance,
|
||||
candidateSet[i]));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
// Order devices by shortest distance
|
||||
for (auto& ordinal : ordered) {
|
||||
candidateSet.RemoveElement(ordinal.second);
|
||||
candidateSet.AppendElement(ordinal.second);
|
||||
}
|
||||
|
||||
// Then apply advanced constraints.
|
||||
|
||||
@@ -1313,6 +1349,11 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(mOnSuccess);
|
||||
MOZ_ASSERT(mOnFailure);
|
||||
|
||||
if (!IsOn(mConstraints.mVideo) && !IsOn(mConstraints.mAudio)) {
|
||||
Fail(NS_LITERAL_STRING("NotSupportedError"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (IsOn(mConstraints.mVideo)) {
|
||||
nsTArray<nsRefPtr<VideoDevice>> sources;
|
||||
GetSources(backend, GetInvariant(mConstraints.mVideo),
|
||||
@@ -1338,6 +1379,11 @@ public:
|
||||
LOG(("Selected audio device"));
|
||||
}
|
||||
|
||||
if (!mAudioDevice && !mVideoDevice) {
|
||||
Fail(NS_LITERAL_STRING("NotFoundError"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1988,8 +2034,7 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
Preferences::GetBool("media.navigator.streams.fake", false);
|
||||
|
||||
nsCString origin;
|
||||
nsPrincipal::GetOriginForURI(aWindow->GetDocumentURI(),
|
||||
getter_Copies(origin));
|
||||
nsPrincipal::GetOriginForURI(aWindow->GetDocumentURI(), origin);
|
||||
bool inPrivateBrowsing;
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
|
||||
@@ -2244,7 +2289,7 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
// cleared until the lambda function clears it.
|
||||
|
||||
MediaManager::GetMessageLoop()->PostTask(FROM_HERE, new ShutdownTask(
|
||||
media::CallbackRunnable::New([this]() mutable {
|
||||
media::NewRunnableFrom([this]() mutable {
|
||||
// Close off any remaining active windows.
|
||||
MutexAutoLock lock(mMutex);
|
||||
GetActiveWindows()->Clear();
|
||||
|
||||
@@ -27,6 +27,9 @@ BaseMediaMgrError::BaseMediaMgrError(const nsAString& aName,
|
||||
"accessed due to a hardware error (e.g. lock from another process).");
|
||||
} else if (mName.EqualsLiteral("InternalError")) {
|
||||
mMessage.AssignLiteral("Internal error.");
|
||||
} else if (mName.EqualsLiteral("NotSupportedError")) {
|
||||
mMessage.AssignLiteral("Constraints with no audio or video in it are not "
|
||||
"supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,13 +167,11 @@ protected:
|
||||
|
||||
// General purpose runnable with an eye toward lambdas
|
||||
|
||||
namespace CallbackRunnable
|
||||
{
|
||||
template<typename OnRunType>
|
||||
class Impl : public nsRunnable
|
||||
class LambdaRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
explicit Impl(OnRunType& aOnRun) : mOnRun(aOnRun) {}
|
||||
explicit LambdaRunnable(OnRunType& aOnRun) : mOnRun(aOnRun) {}
|
||||
private:
|
||||
NS_IMETHODIMP
|
||||
Run()
|
||||
@@ -184,11 +182,10 @@ private:
|
||||
};
|
||||
|
||||
template<typename OnRunType>
|
||||
Impl<OnRunType>*
|
||||
New(OnRunType aOnRun)
|
||||
LambdaRunnable<OnRunType>*
|
||||
NewRunnableFrom(OnRunType aOnRun)
|
||||
{
|
||||
return new Impl<OnRunType>(aOnRun);
|
||||
}
|
||||
return new LambdaRunnable<OnRunType>(aOnRun);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabl
|
||||
skip-if = toolkit == 'gonk' # b2g emulator seems to be too slow (Bug 1016498 and 1008080)
|
||||
[test_dataChannel_noOffer.html]
|
||||
skip-if = toolkit == 'gonk' # b2g (Bug 1059867)
|
||||
[test_enumerateDevices.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_getUserMedia_basicAudio.html]
|
||||
skip-if = (toolkit == 'gonk' && debug) # debug-only failure
|
||||
[test_getUserMedia_basicVideo.html]
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script src="mediaStreamPlayback.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({ title: "Run enumerateDevices code", bug: "1046245" });
|
||||
/**
|
||||
Tests covering enumerateDevices API. Exercise code.
|
||||
*/
|
||||
|
||||
runTest(() => navigator.mediaDevices.enumerateDevices()
|
||||
.then(devices => {
|
||||
ok(devices.length > 0, "At least one device found");
|
||||
devices.forEach(d => {
|
||||
ok(d.kind == "videoinput" || d.kind == "audioinput", "Known device kind");
|
||||
is(d.deviceId.length, 44, "Correct device id length");
|
||||
ok(d.label.length !== undefined, "Device label: " + d.label);
|
||||
is(d.groupId, "", "Don't support groupId yet");
|
||||
});
|
||||
}));
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -50,6 +50,9 @@ var tests = [
|
||||
{ message: "unknown mediaSource fails",
|
||||
constraints: { video: { mediaSource: 'uncle' } },
|
||||
error: "NotFoundError" },
|
||||
{ message: "emtpy constraint fails",
|
||||
constraints: { },
|
||||
error: "NotSupportedError" },
|
||||
{ message: "Success-path: optional video facingMode + audio ignoring facingMode",
|
||||
constraints: { fake: true,
|
||||
audio: { mediaSource: 'microphone',
|
||||
|
||||
@@ -79,28 +79,27 @@ MediaEngineCameraVideoSource::FitnessDistance(ValueType n,
|
||||
|
||||
// Binding code doesn't templatize well...
|
||||
|
||||
template<>
|
||||
/* static */ uint32_t
|
||||
/*static*/ uint32_t
|
||||
MediaEngineCameraVideoSource::FitnessDistance(int32_t n,
|
||||
const OwningLongOrConstrainLongRange& aConstraint)
|
||||
const OwningLongOrConstrainLongRange& aConstraint, bool aAdvanced)
|
||||
{
|
||||
if (aConstraint.IsLong()) {
|
||||
ConstrainLongRange range;
|
||||
range.mIdeal.Construct(aConstraint.GetAsLong());
|
||||
(aAdvanced ? range.mExact : range.mIdeal).Construct(aConstraint.GetAsLong());
|
||||
return FitnessDistance(n, range);
|
||||
} else {
|
||||
return FitnessDistance(n, aConstraint.GetAsConstrainLongRange());
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
/* static */ uint32_t
|
||||
/*static*/ uint32_t
|
||||
MediaEngineCameraVideoSource::FitnessDistance(double n,
|
||||
const OwningDoubleOrConstrainDoubleRange& aConstraint)
|
||||
const OwningDoubleOrConstrainDoubleRange& aConstraint,
|
||||
bool aAdvanced)
|
||||
{
|
||||
if (aConstraint.IsDouble()) {
|
||||
ConstrainDoubleRange range;
|
||||
range.mIdeal.Construct(aConstraint.GetAsDouble());
|
||||
(aAdvanced ? range.mExact : range.mIdeal).Construct(aConstraint.GetAsDouble());
|
||||
return FitnessDistance(n, range);
|
||||
} else {
|
||||
return FitnessDistance(n, aConstraint.GetAsConstrainDoubleRange());
|
||||
@@ -109,18 +108,22 @@ MediaEngineCameraVideoSource::FitnessDistance(double n,
|
||||
|
||||
/*static*/ uint32_t
|
||||
MediaEngineCameraVideoSource::GetFitnessDistance(const webrtc::CaptureCapability& aCandidate,
|
||||
const MediaTrackConstraintSet &aConstraints)
|
||||
const MediaTrackConstraintSet &aConstraints,
|
||||
bool aAdvanced)
|
||||
{
|
||||
// Treat width|height|frameRate == 0 on capability as "can do any".
|
||||
// This allows for orthogonal capabilities that are not in discrete steps.
|
||||
|
||||
uint64_t distance =
|
||||
uint64_t(aCandidate.width? FitnessDistance(int32_t(aCandidate.width),
|
||||
aConstraints.mWidth) : 0) +
|
||||
aConstraints.mWidth,
|
||||
aAdvanced) : 0) +
|
||||
uint64_t(aCandidate.height? FitnessDistance(int32_t(aCandidate.height),
|
||||
aConstraints.mHeight) : 0) +
|
||||
aConstraints.mHeight,
|
||||
aAdvanced) : 0) +
|
||||
uint64_t(aCandidate.maxFPS? FitnessDistance(double(aCandidate.maxFPS),
|
||||
aConstraints.mFrameRate) : 0);
|
||||
aConstraints.mFrameRate,
|
||||
aAdvanced) : 0);
|
||||
return uint32_t(std::min(distance, uint64_t(UINT32_MAX)));
|
||||
}
|
||||
|
||||
@@ -147,6 +150,8 @@ MediaEngineCameraVideoSource::TrimLessFitCandidates(CapabilitySet& set) {
|
||||
// GetBestFitnessDistance returns the best distance the capture device can offer
|
||||
// as a whole, given an accumulated number of ConstraintSets.
|
||||
// Ideal values are considered in the first ConstraintSet only.
|
||||
// Plain values are treated as Ideal in the first ConstraintSet.
|
||||
// Plain values are treated as Exact in subsequent ConstraintSets.
|
||||
// Infinity = UINT32_MAX e.g. device cannot satisfy accumulated ConstraintSets.
|
||||
// A finite result may be used to calculate this device's ranking as a choice.
|
||||
|
||||
@@ -167,7 +172,7 @@ MediaEngineCameraVideoSource::GetBestFitnessDistance(
|
||||
auto& candidate = candidateSet[i];
|
||||
webrtc::CaptureCapability cap;
|
||||
GetCapability(candidate.mIndex, cap);
|
||||
uint32_t distance = GetFitnessDistance(cap, *cs);
|
||||
uint32_t distance = GetFitnessDistance(cap, *cs, !first);
|
||||
if (distance == UINT32_MAX) {
|
||||
candidateSet.RemoveElementAt(i);
|
||||
} else {
|
||||
@@ -239,7 +244,7 @@ MediaEngineCameraVideoSource::ChooseCapability(
|
||||
auto& candidate = candidateSet[i];
|
||||
webrtc::CaptureCapability cap;
|
||||
GetCapability(candidate.mIndex, cap);
|
||||
candidate.mDistance = GetFitnessDistance(cap, aConstraints);
|
||||
candidate.mDistance = GetFitnessDistance(cap, aConstraints, false);
|
||||
if (candidate.mDistance == UINT32_MAX) {
|
||||
candidateSet.RemoveElementAt(i);
|
||||
} else {
|
||||
@@ -256,7 +261,7 @@ MediaEngineCameraVideoSource::ChooseCapability(
|
||||
auto& candidate = candidateSet[i];
|
||||
webrtc::CaptureCapability cap;
|
||||
GetCapability(candidate.mIndex, cap);
|
||||
if (GetFitnessDistance(cap, cs) == UINT32_MAX) {
|
||||
if (GetFitnessDistance(cap, cs, true) == UINT32_MAX) {
|
||||
rejects.AppendElement(candidate);
|
||||
candidateSet.RemoveElementAt(i);
|
||||
} else {
|
||||
@@ -288,7 +293,7 @@ MediaEngineCameraVideoSource::ChooseCapability(
|
||||
for (auto& candidate : candidateSet) {
|
||||
webrtc::CaptureCapability cap;
|
||||
GetCapability(candidate.mIndex, cap);
|
||||
candidate.mDistance = GetFitnessDistance(cap, prefs);
|
||||
candidate.mDistance = GetFitnessDistance(cap, prefs, false);
|
||||
}
|
||||
TrimLessFitCandidates(candidateSet);
|
||||
}
|
||||
|
||||
@@ -80,8 +80,14 @@ protected:
|
||||
StreamTime delta);
|
||||
template<class ValueType, class ConstrainRange>
|
||||
static uint32_t FitnessDistance(ValueType n, const ConstrainRange& aRange);
|
||||
static uint32_t FitnessDistance(int32_t n,
|
||||
const dom::OwningLongOrConstrainLongRange& aConstraint, bool aAdvanced);
|
||||
static uint32_t FitnessDistance(double n,
|
||||
const dom::OwningDoubleOrConstrainDoubleRange& aConstraint, bool aAdvanced);
|
||||
|
||||
static uint32_t GetFitnessDistance(const webrtc::CaptureCapability& aCandidate,
|
||||
const dom::MediaTrackConstraintSet &aConstraints);
|
||||
const dom::MediaTrackConstraintSet &aConstraints,
|
||||
bool aAdvanced);
|
||||
static void TrimLessFitCandidates(CapabilitySet& set);
|
||||
static void LogConstraints(const dom::MediaTrackConstraintSet& aConstraints,
|
||||
bool aAdvanced);
|
||||
|
||||
@@ -346,9 +346,9 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
|
||||
{
|
||||
nsTArray<nsString> emptyOptions;
|
||||
return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
|
||||
NS_LITERAL_CSTRING("unused"),
|
||||
emptyOptions,
|
||||
aTypes);
|
||||
NS_LITERAL_CSTRING("unused"),
|
||||
emptyOptions,
|
||||
aTypes);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NotificationTask, nsIRunnable)
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsVersionComparator.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "nsIWindowMediator.h"
|
||||
@@ -3112,8 +3113,8 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
|
||||
// in this else branch we really don't know where the load is coming
|
||||
// from and in fact should use something better than just using
|
||||
// a nullPrincipal as the loadingPrincipal.
|
||||
principal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
principal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
url,
|
||||
principal,
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsPluginInstanceOwner.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
#define MAGIC_REQUEST_CONTEXT 0x01020304
|
||||
|
||||
@@ -700,9 +701,8 @@ nsPluginStreamListenerPeer::RequestRead(NPByteRange* rangeList)
|
||||
// in this else branch we really don't know where the load is coming
|
||||
// from and in fact should use something better than just using
|
||||
// a nullPrincipal as the loadingPrincipal.
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
mURL,
|
||||
principal,
|
||||
|
||||
@@ -2527,7 +2527,7 @@ QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
|
||||
}
|
||||
|
||||
nsCString origin;
|
||||
rv = aPrincipal->GetOrigin(getter_Copies(origin));
|
||||
rv = aPrincipal->GetOrigin(origin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (origin.EqualsLiteral(kChromeOrigin)) {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "nsIDOMWindowUtils.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsINetworkInterceptController.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
@@ -751,7 +752,7 @@ nsCORSListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!equal) {
|
||||
// Spec says to set our source origin to a unique origin.
|
||||
mOriginHeaderPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
mOriginHeaderPrincipal = nsNullPrincipal::Create();
|
||||
if (!mOriginHeaderPrincipal) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@@ -797,9 +797,8 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
|
||||
nsIContentPolicy::TYPE_CSP_REPORT);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
rv = NS_NewChannel(getter_AddRefs(reportChannel),
|
||||
reportURI,
|
||||
nullPrincipal,
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
void GetSupportedNames(unsigned, nsTArray<nsString>& aKeys);
|
||||
|
||||
void NamedGetter(const nsAString& aKey, bool& aFound, nsAString& aResult,
|
||||
ErrorResult& aRv)
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
GetItem(aKey, aResult, aRv);
|
||||
aFound = !aResult.IsVoid();
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
{
|
||||
RemoveItem(aKey, aRv);
|
||||
|
||||
aFound = (aRv.ErrorCode() != NS_SUCCESS_DOM_NO_OPERATION);
|
||||
aFound = !aRv.ErrorCodeIs(NS_SUCCESS_DOM_NO_OPERATION);
|
||||
}
|
||||
|
||||
void Clear(ErrorResult& aRv);
|
||||
|
||||
@@ -30,10 +30,9 @@ interface Animation {
|
||||
readonly attribute Promise<Animation> ready;
|
||||
[Throws]
|
||||
readonly attribute Promise<Animation> finished;
|
||||
/*
|
||||
void cancel ();
|
||||
[Throws]
|
||||
void finish ();
|
||||
*/
|
||||
[BinaryName="playFromJS"]
|
||||
void play ();
|
||||
[BinaryName="pauseFromJS"]
|
||||
|
||||
@@ -143,7 +143,7 @@ convertToBytes(char* buf, uint32_t maxlen, const char* str)
|
||||
break;
|
||||
default:
|
||||
buf[len++] = *pos++;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
|
||||
@@ -815,8 +815,9 @@ private:
|
||||
nsRefPtr<Promise> cachePromise =
|
||||
mCacheCreator->Cache_()->Put(request, *response, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
channel->Cancel(error.ErrorCode());
|
||||
return error.StealNSResult();
|
||||
nsresult rv = error.StealNSResult();
|
||||
channel->Cancel(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRefPtr<CachePromiseHandler> promiseHandler =
|
||||
@@ -1317,7 +1318,7 @@ CacheScriptLoader::Load(Cache* aCache)
|
||||
ErrorResult error;
|
||||
nsRefPtr<Promise> promise = aCache->Match(request, params, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
Fail(error.ErrorCode());
|
||||
Fail(error.StealNSResult());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ CompareCache::ManageCacheResult(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
||||
CacheQueryOptions params;
|
||||
nsRefPtr<Promise> promise = cache->Match(request, params, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
mManager->CacheFinished(error.ErrorCode(), false);
|
||||
mManager->CacheFinished(error.StealNSResult(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ ServiceWorkerWindowClient::Focus(ErrorResult& aRv) const
|
||||
promiseProxy);
|
||||
aRv = NS_DispatchToMainThread(r);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
promise->MaybeReject(aRv.ErrorCode());
|
||||
promise->MaybeReject(aRv);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
|
||||
@@ -87,7 +87,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsRefPtr<nsXMLContentSink> it = new nsXMLContentSink();
|
||||
|
||||
|
||||
nsresult rv = it->Init(aDoc, aURI, aContainer, aChannel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -123,7 +123,7 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
|
||||
if (!mDocShell) {
|
||||
mPrettyPrintXML = false;
|
||||
}
|
||||
|
||||
|
||||
mState = eXMLContentSinkState_InProlog;
|
||||
mDocElement = nullptr;
|
||||
|
||||
@@ -175,7 +175,7 @@ nsXMLContentSink::WillBuildModel(nsDTDMode aDTDMode)
|
||||
mPrettyPrintXML = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ nsXMLContentSink::MaybePrettyPrint()
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
nsRefPtr<nsXMLPrettyPrinter> printer;
|
||||
nsresult rv = NS_NewXMLPrettyPrinter(getter_AddRefs(printer));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -304,10 +304,10 @@ nsXMLContentSink::DidBuildModel(bool aTerminated)
|
||||
MaybePrettyPrint();
|
||||
|
||||
bool startLayout = true;
|
||||
|
||||
|
||||
if (mPrettyPrinting) {
|
||||
NS_ASSERTION(!mPendingSheetCount, "Shouldn't have pending sheets here!");
|
||||
|
||||
|
||||
// We're pretty-printing now. See whether we should wait up on
|
||||
// stylesheet loads
|
||||
if (mDocument->CSSLoader()->HasPendingLoads() &&
|
||||
@@ -316,7 +316,7 @@ nsXMLContentSink::DidBuildModel(bool aTerminated)
|
||||
startLayout = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (startLayout) {
|
||||
StartLayout(false);
|
||||
|
||||
@@ -391,7 +391,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
|
||||
}
|
||||
|
||||
// Notify document observers that all the content has been stuck
|
||||
// into the document.
|
||||
// into the document.
|
||||
// XXX do we need to notify for things like PIs? Or just the
|
||||
// documentElement?
|
||||
nsIContent *rootElement = mDocument->GetRootElement();
|
||||
@@ -511,7 +511,7 @@ nsXMLContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
||||
ssle->SetLineNumber(aFromParser ? aLineNumber : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content.forget(aResult);
|
||||
|
||||
@@ -539,7 +539,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
) {
|
||||
aContent->DoneAddingChildren(HaveNotifiedForCurrentContent());
|
||||
}
|
||||
|
||||
|
||||
if (IsMonolithicContainer(nodeInfo)) {
|
||||
mInMonolithicContainer--;
|
||||
}
|
||||
@@ -552,7 +552,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
if (nodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_XHTML)
|
||||
|| nodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_SVG)
|
||||
) {
|
||||
mConstrainSize = true;
|
||||
mConstrainSize = true;
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
|
||||
|
||||
if (mPreventScriptExecution) {
|
||||
@@ -577,7 +577,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
|
||||
return block ? NS_ERROR_HTMLPARSER_BLOCK : NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (nodeInfo->Equals(nsGkAtoms::meta, kNameSpaceID_XHTML) &&
|
||||
// Need to check here to make sure this meta tag does not set
|
||||
@@ -629,7 +629,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::AddContentAsLeaf(nsIContent *aContent)
|
||||
@@ -745,17 +745,17 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
|
||||
// nsContentSink::ProcessStyleLink handles the bookkeeping here wrt
|
||||
// pending sheets.
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::SetDocumentCharset(nsACString& aCharset)
|
||||
{
|
||||
if (mDocument) {
|
||||
mDocument->SetDocumentCharacterSet(aCharset);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -802,7 +802,7 @@ nsXMLContentSink::FlushText(bool aReleaseTextNode)
|
||||
nsRefPtr<nsTextNode> textContent = new nsTextNode(mNodeInfoManager);
|
||||
|
||||
mLastTextNode = textContent;
|
||||
|
||||
|
||||
// Set the text in the text node
|
||||
textContent->SetText(mText, mTextLength, false);
|
||||
mLastTextNodeSize += mTextLength;
|
||||
@@ -817,7 +817,7 @@ nsXMLContentSink::FlushText(bool aReleaseTextNode)
|
||||
mLastTextNodeSize = 0;
|
||||
mLastTextNode = nullptr;
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ nsXMLContentSink::SetDocElement(int32_t aNameSpaceID,
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mDocElement = aContent;
|
||||
@@ -983,7 +983,7 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName,
|
||||
if (!OnOpenContainer(aAtts, aAttsCount, nameSpaceID, localName, aLineNumber)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsRefPtr<mozilla::dom::NodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
@@ -998,7 +998,7 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName,
|
||||
// on the stack inside CreateElement (which is effectively what the HTML sink
|
||||
// does), but that's hard with all the subclass overrides going on.
|
||||
nsCOMPtr<nsIContent> parent = GetCurrentContent();
|
||||
|
||||
|
||||
result = PushContent(content);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
@@ -1006,7 +1006,7 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName,
|
||||
result = AddAttributes(aAtts, content);
|
||||
|
||||
if (NS_OK == result) {
|
||||
// Store the element
|
||||
// Store the element
|
||||
if (!SetDocElement(nameSpaceID, localName, content) && appendContent) {
|
||||
NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
|
||||
|
||||
@@ -1090,14 +1090,14 @@ nsXMLContentSink::HandleEndElement(const char16_t *aName,
|
||||
debugNameSpaceID == kNameSpaceID_XHTML;
|
||||
NS_ASSERTION(content->NodeInfo()->Equals(debugTagAtom, debugNameSpaceID) ||
|
||||
isTemplateElement, "Wrong element being closed");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
result = CloseElement(content);
|
||||
|
||||
if (mCurrentHead == content) {
|
||||
mCurrentHead = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (mDocElement == content) {
|
||||
// XXXbz for roots that don't want to be appended on open, we
|
||||
// probably need to deal here.... (and stop appending them on open).
|
||||
@@ -1110,7 +1110,7 @@ nsXMLContentSink::HandleEndElement(const char16_t *aName,
|
||||
int32_t stackLen = mContentStack.Length();
|
||||
if (mNotifyLevel >= stackLen) {
|
||||
if (numFlushed < content->GetChildCount()) {
|
||||
NotifyAppend(content, numFlushed);
|
||||
NotifyAppend(content, numFlushed);
|
||||
}
|
||||
mNotifyLevel = stackLen - 1;
|
||||
}
|
||||
@@ -1128,7 +1128,7 @@ nsXMLContentSink::HandleEndElement(const char16_t *aName,
|
||||
result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleComment(const char16_t *aName)
|
||||
{
|
||||
FlushText();
|
||||
@@ -1141,8 +1141,8 @@ nsXMLContentSink::HandleComment(const char16_t *aName)
|
||||
return NS_SUCCEEDED(rv) ? DidProcessATokenImpl() : rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleCDataSection(const char16_t *aData,
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleCDataSection(const char16_t *aData,
|
||||
uint32_t aLength)
|
||||
{
|
||||
// XSLT doesn't differentiate between text and cdata and wants adjacent
|
||||
@@ -1152,7 +1152,7 @@ nsXMLContentSink::HandleCDataSection(const char16_t *aData,
|
||||
}
|
||||
|
||||
FlushText();
|
||||
|
||||
|
||||
nsRefPtr<CDATASection> cdata = new CDATASection(mNodeInfoManager);
|
||||
cdata->SetText(aData, aLength, false);
|
||||
nsresult rv = AddContentAsLeaf(cdata);
|
||||
@@ -1162,9 +1162,9 @@ nsXMLContentSink::HandleCDataSection(const char16_t *aData,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
||||
const nsAString & aName,
|
||||
const nsAString & aSystemId,
|
||||
nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
||||
const nsAString & aName,
|
||||
const nsAString & aSystemId,
|
||||
const nsAString & aPublicId,
|
||||
nsISupports* aCatalogData)
|
||||
{
|
||||
@@ -1197,7 +1197,7 @@ nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleCharacterData(const char16_t *aData,
|
||||
nsXMLContentSink::HandleCharacterData(const char16_t *aData,
|
||||
uint32_t aLength)
|
||||
{
|
||||
return HandleCharacterData(aData, aLength, true);
|
||||
@@ -1216,7 +1216,7 @@ nsXMLContentSink::HandleCharacterData(const char16_t *aData, uint32_t aLength,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
||||
nsXMLContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
||||
const char16_t *aData)
|
||||
{
|
||||
FlushText();
|
||||
@@ -1248,7 +1248,7 @@ nsXMLContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
||||
&willNotify,
|
||||
&isAlternate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (willNotify) {
|
||||
// Successfully started a stylesheet load
|
||||
if (!isAlternate && !mRunsToCompletion) {
|
||||
@@ -1319,7 +1319,7 @@ nsXMLContentSink::HandleXMLDeclaration(const char16_t *aVersion,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::ReportError(const char16_t* aErrorText,
|
||||
nsXMLContentSink::ReportError(const char16_t* aErrorText,
|
||||
const char16_t* aSourceText,
|
||||
nsIScriptError *aError,
|
||||
bool *_retval)
|
||||
@@ -1329,7 +1329,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText,
|
||||
|
||||
// The expat driver should report the error. We're just cleaning up the mess.
|
||||
*_retval = true;
|
||||
|
||||
|
||||
mPrettyPrintXML = false;
|
||||
|
||||
mState = eXMLContentSinkState_InProlog;
|
||||
@@ -1386,14 +1386,14 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText,
|
||||
nsAutoString parsererror(errorNs);
|
||||
parsererror.Append((char16_t)0xFFFF);
|
||||
parsererror.AppendLiteral("parsererror");
|
||||
|
||||
|
||||
rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1,
|
||||
false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = HandleCharacterData(aErrorText, NS_strlen(aErrorText), false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString sourcetext(errorNs);
|
||||
sourcetext.Append((char16_t)0xFFFF);
|
||||
sourcetext.AppendLiteral("sourcetext");
|
||||
@@ -1401,13 +1401,13 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText,
|
||||
rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1,
|
||||
false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = HandleCharacterData(aSourceText, NS_strlen(aSourceText), false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = HandleEndElement(sourcetext.get(), false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = HandleEndElement(parsererror.get(), false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1439,7 +1439,7 @@ nsXMLContentSink::AddAttributes(const char16_t** aAtts,
|
||||
#define NS_ACCUMULATION_BUFFER_SIZE 4096
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::AddText(const char16_t* aText,
|
||||
nsXMLContentSink::AddText(const char16_t* aText,
|
||||
int32_t aLength)
|
||||
{
|
||||
// Create buffer when we first need it
|
||||
@@ -1570,7 +1570,7 @@ nsXMLContentSink::FlushTags()
|
||||
|
||||
mUpdatesInNotification = oldUpdates;
|
||||
mBeganUpdate = oldBeganUpdate;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1496,8 +1496,7 @@ nsXULElement::GetControllers(ErrorResult& rv)
|
||||
rv = NS_NewXULControllers(nullptr, NS_GET_IID(nsIControllers),
|
||||
reinterpret_cast<void**>(&slots->mControllers));
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv.ErrorCode()),
|
||||
"unable to create a controllers");
|
||||
NS_ASSERTION(!rv.Failed(), "unable to create a controllers");
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1457,10 +1457,14 @@ nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
|
||||
|
||||
mRangeUpdater.SelAdjSplitNode(aNode, aOffset, newNode);
|
||||
|
||||
nsresult result = aResult.StealNSResult();
|
||||
for (auto& listener : mActionListeners) {
|
||||
listener->DidSplitNode(aNode.AsDOMNode(), aOffset, GetAsDOMNode(newNode),
|
||||
aResult.ErrorCode());
|
||||
result);
|
||||
}
|
||||
// Note: result might be a success code, so we can't use Throw() to
|
||||
// set it on aResult.
|
||||
aResult = result;
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
||||
@@ -1211,7 +1211,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
|
||||
if (err.Failed()) {
|
||||
#ifdef DEBUG
|
||||
printf("Couldn't create contextual fragment: error was %X\n",
|
||||
static_cast<uint32_t>(err.ErrorCode()));
|
||||
err.ErrorCodeAsInt());
|
||||
#endif
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
||||
@@ -339,13 +339,13 @@ nsHTMLEditor::SetInlinePropertyOnTextNode(Text& aText,
|
||||
if (uint32_t(aEndOffset) != aText.Length()) {
|
||||
// We need to split off back of text node
|
||||
text = SplitNode(aText, aEndOffset, rv)->GetAsText();
|
||||
NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
}
|
||||
|
||||
if (aStartOffset) {
|
||||
// We need to split off front of text node
|
||||
SplitNode(*text, aStartOffset, rv);
|
||||
NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
}
|
||||
|
||||
if (aAttribute) {
|
||||
|
||||
@@ -690,7 +690,7 @@ nsHTMLEditor::SetResizingInfoPosition(int32_t aX, int32_t aY, int32_t aW, int32_
|
||||
ErrorResult rv;
|
||||
if (textInfo) {
|
||||
mResizingInfo->RemoveChild(*textInfo, rv);
|
||||
NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
textInfo = nullptr;
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ nsHTMLEditor::SetResizingInfoPosition(int32_t aX, int32_t aY, int32_t aW, int32_
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
textInfo = do_QueryInterface(nodeAsText);
|
||||
mResizingInfo->AppendChild(*textInfo, rv);
|
||||
NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
|
||||
res = mResizingInfo->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ GetHostForPrincipal(nsIPrincipal* aPrincipal, nsACString& aHost)
|
||||
}
|
||||
|
||||
// Some entries like "file://" uses the origin.
|
||||
rv = aPrincipal->GetOrigin(getter_Copies(aHost));
|
||||
rv = aPrincipal->GetOrigin(aHost);
|
||||
if (NS_SUCCEEDED(rv) && !aHost.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1519,7 +1519,7 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil,
|
||||
aSpellCheckSelection->GetRangesForInterval(*beginNode, beginOffset,
|
||||
*endNode, endOffset,
|
||||
true, ranges, erv);
|
||||
ENSURE_SUCCESS(erv, erv.ErrorCode());
|
||||
ENSURE_SUCCESS(erv, erv.StealNSResult());
|
||||
for (uint32_t i = 0; i < ranges.Length(); i++)
|
||||
RemoveRange(aSpellCheckSelection, ranges[i]);
|
||||
}
|
||||
|
||||
@@ -111,9 +111,8 @@ moz_icon_to_channel(nsIURI* aURI, const nsACString& aFileExt,
|
||||
rv = stream->AdoptData((char*)buf, buf_size);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_NewInputStreamChannel(aChannel,
|
||||
aURI,
|
||||
|
||||
@@ -101,9 +101,8 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPixbuf, nsIURI* aURI,
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_NewInputStreamChannel(aChannel,
|
||||
aURI,
|
||||
|
||||
@@ -84,9 +84,8 @@ moz_qicon_to_channel(QImage* image, nsIURI* aURI,
|
||||
rv = stream->AdoptData((char*)buf, buf_size);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_NewInputStreamChannel(aChannel,
|
||||
aURI,
|
||||
|
||||
@@ -876,16 +876,14 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
||||
SandboxOptions& options)
|
||||
{
|
||||
// Create the sandbox global object
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(prinOrSop);
|
||||
if (!principal) {
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(prinOrSop);
|
||||
if (sop) {
|
||||
principal = sop->GetPrincipal();
|
||||
} else {
|
||||
nsRefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
|
||||
rv = nullPrin->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsNullPrincipal> nullPrin = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrin, NS_ERROR_FAILURE);
|
||||
principal = nullPrin;
|
||||
}
|
||||
}
|
||||
@@ -1528,7 +1526,7 @@ xpc::EvalInSandbox(JSContext* cx, HandleObject sandboxArg, const nsAString& sour
|
||||
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoCString filenameBuf;
|
||||
if (!filename.IsVoid()) {
|
||||
if (!filename.IsVoid() && filename.Length() != 0) {
|
||||
filenameBuf.Assign(filename);
|
||||
} else {
|
||||
// Default to the spec of the principal.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
|
||||
|
||||
/**
|
||||
* Test that the name of a sandbox contains the name of all principals.
|
||||
*/
|
||||
function test_sandbox_name() {
|
||||
let names = [
|
||||
"http://example.com/?" + Math.random(),
|
||||
"http://example.org/?" + Math.random()
|
||||
];
|
||||
let sandbox = Cu.Sandbox(names);
|
||||
let fileName = Cu.evalInSandbox(
|
||||
"(new Error()).fileName",
|
||||
sandbox,
|
||||
"latest" /*js version*/,
|
||||
""/*file name*/
|
||||
);
|
||||
|
||||
for (let name of names) {
|
||||
Assert.ok(fileName.indexOf(name) != -1, `Name ${name} appears in ${fileName}`);
|
||||
}
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
test_sandbox_name();
|
||||
}
|
||||
@@ -97,6 +97,7 @@ skip-if = os == "android" # native test components aren't available on Android
|
||||
[test_sandbox_atob.js]
|
||||
[test_isProxy.js]
|
||||
[test_getObjectPrincipal.js]
|
||||
[test_sandbox_name.js]
|
||||
[test_watchdog_enable.js]
|
||||
head = head_watchdog.js
|
||||
[test_watchdog_disable.js]
|
||||
|
||||
@@ -258,7 +258,7 @@ struct AnimationCollection : public PRCList
|
||||
void Destroy()
|
||||
{
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mAnimations[animIdx]->Cancel();
|
||||
mAnimations[animIdx]->CancelFromStyle();
|
||||
}
|
||||
// This will call our destructor.
|
||||
mElement->DeleteProperty(mElementProperty);
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/dom/CSSStyleSheetBinding.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -734,7 +735,7 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheet* aPrimarySheet,
|
||||
MOZ_COUNT_CTOR(CSSStyleSheetInner);
|
||||
mSheets.AppendElement(aPrimarySheet);
|
||||
|
||||
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
mPrincipal = nsNullPrincipal::Create();
|
||||
if (!mPrincipal) {
|
||||
NS_RUNTIMEABORT("OOM");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::css;
|
||||
using mozilla::dom::Animation;
|
||||
using mozilla::dom::AnimationPlayState;
|
||||
using mozilla::dom::KeyframeEffectReadonly;
|
||||
using mozilla::CSSAnimation;
|
||||
|
||||
@@ -49,7 +50,7 @@ CSSAnimation::Pause()
|
||||
Animation::Pause();
|
||||
}
|
||||
|
||||
mozilla::dom::AnimationPlayState
|
||||
AnimationPlayState
|
||||
CSSAnimation::PlayStateFromJS() const
|
||||
{
|
||||
// Flush style to ensure that any properties controlling animation state
|
||||
@@ -363,21 +364,24 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
// Reset compositor state so animation will be re-synchronized.
|
||||
oldAnim->ClearIsRunningOnCompositor();
|
||||
|
||||
// Handle changes in play state.
|
||||
// CSSAnimation takes care of override behavior so that,
|
||||
// for example, if the author has called pause(), that will
|
||||
// override the animation-play-state.
|
||||
// (We should check newAnim->IsStylePaused() but that requires
|
||||
// downcasting to CSSAnimation and we happen to know that
|
||||
// newAnim will only ever be paused by calling PauseFromStyle
|
||||
// making IsPausedOrPausing synonymous in this case.)
|
||||
if (!oldAnim->IsStylePaused() && newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PauseFromStyle();
|
||||
animationChanged = true;
|
||||
} else if (oldAnim->IsStylePaused() &&
|
||||
!newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PlayFromStyle();
|
||||
animationChanged = true;
|
||||
// Handle changes in play state. If the animation is idle, however,
|
||||
// changes to animation-play-state should *not* restart it.
|
||||
if (oldAnim->PlayState() != AnimationPlayState::Idle) {
|
||||
// CSSAnimation takes care of override behavior so that,
|
||||
// for example, if the author has called pause(), that will
|
||||
// override the animation-play-state.
|
||||
// (We should check newAnim->IsStylePaused() but that requires
|
||||
// downcasting to CSSAnimation and we happen to know that
|
||||
// newAnim will only ever be paused by calling PauseFromStyle
|
||||
// making IsPausedOrPausing synonymous in this case.)
|
||||
if (!oldAnim->IsStylePaused() && newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PauseFromStyle();
|
||||
animationChanged = true;
|
||||
} else if (oldAnim->IsStylePaused() &&
|
||||
!newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PlayFromStyle();
|
||||
animationChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (animationChanged) {
|
||||
@@ -390,7 +394,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
// Although we're doing this while iterating this is safe because
|
||||
// we're not changing the length of newAnimations and we've finished
|
||||
// iterating over the list of old iterations.
|
||||
newAnim->Cancel();
|
||||
newAnim->CancelFromStyle();
|
||||
newAnim = nullptr;
|
||||
newAnimations.ReplaceElementAt(newIdx, oldAnim);
|
||||
collection->mAnimations.RemoveElementAt(oldIdx);
|
||||
@@ -410,7 +414,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
|
||||
// Cancel removed animations
|
||||
for (size_t newAnimIdx = newAnimations.Length(); newAnimIdx-- != 0; ) {
|
||||
newAnimations[newAnimIdx]->Cancel();
|
||||
newAnimations[newAnimIdx]->CancelFromStyle();
|
||||
}
|
||||
|
||||
UpdateCascadeResults(aStyleContext, collection);
|
||||
|
||||
@@ -339,7 +339,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
||||
currentValue != segment.mToValue) {
|
||||
// stop the transition
|
||||
if (!anim->GetEffect()->IsFinishedTransition()) {
|
||||
anim->Cancel();
|
||||
anim->CancelFromStyle();
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
}
|
||||
animations.RemoveElementAt(i);
|
||||
@@ -475,7 +475,7 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||
// currently in the 'transition-delay'). It also might happen because we
|
||||
// just got a style change to a value that can't be interpolated.
|
||||
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
||||
animations[currentIndex]->Cancel();
|
||||
animations[currentIndex]->CancelFromStyle();
|
||||
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
||||
animations.RemoveElementAt(currentIndex);
|
||||
aElementTransitions->UpdateAnimationGeneration(mPresContext);
|
||||
@@ -593,7 +593,7 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||
}
|
||||
#endif
|
||||
if (haveCurrentTransition) {
|
||||
animations[currentIndex]->Cancel();
|
||||
animations[currentIndex]->CancelFromStyle();
|
||||
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
||||
animations[currentIndex] = animation;
|
||||
} else {
|
||||
|
||||
@@ -136,13 +136,7 @@ public:
|
||||
~JSErrorResult()
|
||||
{
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
WouldReportJSException();
|
||||
if (IsJSException()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AutoJSContext cx;
|
||||
Optional<JS::Handle<JS::Value> > value(cx);
|
||||
StealJSException(cx, &value.Value());
|
||||
}
|
||||
SuppressException();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@@ -237,7 +231,7 @@ public:
|
||||
if (jrv.Failed()) {
|
||||
CSFLogError(logTag, ": OnAddTrack(%u) failed! Error: %u",
|
||||
static_cast<unsigned>(i),
|
||||
static_cast<unsigned>(jrv.ErrorCode()));
|
||||
jrv.ErrorCodeAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +246,7 @@ public:
|
||||
mObserver->OnAddStream(*aStream, rv);
|
||||
if (rv.Failed()) {
|
||||
CSFLogError(logTag, ": OnAddStream() failed! Error: %u",
|
||||
static_cast<unsigned>(rv.ErrorCode()));
|
||||
rv.ErrorCodeAsInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,18 @@ struct already_AddRefed
|
||||
|
||||
explicit already_AddRefed(T* aRawPtr) : mRawPtr(aRawPtr) {}
|
||||
|
||||
// Disallowed. Use move semantics instead.
|
||||
// Disallow copy constructor and copy assignment operator: move semantics used instead.
|
||||
already_AddRefed(const already_AddRefed<T>& aOther) = delete;
|
||||
already_AddRefed<T>& operator=(const already_AddRefed<T>& aOther) = delete;
|
||||
|
||||
already_AddRefed(already_AddRefed<T>&& aOther) : mRawPtr(aOther.take()) {}
|
||||
|
||||
already_AddRefed<T>& operator=(already_AddRefed<T>&& aOther)
|
||||
{
|
||||
mRawPtr = aOther.take();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper is useful in cases like
|
||||
*
|
||||
|
||||
+2
-1
@@ -107,8 +107,9 @@ public:
|
||||
private:
|
||||
void assign(T* aVal)
|
||||
{
|
||||
unref(mPtr);
|
||||
T* tmp = mPtr;
|
||||
mPtr = aVal;
|
||||
unref(tmp);
|
||||
}
|
||||
|
||||
T* MOZ_OWNING_REF mPtr;
|
||||
|
||||
@@ -511,4 +511,12 @@ operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
template <class T>
|
||||
inline already_AddRefed<T>
|
||||
do_AddRef(T*&& aObj)
|
||||
{
|
||||
nsRefPtr<T> ref(aObj);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
#endif /* mozilla_nsRefPtr_h */
|
||||
|
||||
@@ -137,9 +137,8 @@ NS_IMETHODIMP
|
||||
nsURIChecker::Init(nsIURI *aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
aURI,
|
||||
nullPrincipal,
|
||||
|
||||
@@ -579,7 +579,7 @@ NeckoParent::AllocPRemoteOpenFileParent(const SerializedLoadContext& aSerialized
|
||||
bool themeWhitelist = false;
|
||||
if (Preferences::GetBool("dom.mozApps.themable") && appUri) {
|
||||
nsAutoCString origin;
|
||||
nsPrincipal::GetOriginForURI(appUri, getter_Copies(origin));
|
||||
nsPrincipal::GetOriginForURI(appUri, origin);
|
||||
nsAutoCString themeOrigin;
|
||||
themeOrigin = Preferences::GetCString("b2g.theme.origin");
|
||||
themeWhitelist = origin.Equals(themeOrigin);
|
||||
|
||||
@@ -387,7 +387,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
|
||||
|
||||
if (Preferences::GetBool("dom.mozApps.themable")) {
|
||||
nsAutoCString origin;
|
||||
nsPrincipal::GetOriginForURI(aUri, getter_Copies(origin));
|
||||
nsPrincipal::GetOriginForURI(aUri, origin);
|
||||
nsAdoptingCString themeOrigin;
|
||||
themeOrigin = Preferences::GetCString("b2g.theme.origin");
|
||||
if (themeOrigin.Equals(origin)) {
|
||||
|
||||
@@ -60,9 +60,8 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
||||
// and sets the right loadInfo right after returning from this function.
|
||||
// Until then we follow the principal of least privilege and use
|
||||
// nullPrincipal as the loadingPrincipal.
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
||||
NS_ENSURE_TRUE(nullPrincipal, NS_ERROR_FAILURE);
|
||||
|
||||
rv = pService->NewChannel2(path,
|
||||
nullptr, // aOriginCharset
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "nsTreeSanitizer.h"
|
||||
#include "nsHtml5Module.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
#define XHTML_DIV_TAG "div xmlns=\"http://www.w3.org/1999/xhtml\""
|
||||
|
||||
@@ -75,8 +76,7 @@ nsParserUtils::Sanitize(const nsAString& aFromStr,
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), "about:blank");
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::Create();
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
|
||||
EmptyString(),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user