diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index 9139365bf5..62f2019527 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -101,6 +101,7 @@ MACH_MODULES = [ 'tools/docs/mach_commands.py', 'tools/mercurial/mach_commands.py', 'tools/mach_commands.py', + 'tools/power/mach_commands.py', ] diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index 3c513ca9fa..1f8907c932 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -120,10 +120,10 @@ public: { if (aName.EqualsLiteral("appId")) { nsresult rv; - mOriginAttributes->mAppId = aValue.ToInteger(&rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return false; - } + int64_t val = aValue.ToInteger64(&rv); + NS_ENSURE_SUCCESS(rv, false); + NS_ENSURE_TRUE(val <= UINT32_MAX, false); + mOriginAttributes->mAppId = static_cast(val); return true; } @@ -145,10 +145,10 @@ public: if (aName.EqualsLiteral("userContextId")) { nsresult rv; - mOriginAttributes->mUserContextId = aValue.ToInteger(&rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return false; - } + int64_t val = aValue.ToInteger64(&rv); + NS_ENSURE_SUCCESS(rv, false); + NS_ENSURE_TRUE(val <= UINT32_MAX, false); + mOriginAttributes->mUserContextId = static_cast(val); return true; } diff --git a/caps/moz.build b/caps/moz.build index 2d8d46cef3..365e8ddf8a 100644 --- a/caps/moz.build +++ b/caps/moz.build @@ -49,6 +49,9 @@ LOCAL_INCLUDES += [ '/js/xpconnect/src', ] +if CONFIG['ENABLE_TESTS']: + DIRS += ['tests/gtest'] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/caps/tests/gtest/TestOriginAttributes.cpp b/caps/tests/gtest/TestOriginAttributes.cpp new file mode 100644 index 0000000000..c5f88fed40 --- /dev/null +++ b/caps/tests/gtest/TestOriginAttributes.cpp @@ -0,0 +1,37 @@ +/* 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 "gtest/gtest.h" +#include "mozilla/BasePrincipal.h" + +using mozilla::OriginAttributes; + +static void +TestSuffix(const OriginAttributes& attrs) +{ + nsAutoCString suffix; + attrs.CreateSuffix(suffix); + + OriginAttributes attrsFromSuffix; + attrsFromSuffix.PopulateFromSuffix(suffix); + + EXPECT_EQ(attrs, attrsFromSuffix); +} + +TEST(OriginAttributes, Suffix_default) +{ + OriginAttributes attrs; + TestSuffix(attrs); +} + +TEST(OriginAttributes, Suffix_appId_inBrowser) +{ + OriginAttributes attrs(1, true); + TestSuffix(attrs); +} + +TEST(OriginAttributes, Suffix_maxAppId_inBrowser) +{ + OriginAttributes attrs(4294967295, true); + TestSuffix(attrs); +} diff --git a/caps/tests/gtest/moz.build b/caps/tests/gtest/moz.build new file mode 100644 index 0000000000..5e1a602120 --- /dev/null +++ b/caps/tests/gtest/moz.build @@ -0,0 +1,13 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +UNIFIED_SOURCES += [ + 'TestOriginAttributes.cpp' +] + +include('/ipc/chromium/chromium-config.mozbuild') + +FINAL_LIBRARY = 'xul-gtest' diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 1b2b0f86a7..fd3b981e39 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13793,6 +13793,13 @@ nsDocShell::SetIsBrowserInsideApp(uint32_t aContainingAppId) return NS_OK; } +NS_IMETHODIMP +nsDocShell::SetIsSignedPackage(const nsAString& aSignedPkg) +{ + mSignedPkg = aSignedPkg; + return NS_OK; +} + /* [infallible] */ NS_IMETHODIMP nsDocShell::GetIsBrowserElement(bool* aIsBrowser) { @@ -13900,6 +13907,9 @@ nsDocShell::GetOriginAttributes() attrs.mInBrowser = true; } + // Bug 1209162 will address the inheritance of each attributes. + attrs.mSignedPkg = mSignedPkg; + return attrs; } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 61ce522bbc..5e854e36de 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -1010,6 +1010,10 @@ protected: nsString GetInheritedPaymentRequestId(); + // The packageId for a signed packaged iff this docShell is created + // for a signed package. + nsString mSignedPkg; + private: nsCString mForcedCharset; nsCString mParentCharset; diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 5b8162c623..546e2ca33e 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -46,7 +46,7 @@ interface nsITabParent; typedef unsigned long nsLoadFlags; -[scriptable, builtinclass, uuid(41b1cf17-b37b-4a62-9df8-5f67cfecab3f)] +[scriptable, builtinclass, uuid(63adb599-6dc9-4746-972e-c22e9018020b)] interface nsIDocShell : nsIDocShellTreeItem { /** @@ -813,6 +813,12 @@ interface nsIDocShell : nsIDocShellTreeItem */ void setIsBrowserInsideApp(in unsigned long containingAppId); + /** + * Indicate that this docshell corresponds to a signed package with + * the given packageId. + */ + void setIsSignedPackage(in AString packageId); + /** * Returns the id of the app associated with this docshell. If this docshell * is an