Merge m-c to b2ginbound a=merge CLOSED TREE

This commit is contained in:
Wes Kocher 2015-03-19 21:02:54 -07:00
commit e55e4aca42
19 changed files with 203 additions and 48 deletions

View File

@ -749,12 +749,31 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
NS_ENSURE_SUCCESS(rv, rv);
if (hasFlags) {
if (aFlags & nsIScriptSecurityManager::ALLOW_CHROME) {
// For now, don't change behavior for resource:// or moz-icon:// and
// just allow them.
if (!targetScheme.EqualsLiteral("chrome")) {
// for now don't change behavior for resource: or moz-icon:
return NS_OK;
}
// allow load only if chrome package is whitelisted
// Allow a URI_IS_UI_RESOURCE source to link to a URI_IS_UI_RESOURCE
// target if ALLOW_CHROME is set.
//
// ALLOW_CHROME is a flag that we pass on all loads _except_ docshell
// loads (since docshell loads run the loaded content with its origin
// principal). So we're effectively allowing resource://, chrome://,
// and moz-icon:// source URIs to load resource://, chrome://, and
// moz-icon:// files, so long as they're not loading it as a document.
bool sourceIsUIResource;
rv = NS_URIChainHasFlags(sourceBaseURI,
nsIProtocolHandler::URI_IS_UI_RESOURCE,
&sourceIsUIResource);
NS_ENSURE_SUCCESS(rv, rv);
if (sourceIsUIResource) {
return NS_OK;
}
// Allow the load only if the chrome package is whitelisted.
nsCOMPtr<nsIXULChromeRegistry> reg(do_GetService(
NS_CHROMEREGISTRY_CONTRACTID));
if (reg) {
@ -766,17 +785,14 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
}
}
// resource: and chrome: are equivalent, securitywise
// That's bogus!! Fix this. But watch out for
// the view-source stylesheet?
bool sourceIsChrome;
rv = NS_URIChainHasFlags(sourceBaseURI,
nsIProtocolHandler::URI_IS_UI_RESOURCE,
&sourceIsChrome);
NS_ENSURE_SUCCESS(rv, rv);
if (sourceIsChrome) {
// Special-case the hidden window: it's allowed to load
// URI_IS_UI_RESOURCE no matter what. Bug 1145470 tracks removing this.
nsAutoCString sourceSpec;
if (NS_SUCCEEDED(sourceBaseURI->GetSpec(sourceSpec)) &&
sourceSpec.EqualsLiteral("resource://gre-resources/hiddenWindow.html")) {
return NS_OK;
}
if (reportErrors) {
ReportError(nullptr, errorTag, sourceURI, aTargetURI);
}

View File

@ -4635,7 +4635,8 @@ nsDocShell::IsNavigationAllowed(bool aDisplayPrintErrorDialog,
bool aCheckIfUnloadFired)
{
bool isAllowed = !IsPrintingOrPP(aDisplayPrintErrorDialog) &&
(!aCheckIfUnloadFired || !mFiredUnloadEvent);
(!aCheckIfUnloadFired || !mFiredUnloadEvent) &&
!mBlockNavigation;
if (!isAllowed) {
return false;
}
@ -9999,13 +10000,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
GetCurScrollPos(ScrollOrientation_X, &cx);
GetCurScrollPos(ScrollOrientation_Y, &cy);
// ScrollToAnchor doesn't necessarily cause us to scroll the window;
// the function decides whether a scroll is appropriate based on the
// arguments it receives. But even if we don't end up scrolling,
// ScrollToAnchor performs other important tasks, such as informing
// the presShell that we have a new hash. See bug 680257.
rv = ScrollToAnchor(curHash, newHash, aLoadType);
NS_ENSURE_SUCCESS(rv, rv);
{
AutoRestore<bool> scrollingToAnchor(mBlockNavigation);
mBlockNavigation = true;
// ScrollToAnchor doesn't necessarily cause us to scroll the window;
// the function decides whether a scroll is appropriate based on the
// arguments it receives. But even if we don't end up scrolling,
// ScrollToAnchor performs other important tasks, such as informing
// the presShell that we have a new hash. See bug 680257.
rv = ScrollToAnchor(curHash, newHash, aLoadType);
NS_ENSURE_SUCCESS(rv, rv);
}
// Reset mLoadType to its original value once we exit this block,
// because this short-circuited load might have started after a

View File

@ -897,6 +897,7 @@ protected:
bool mUseRemoteTabs;
bool mDeviceSizeIsPageSize;
bool mWindowDraggingAllowed;
bool mBlockNavigation;
// Because scriptability depends on the mAllowJavascript values of our
// ancestors, we cache the effective scriptability and recompute it when

18
dom/cache/Cache.cpp vendored
View File

@ -78,7 +78,17 @@ using mozilla::dom::workers::WorkerPrivate;
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::cache::Cache);
NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::cache::Cache);
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Cache, mGlobal, mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_CLASS(mozilla::dom::cache::Cache)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(mozilla::dom::cache::Cache)
tmp->DisconnectFromActor();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(mozilla::dom::cache::Cache)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal, mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(mozilla::dom::cache::Cache)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Cache)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@ -533,6 +543,12 @@ Cache::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
}
Cache::~Cache()
{
DisconnectFromActor();
}
void
Cache::DisconnectFromActor()
{
if (mActor) {
mActor->StartDestroy();

3
dom/cache/Cache.h vendored
View File

@ -107,6 +107,9 @@ public:
private:
~Cache();
// Called when we're destroyed or CCed.
void DisconnectFromActor();
// TODO: Replace with actor-per-request model during refactor (bug 1110485)
RequestId AddRequestPromise(Promise* aPromise, ErrorResult& aRv);
already_AddRefed<Promise> RemoveRequestPromise(RequestId aRequestId);

View File

@ -41,8 +41,17 @@ using mozilla::ipc::PrincipalToPrincipalInfo;
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::cache::CacheStorage);
NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::cache::CacheStorage);
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CacheStorage, mGlobal,
mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_CLASS(mozilla::dom::cache::CacheStorage)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(mozilla::dom::cache::CacheStorage)
tmp->DisconnectFromActor();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(mozilla::dom::cache::CacheStorage)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal, mRequestPromises)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(mozilla::dom::cache::CacheStorage)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CacheStorage)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@ -524,6 +533,12 @@ CacheStorage::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
}
CacheStorage::~CacheStorage()
{
DisconnectFromActor();
}
void
CacheStorage::DisconnectFromActor()
{
NS_ASSERT_OWNINGTHREAD(CacheStorage);

View File

@ -109,6 +109,9 @@ private:
const mozilla::ipc::PrincipalInfo& aPrincipalInfo, Feature* aFeature);
~CacheStorage();
// Called when we're destroyed or CCed.
void DisconnectFromActor();
void MaybeRunPendingRequests();
RequestId AddRequestPromise(Promise* aPromise, ErrorResult& aRv);

View File

@ -81,7 +81,8 @@ function runTests(testFile, order) {
SimpleTest.waitForExplicitFinish();
if (typeof order == "undefined") {
order = "both"; // both by default
order = "sequential"; // sequential by default, see bug 1143222.
// TODO: Make this "both" again.
}
ok(order == "parallel" || order == "sequential" || order == "both",

View File

@ -175,6 +175,23 @@ bool MessagePumpLibevent::WatchFileDescriptor(int fd,
should_delete_event = false;
// Ownership is transferred to the controller.
evt = mozilla::MakeUnique<event>();
} else {
// It's illegal to use this function to listen on 2 separate fds with the
// same |controller|.
if (EVENT_FD(evt.get()) != fd) {
NOTREACHED() << "FDs don't match" << EVENT_FD(evt.get()) << "!=" << fd;
return false;
}
// Make sure we don't pick up any funky internal libevent masks.
int old_interest_mask = evt.get()->ev_events &
(EV_READ | EV_WRITE | EV_PERSIST);
// Combine old/new event masks.
event_mask |= old_interest_mask;
// Must disarm the event before we can reuse it.
event_del(evt.get());
}
// Set current interest mask and message pump for this event.

View File

@ -124,11 +124,21 @@ Pickle::Pickle(int header_size)
Pickle::Pickle(const char* data, int data_len)
: header_(reinterpret_cast<Header*>(const_cast<char*>(data))),
header_size_(data_len - header_->payload_size),
header_size_(0),
capacity_(kCapacityReadOnly),
variable_buffer_offset_(0) {
DCHECK(header_size_ >= sizeof(Header));
DCHECK(header_size_ == AlignInt(header_size_));
if (data_len >= static_cast<int>(sizeof(Header)))
header_size_ = data_len - header_->payload_size;
if (header_size_ > static_cast<unsigned int>(data_len))
header_size_ = 0;
if (header_size_ != AlignInt(header_size_))
header_size_ = 0;
// If there is anything wrong with the data, we're not going to use it.
if (!header_size_)
header_ = nullptr;
}
Pickle::Pickle(const Pickle& other)
@ -648,11 +658,15 @@ const char* Pickle::FindNext(uint32_t header_size,
DCHECK(header_size == AlignInt(header_size));
DCHECK(header_size <= static_cast<memberAlignmentType>(kPayloadUnit));
const Header* hdr = reinterpret_cast<const Header*>(start);
const char* payload_base = start + header_size;
const char* payload_end = payload_base + hdr->payload_size;
if (payload_end < payload_base)
return NULL;
if (end < start)
return nullptr;
size_t length = static_cast<size_t>(end - start);
if (length < sizeof(Header))
return nullptr;
return (payload_end > end) ? NULL : payload_end;
const Header* hdr = reinterpret_cast<const Header*>(start);
if (length < header_size || length - header_size < hdr->payload_size)
return nullptr;
return start + header_size + hdr->payload_size;
}

View File

@ -226,10 +226,12 @@ class Pickle {
// Returns the address of the byte immediately following the currently valid
// header + payload.
char* end_of_payload() {
// We must have a valid header_.
return payload() + payload_size();
}
const char* end_of_payload() const {
return payload() + payload_size();
// This object may be invalid.
return header_ ? payload() + payload_size() : nullptr;
}
uint32_t capacity() const {

View File

@ -844,6 +844,8 @@ void Channel::ChannelImpl::OnFileCanReadWithoutBlocking(int fd) {
if (!ProcessIncomingMessages()) {
Close();
listener_->OnChannelError();
// The OnChannelError() call may delete this, so we need to exit now.
return;
}
}

View File

@ -27,6 +27,7 @@
#include "jsmath.h"
#include "jsprf.h"
#include "jsutil.h"
#include "prmjtime.h"
#include "asmjs/AsmJSLink.h"
@ -4444,9 +4445,17 @@ FoldMaskedArrayIndex(FunctionCompiler &f, ParseNode **indexExpr, int32_t *mask,
if (IsLiteralOrConstInt(f, maskNode, &mask2)) {
// Flag the access to skip the bounds check if the mask ensures that an 'out of
// bounds' access can not occur based on the current heap length constraint.
if (mask2 == 0 ||
CountLeadingZeroes32(f.m().minHeapLength() - 1) <= CountLeadingZeroes32(mask2)) {
if (mask2 == 0) {
*needsBoundsCheck = NO_BOUNDS_CHECK;
} else {
uint32_t minHeap = f.m().minHeapLength();
uint32_t minHeapZeroes = CountLeadingZeroes32(minHeap - 1);
uint32_t maskZeroes = CountLeadingZeroes32(mask2);
if ((minHeapZeroes < maskZeroes) ||
(IsPowerOfTwo(minHeap) && minHeapZeroes == maskZeroes))
{
*needsBoundsCheck = NO_BOUNDS_CHECK;
}
}
*mask &= mask2;
*indexExpr = indexNode;

View File

@ -9896,9 +9896,8 @@ nsCSSFrameConstructor::CreateNeededPseudoInternalRubyBoxes(
return;
}
nsStyleContext* parentStyle = aParentFrame->StyleContext();
if (!parentStyle->GetPseudo()) {
// Normally, pseudo frames start from and end at some elements,
if (!IsRubyPseudo(aParentFrame)) {
// Normally, ruby pseudo frames start from and end at some elements,
// which means they don't have leading and trailing whitespaces at
// all. But there are two cases where they do actually have leading
// or trailing whitespaces:
@ -9913,6 +9912,7 @@ nsCSSFrameConstructor::CreateNeededPseudoInternalRubyBoxes(
FCItemIterator iter(aItems);
nsIContent* parentContent = aParentFrame->GetContent();
nsStyleContext* parentStyle = aParentFrame->StyleContext();
while (!iter.IsDone()) {
if (!iter.SkipItemsWantingParentType(ourParentType)) {
if (ourParentType == eTypeRuby) {

View File

@ -348,8 +348,10 @@ SearchNames(/*optional*/ const Input* subjectAltName,
return rv;
}
// do { ... } while(...) because subjectAltName isn't allowed to be empty.
do {
// According to RFC 5280, "If the subjectAltName extension is present, the
// sequence MUST contain at least one entry." For compatibility reasons, we
// do not enforce this. See bug 1143085.
while (!altNames.AtEnd()) {
GeneralNameType presentedIDType;
Input presentedID;
rv = ReadGeneralName(altNames, presentedIDType, presentedID);
@ -371,7 +373,7 @@ SearchNames(/*optional*/ const Input* subjectAltName,
presentedIDType == GeneralNameType::iPAddress) {
fallBackToCommonName = FallBackToSearchWithinSubject::No;
}
} while (!altNames.AtEnd());
}
}
if (referenceIDType == GeneralNameType::nameConstraints) {

View File

@ -1354,7 +1354,11 @@ static const CheckCertHostnameParams CHECK_CERT_HOSTNAME_PARAMS[] =
// http://tools.ietf.org/html/rfc5280#section-4.2.1.6: "If the subjectAltName
// extension is present, the sequence MUST contain at least one entry."
WITH_SAN("a", RDN(CN("a")), ByteString(), Result::ERROR_BAD_DER),
// However, for compatibility reasons, this is not enforced. See bug 1143085.
// This case is treated as if the extension is not present (i.e. name
// matching falls back to the subject CN).
WITH_SAN("a", RDN(CN("a")), ByteString(), Success),
WITH_SAN("a", RDN(CN("b")), ByteString(), Result::ERROR_BAD_CERT_DOMAIN),
// http://tools.ietf.org/html/rfc5280#section-4.1.2.6 says "If subject naming
// information is present only in the subjectAltName extension (e.g., a key
@ -2217,11 +2221,6 @@ static const NameConstraintParams NAME_CONSTRAINT_PARAMS[] =
{ RDN(CN("b.example.com")), NO_SAN, GeneralSubtree(DNSName("a.example.com")),
Result::ERROR_CERT_NOT_IN_NAME_SPACE, Success
},
{ // Empty SAN is rejected
RDN(CN("a.example.com")), ByteString(),
GeneralSubtree(DNSName("a.example.com")),
Result::ERROR_BAD_DER, Result::ERROR_BAD_DER
},
{ // DNSName CN-ID match is detected when there is a SAN w/o any DNSName or
// IPAddress
RDN(CN("a.example.com")), RFC822Name("foo@example.com"),
@ -2392,6 +2391,34 @@ static const NameConstraintParams NAME_CONSTRAINT_PARAMS[] =
GeneralSubtree(RFC822Name(".uses_underscore.example.com")),
Success, Result::ERROR_CERT_NOT_IN_NAME_SPACE
},
/////////////////////////////////////////////////////////////////////////////
// Name constraint tests that relate to having an empty SAN. According to RFC
// 5280 this isn't valid, but we allow it for compatibility reasons (see bug
// 1143085).
{ // For DNSNames, we fall back to the subject CN.
RDN(CN("a.example.com")), ByteString(),
GeneralSubtree(DNSName("a.example.com")),
Success, Result::ERROR_CERT_NOT_IN_NAME_SPACE
},
{ // For RFC822Names, we do not fall back to the subject emailAddress.
// This new implementation seems to conform better to the standards for
// RFC822 name constraints, by only applying the name constraints to
// emailAddress names in the certificate subject if there is no
// subjectAltName extension in the cert.
// In this case, the presence of the (empty) SAN extension means that RFC822
// name constraints are not enforced on the emailAddress attributes of the
// subject.
RDN(emailAddress("a@example.com")), ByteString(),
GeneralSubtree(RFC822Name("a@example.com")),
Success, Success
},
{ // Compare this to the case where there is no SAN (i.e. the name
// constraints are enforced, because the extension is not present at all).
RDN(emailAddress("a@example.com")), NO_SAN,
GeneralSubtree(RFC822Name("a@example.com")),
Success, Result::ERROR_CERT_NOT_IN_NAME_SPACE
},
};
class pkixnames_CheckNameConstraints

View File

@ -685,6 +685,18 @@ OU(const ByteString& value)
return AVA(tlv_id_at_organizationalUnitName, der::UTF8String, value);
}
ByteString
emailAddress(const ByteString& value)
{
// id-emailAddress AttributeType ::= { pkcs-9 1 }
// python DottedOIDToCode.py --tlv id-emailAddress 1.2.840.113549.1.9.1
static const uint8_t tlv_id_emailAddress[] = {
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01
};
return AVA(tlv_id_emailAddress, der::IA5String, value);
}
// RelativeDistinguishedName ::=
// SET SIZE (1..MAX) OF AttributeTypeAndValue
//

View File

@ -146,6 +146,15 @@ OU(const char* value)
std::strlen(value)));
}
ByteString emailAddress(const ByteString&);
inline ByteString
emailAddress(const char* value)
{
return emailAddress(ByteString(reinterpret_cast<const uint8_t*>(value),
std::strlen(value)));
}
// RelativeDistinguishedName ::=
// SET SIZE (1..MAX) OF AttributeTypeAndValue
//

View File

@ -3990,7 +3990,7 @@ bool nsWindow::DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
}
}
result = DispatchInputEvent(&event);
result = ConvertStatus(DispatchInputEvent(&event));
if (nsToolkit::gMouseTrailer)
nsToolkit::gMouseTrailer->Enable();