Compare commits

...
87 Commits
Author SHA1 Message Date
Moonchild 254efe6759 Issue #2664 - Include date interval formatting in ICU build 2024-12-19 14:38:42 +01:00
Moonchild 2e68f35707 Merge pull request 'Fix master branch compilation' (#2666) from martok/UXP-contrib:mr/compilation-fix into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2666
2024-12-15 00:17:03 +00:00
Martok 786dc56351 Issue #1787 - Follow-up: remove no longer used AppClearDataObserver. 2024-12-14 23:20:01 +01:00
Martok 2c4ef2600e No issue - Follow-up: fix compilation 2024-12-14 23:20:00 +01:00
Moonchild 8c8072860d No issue - Cloned <audio>/<video> elements should respect muted attribute. 2024-12-05 14:16:07 +01:00
Brian Smith 54043a8b0a No Issue - Fixes assembling with binutil as >= 2.41. https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/effadce6c756247ea8bae32dc13bb3e6f464f0eb Same code exists in libav so applying the same patch there as well. 2024-12-04 11:07:18 +01:00
Moonchild 350e9c1879 Merge remote-tracking branch 'dbsoft/cocoawindow' 2024-12-01 20:51:22 +01:00
Brian Smith 0887abea30 No Issue - Make nsCocoaWindow hold a death grip on its native window until its destructor.
https://bugzilla.mozilla.org/show_bug.cgi?id=1880582
2024-11-30 17:53:28 -06:00
Moonchild cd78019ba6 Update NSS to 3.90.5 2024-11-28 11:11:09 +01:00
Moonchild 3a26f14966 [XPCOM] Warn about .library-ms files on Windows (treat as executable) 2024-11-28 09:59:45 +01:00
Moonchild e2714e6938 Issue #2255 - Follow-up: Check if we actually have a non-null global object.
This should avoid the intermittent crashes that are still being reported
on this issue that end up crashing because of a proxied object that can't
be unwrapped after being passed around.
2024-11-27 18:27:00 +01:00
Moonchild c0b74ce133 [network] Update effective TLD names list. 2024-11-26 22:45:53 +01:00
Moonchild 14b9599104 [js] Avoid potential crash if GC cell is no longer valid. 2024-11-23 13:54:29 +01:00
Moonchild f336312483 Merge branch '2561-revertffmpeg6' 2024-11-23 00:37:52 +01:00
Moonchild c7f25b6b9a Revert "Issue #2317 - Part 1 - Update and cleanup ffvpx documentation in preparation for lib update."
This reverts commit ea464a764f.
2024-11-22 23:07:20 +01:00
Moonchild 29445ecfbe Revert "Issue #2317 - Part 2 - Import FFmpeg 6.0 source files for ffvpx"
This reverts commit 3a67a9510b.
2024-11-22 23:07:13 +01:00
Moonchild b6925236cc Revert "Issue #2317 - Part 2a - Update changes.patch for ffvpx"
This reverts commit 4321dbddcc.
2024-11-22 23:07:06 +01:00
Moonchild 3b580c88d3 Revert "Issue #2317 - Part 2b - Clip constants used with shift instructions within inline assembly"
This reverts commit 45b9cfbe93.
2024-11-22 23:06:59 +01:00
Moonchild 946c79b573 Revert "Issue #2317 - Part 3 - Update symbols list for FFmpeg 6.0"
This reverts commit ff4d550c80.
2024-11-22 23:06:53 +01:00
Moonchild 44ef435a21 Revert "Issue #2317 - Part 4 - Regenerate config* files for ffvpx"
This reverts commit 21face45d3.
2024-11-22 23:06:46 +01:00
Moonchild 9f32e371cb Revert "Issue #2317 - Part 5 - Build ffvpx against the FFmpeg 6.0 headers"
This reverts commit ef8447ad4b.
2024-11-22 23:06:40 +01:00
Moonchild c959b55dd0 Revert "Issue #2317 - Part 6 - Remove old workaround for clang-cl"
This reverts commit aff6fbf36c.
2024-11-22 23:06:34 +01:00
Moonchild 7786fc9d84 Revert "Issue #2317 - Part 7 - Don't use -ffreestanding flag when building with clang"
This reverts commit 9d333be11b.
2024-11-22 23:06:29 +01:00
Moonchild 0e09f19795 Revert "Issue #2317 - Part 8 - Update compiler flags used for ffvpx"
This reverts commit 165ef56547.
2024-11-22 23:06:24 +01:00
Moonchild aae12e5b54 Revert "Issue #2317 - Part 9 - "send" before "receive"-ing when decoding audio using FFmpeg"
This reverts commit 6ee56b0a60.
2024-11-22 23:06:18 +01:00
Moonchild 5418ade030 Revert " Issue #2317 - Follow-up - Update ffvpx to 6.0.1"
This reverts commit 1f7023294a.
2024-11-22 23:06:11 +01:00
Moonchild 2b85a07fb9 Merge pull request 'Remove nsIAppsService, mozIApplication and mozapp data cleanup.' (#2659) from DOMApps-cleanup into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2659
2024-11-21 10:12:55 +00:00
Moonchild 25d668395b Issue #1787 - Remove nsIAppsService, mozIApplication and mozapp data cleanup. 2024-11-20 20:18:19 +01:00
Moonchild 32dd996cf2 Issue #2657 - Remove -moz-samplesize resize-decoding for low-vram mobiles
Resolves #2657
2024-11-20 14:10:10 +01:00
Moonchild 4222ca929d Merge pull request 'Remove pre-allocated process manager.' (#2656) from preallocatedprocessmanager-cleanup into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2656
2024-11-19 12:54:24 +00:00
Moonchild 35a4d4172e Merge pull request 'Remove mozapp/appID and isolated mozbrowser element support' (#2655) from isolatedmozbrowser-cleanup into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2655
2024-11-19 12:38:16 +00:00
Moonchild 945e5b88fb Issue #2654 - Remove pre-allocated process manager.
Resolves #2654
2024-11-19 13:18:31 +01:00
Moonchild dcba66d719 Issue #2653 - Part 5: Simplify and clean up some quota code
Since we no longer need a complex check, we can remove some indirection.
2024-11-18 19:15:23 +01:00
Moonchild a64ed8a1db Issue #2653 - Part 4: Remove isApp from quota manager and its clients 2024-11-18 15:00:21 +01:00
Moonchild 5206e5316c Issue #2653 - Part 3: Remove support for packaged apps from asmjscache 2024-11-18 13:58:43 +01:00
Moonchild 8f21ccd0a2 Issue #2653 - Part 2: Update tests 2024-11-17 21:38:15 +01:00
Moonchild 01a1a8557b Issue #2653 - Part 1: Initial cleanup of AppId and isolated mozbrowser.
This removes a lot of the plumbing for having the platform embed itself
through IPC which was required for B2G running the browser as both
shell and browser application.
2024-11-17 20:39:45 +01:00
Moonchild b2cab55756 No issue - Stop WebGL context forcing spew in non-debug builds. 2024-11-15 21:45:59 +01:00
Moonchild 3ead6cadb6 Issue #2652 - Part2: Add "Clear DNS cache" button to about:networking
Resolves #2652
2024-11-15 12:47:24 +01:00
Moonchild 8a4db5fa4b Issue #2652 - Part 1: Add a way to programmatically clear the DNS cache. 2024-11-15 12:25:52 +01:00
Moonchild a421c7fab4 No Issue - stop spewing useless xfo < CSP warning in non-debug builds
This warning throws off a lot of users reporting issues. It's not even
a proper warning as it's informative at best.
Leave it in for debug builds, but stop spewing these common notices in
release builds.
2024-11-14 21:53:59 +01:00
Moonchild 7894ac066c Merge pull request 'Implement Regexp Match indices' (#2650) from matchindices-work2 into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2650
2024-11-12 13:54:02 +00:00
Moonchild 1d3c46ea86 Issue #2305 Part 4: Check for failure when getting RegExp match result template
Null deref crash fix.
2024-11-12 14:30:36 +01:00
Martok 62a47c35c1 Issue #2305 Part 3c: Merge repeated loops over MatchPairs 2024-11-11 09:56:07 +01:00
Martok a2cb54f93b Issue #2305 Part 3b: Create .indices and .indices.groups 2024-11-11 09:55:47 +01:00
Moonchild 4cc45366d7 Issue #2305 Part 3a: Pass ResultTemplateKind through CreateRegExpMatchResult
This sets up the MatchResult with the proper structure to contain indices
when necessary.
2024-11-11 09:55:39 +01:00
Moonchild 935d1b9e1b Issue #2305 Part 2: Support .indices in match result template objects
Before match indices, all match results had the same shape. (If there are
no named capture groups, `.groups` exists but is undefined.) Match results
with `.indices` have a distinct shape, so we need a distinct template
object. We also need a template object for `.indices` itself.
2024-11-11 09:54:26 +01:00
Moonchild c18edb0b67 Issue #2305 Part 1: Add support for hasIndices to RegExpFlags (/d)
Adds recognition and parsing of the /d RegExp flag.
Drive-by correction: add missing "s" for dotAll to RegExpObject::toString.
Tag #1284 and #2008
2024-11-11 09:53:05 +01:00
Karl Tomlinson 7f93d25967 Bug 1920800 - Remove oldImages from check for flushed old principal handle
The logic should be equivalent when frame IDs on aImages are contiguously
increasing from IDs on previously set frames.

There are currently no callers passing empty aImages, but the logic in this
case would now be as described in the documentation of
UpdatePrincipalHandleForFrameID():

> We will notify mElement that aPrincipalHandle has been applied when all
> FrameIDs prior to aFrameID have been flushed out.
2024-10-30 13:21:33 +01:00
Moonchild 0f007a16d5 Issue #2648 - Inherit the content disposition of the multipart response 2024-10-30 09:50:08 +01:00
Moonchild eacd48cccb Issue #2648 - Apply CSP to documents sent through multipart/x-mixed-replace 2024-10-30 09:48:28 +01:00
Moonchild fc1fe7d0c5 Issue #2646 - Parse "variations" keywords.
Resolves #2646
2024-10-29 15:27:44 +01:00
Moonchild 92873ead3e Revert "Issue #2645 - Fix type confusion for ResumeKind"
This reverts commit 12e9db2481.
2024-10-28 14:51:10 +01:00
Moonchild 9fede4a3ba Merge branch '2645-resumekind' 2024-10-23 10:52:32 +02:00
Moonchild dbd5dc9554 Issue #2645 - Return null if getName() PC is invalid. 2024-10-21 22:50:57 +02:00
Moonchild 3f538909ab Merge branch 'master' into 2645-resumekind 2024-10-21 13:56:59 +02:00
Moonchild 8e4ce9b800 Issue #2641 - Update Fetch to adhere to the updated spec (pass refpolicy)
Resolves #2641
2024-10-21 12:37:01 +02:00
Moonchild edf4210e12 Issue #2641 - Speculative load changes for referrerpolicy 2024-10-21 12:36:11 +02:00
Moonchild 5a64fd9657 Merge pull request 'Apply border-radius to Outlines as fallback to -moz-outline-radius' (#2643) from RealityRipple/UXP:outline-radius-fallback into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2643
2024-10-11 21:55:29 +00:00
Moonchild 12e9db2481 Issue #2645 - Fix type confusion for ResumeKind
It used a mix of uint8_t and uint16_t. Set it to uint16_t.
Also don't allow non-typeset to simplify stubs used in compound opcodes.
2024-10-11 22:02:44 +02:00
Andy 0af6123536 The border-radius Directive Should Apply to Outlines
However, `-moz-outline-radius` should still override any `border-radius`.
This is primarily done for backward compatibility with some themes.
Additionally, it also allows for more advanced outline control than the CSS spec provides, without breaking spec.
Finally, if the spec is ever updated to include `outline-radius`, we'll be ready to drop the `-moz-` prefix!

Note: BZ 315209 has an inadvertent double-negative in nsDisplayList.cpp:
HasRadius() essentially returns the opposite value it should.
2024-10-09 12:08:46 -07:00
Moonchild e2c94125cc [GMP] Factor out more detailed CheckDimensions function for CreateFrame. 2024-10-02 10:34:38 +02:00
Steve Fink 723ca48613 [js] Disallow deserializing structured clone buffers with transferables more than once. 2024-10-01 22:22:04 +02:00
Boris Zbarsky 15514da406 Bug 1493449 - Change the default credentials mode for module scripts from 'omit' to 'same-origin'
Resolves #2642
2024-10-01 00:03:06 +02:00
Moonchild 04d1e3e53a Revert "Issue #2523 - Part 1 - Import headers from FFmpeg 7.0"
This reverts commit 27bb48deaf.
2024-09-30 23:49:05 +02:00
Moonchild c654c1820f Revert "Issue #2523 - Part 2 - Update audio & video decoders to work with FFmpeg 7.0"
This reverts commit 7dbc24a739.
2024-09-30 23:48:55 +02:00
Moonchild 39dd9d560a Revert "Issue #2527 - Part 1 - Remove old FFmpeg and LibAV headers"
This reverts commit b970fc412a.
2024-09-30 23:48:43 +02:00
Moonchild 032357c053 Revert "Issue #2527 - Part 2 - Remove support for libavcodec < 58"
This reverts commit 738c6a740a.
2024-09-30 23:48:33 +02:00
Moonchild ecacd4a4d9 Revert "Issue #2527 - Part 3 - Remove additional checks for LibAV"
This reverts commit b0f872c919.
2024-09-30 23:48:25 +02:00
Moonchild a6bc5962c4 Bug 1900191 - Use nestegg advertised default duration if it exists. 2024-09-30 22:34:37 +02:00
Moonchild 12e93be21a Bug 1878510 - Follow-up: Explicitly pass values through variadic functions
While MSVC has no issue with this and understands values should be passed,
clang doesn't like it and aborts.
2024-09-27 13:15:06 +02:00
Moonchild 0aeac02b89 Bug 1878510 - When recreating WebM demuxer when encountering a new segment, propagate media time 2024-09-25 22:22:49 +02:00
Moonchild 1402d8eee6 Merge pull request 'libjpeg: NetBSD/powerpc ALTIVEC simd support' (#2591) from discoM/UXP:powerpc_altivec into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2591
2024-09-23 13:02:25 +00:00
Martin Husemann 42b3e18a4a libjpeg: add NetBSD/powerpc spcific Altivec cpu feature detection 2024-09-23 12:51:33 +02:00
Moonchild cabe9ea2d5 Update README to point to the xref site.
Gitea's bleve indexer is too slow and resource-intensive to use.
2024-09-22 15:14:37 +02:00
Moonchild c57a1eee66 Merge pull request 'Make NetBSD use the same xptcall support as others.' (#2588) from discoM/UXP:xptcall_netbsd_powerpc into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2588
2024-09-22 10:50:03 +00:00
Moonchild a8fbc1dfbe Merge pull request 'Make NetBSD/powerpc use the powerpc atomic ops.' (#2589) from discoM/UXP:netbsd_ppc_atomicops into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2589
2024-09-22 10:49:44 +00:00
Martin Husemann 1f457514b0 Hardcode '-maltivec' as compiler flag for powerpc/altivec support 2024-09-22 12:39:23 +02:00
Martin Husemann acd339fcf7 Make NetBSD/powerpc use the powerpc atomic ops.
NetBSD/powerpc gcc does not predefine __ppc__, but only __powerpc__,
so add that to the preprocessor ifdef cascade to select atomic
ops.
2024-09-22 12:10:32 +02:00
Martin Husemann 07bb7f379b Make NetBSD use the same xptcall support as others.
These functions are only ELF ABI specific, not really OS specific.
Add powerpc, powerpc64 and sparc64 support for NetBSD
by using the same code as other ELF systems do.
2024-09-22 11:56:04 +02:00
Moonchild 8cabf0bf72 [Debug] Make inaccurate GC stats reporting non-fatal in debug builds.
Not sure why this was fatal as it only hinders being able to report memory
issues to a debugging dev :P
2024-09-21 15:38:34 +02:00
Moonchild 178f72365d Merge branch '2251-ghostbuster-work' 2024-09-20 16:47:02 +02:00
FranklinDM f819937a31 Issue #2251 - Expose unlink ghost windows to about:memory 2024-09-19 19:08:04 +02:00
FranklinDM 114b5265d6 Issue #2251 - Expose ghost window unlinking to release builds. 2024-09-19 19:07:33 +02:00
Moonchild 8595dc550f No issue - Fix asserts in debug.
Hashbang parser changes allow more than one EOL which screws up these
assertions' premise. Just remove them as the preconditions are no longer
valid.
2024-09-19 19:04:22 +02:00
Moonchild 5b8d28ba4d Merge pull request 'Fix building for Apple Silicon Mac with Xcode 16.' (#2587) from dbsoft/UXP:clangarm64fix into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2587
2024-09-19 12:47:55 +00:00
Brian Smith 8146ba5a07 No Issue - Fix building for Apple Silicon Mac with Xcode 16.
Due to the following LLVM change labels need to be outside .cfi_start/endprocs:
https://reviews.llvm.org/D155245
Solution pointed out here is to move the label above .cfi_startproc:
https://github.com/libffi/libffi/issues/807
2024-09-18 13:47:23 -05:00
770 changed files with 77067 additions and 42557 deletions

No files matched your search

+7
View File
@@ -19,6 +19,13 @@ If you are interested in the development and building side of things, some
information will be available on the [Pale Moon developer site](http://developer.palemoon.org).
You are also always welcome to get in touch with our community on the [Pale Moon forum](https://forum.palemoon.org/).
### Code search
While our repo has basic code searching capabilities (via `git grep`), you are strongly
encouraged to instead use the dedicated code search and cross-referencing site:
[https://xref.palemoon.org/](https://xref.palemoon.org/)
This repo and a copy of the front-end are amalgamated in the `goanna-central` index.
### A note about trademarks and branding
Although this repository is primarily licensed under Mozilla Public License v2.0, the
+2 -2
View File
@@ -340,9 +340,9 @@ this.AccessFu = { // jshint ignore:line
case 'remote-browser-shown':
case 'inprocess-browser-shown':
{
// Ignore notifications that aren't from a BrowserOrApp
// Ignore notifications that aren't from a Browser
let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader);
if (!frameLoader.ownerIsMozBrowserOrAppFrame) {
if (!frameLoader.ownerIsMozBrowserFrame) {
return;
}
this._handleMessageManager(frameLoader.messageManager);
+2 -7
View File
@@ -624,13 +624,8 @@ BasePrincipal::GetOriginSuffix(nsACString& aOriginAttributes)
NS_IMETHODIMP
BasePrincipal::GetAppStatus(uint16_t* aAppStatus)
{
if (AppId() == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
NS_WARNING("Asking for app status on a principal with an unknown app id");
*aAppStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
return NS_OK;
}
*aAppStatus = nsScriptSecurityManager::AppStatusForPrincipal(this);
// TODO: Remove GetAppStatus.
*aAppStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
return NS_OK;
}
-9
View File
@@ -303,15 +303,6 @@ interface nsIPrincipal : nsISerializable
*/
[infallible] readonly attribute unsigned long privateBrowsingId;
/**
* Returns true iff the principal is inside an isolated mozbrowser element.
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements. <iframe mozbrowser noisolation> does not count as
* isolated since isolation is disabled. Isolation can only be disabled if
* the containing document is chrome.
*/
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
/**
* Returns true if this principal has an unknown appId. This shouldn't
* generally be used. We only expose it due to not providing the correct
-2
View File
@@ -31,8 +31,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/HashFunctions.h"
#include "nsIAppsService.h"
using namespace mozilla;
static bool gCodeBasePrincipalSupport = false;
-64
View File
@@ -9,7 +9,6 @@
#include "xpcpublic.h"
#include "XPCWrapper.h"
#include "nsIAppsService.h"
#include "nsIInputStreamChannel.h"
#include "nsILoadContext.h"
#include "nsIServiceManager.h"
@@ -55,7 +54,6 @@
#include "nsIChromeRegistry.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "mozIApplication.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ContentParent.h"
@@ -240,68 +238,6 @@ nsScriptSecurityManager::SecurityHashURI(nsIURI* aURI)
return NS_SecurityHashURI(aURI);
}
uint16_t
nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
{
uint32_t appId = aPrin->GetAppId();
// After bug 1238160, the principal no longer knows how to answer "is this a
// browser element", which is really what this code path wants. Currently,
// desktop is the only platform where we intend to disable isolation on a
// browser frame, so non-desktop should be able to assume that
// inIsolatedMozBrowser is true for all mozbrowser frames. Additionally,
// apps are no longer used on desktop, so appId is always NO_APP_ID. We use
// a release assertion in nsFrameLoader::OwnerIsIsolatedMozBrowserFrame so
// that platforms with apps can assume inIsolatedMozBrowser is true for all
// mozbrowser frames.
bool inIsolatedMozBrowser = aPrin->GetIsInIsolatedMozBrowserElement();
NS_WARNING_ASSERTION(
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
"Asking for app status on a principal with an unknown app id");
// Installed apps have a valid app id (not NO_APP_ID or UNKNOWN_APP_ID)
// and they are not inside a mozbrowser.
if (appId == nsIScriptSecurityManager::NO_APP_ID ||
appId == nsIScriptSecurityManager::UNKNOWN_APP_ID ||
inIsolatedMozBrowser)
{
return nsIPrincipal::APP_STATUS_NOT_INSTALLED;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(appsService, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByLocalId(appId, getter_AddRefs(app));
NS_ENSURE_TRUE(app, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
uint16_t status = nsIPrincipal::APP_STATUS_INSTALLED;
NS_ENSURE_SUCCESS(app->GetAppStatus(&status),
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
nsString appOrigin;
NS_ENSURE_SUCCESS(app->GetOrigin(appOrigin),
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
nsCOMPtr<nsIURI> appURI;
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(appURI), appOrigin),
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
// The app could contain a cross-origin iframe - make sure that the content
// is actually same-origin with the app.
MOZ_ASSERT(inIsolatedMozBrowser == false, "Checked this above");
nsAutoCString suffix;
PrincipalOriginAttributes attrs;
NS_ENSURE_TRUE(attrs.PopulateFromOrigin(NS_ConvertUTF16toUTF8(appOrigin), suffix),
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
attrs.mAppId = appId;
attrs.mInIsolatedMozBrowser = false;
nsCOMPtr<nsIPrincipal> appPrin = BasePrincipal::CreateCodebasePrincipal(appURI, attrs);
NS_ENSURE_TRUE(appPrin, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
return aPrin->Equals(appPrin) ? status
: nsIPrincipal::APP_STATUS_NOT_INSTALLED;
}
/*
* GetChannelResultPrincipal will return the principal that the resource
* returned by this channel will use. For example, if the resource is in
-1
View File
@@ -4,7 +4,6 @@ support-files =
file_disableScript.html
!/js/xpconnect/tests/mochitest/file_empty.html
[test_app_principal_equality.html]
[test_bug246699.html]
[test_bug292789.html]
[test_bug423375.html]
@@ -1,88 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=777467
-->
<head>
<meta charset="utf-8">
<title>Test app principal's equality</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777467">Mozilla Bug 777467</a>
<p id="display"></p>
<script>
/** Test for app principal's equality **/
SimpleTest.waitForExplicitFinish();
var permissions = new Promise(resolve => {
SpecialPowers.pushPermissions(
[{ type: "browser", allow: true, context: document },
{ type: "embed-apps", allow: true, context: document }],
resolve);
});
permissions.then(() => {
$('content').innerHTML =
'<iframe src="error404"></iframe>\n' +
'<iframe mozbrowser src="error404"></iframe>\n' +
'<iframe mozapp="http://example.org/manifest.webapp" mozbrowser src="error404"></iframe>';
var iframes = document.getElementsByTagName("iframe");
var promises = []
for (var i = 0; i < promises.length; ++i) {
promises.push(new Promise(resolve => {
iframes[i].addEventListener("load", resolve);
}));
}
return Promise.all(promises);
});
var prefs = new Promise(resolve => {
SpecialPowers.pushPrefEnv(
{ set: [[ "dom.mozBrowserFramesEnabled", true ],
[ "dom.ipc.browser_frames.oop_by_default", false ]] },
resolve);
});
</script>
<div id="content" style="display: none;">
</div>
<pre id="test">
<script type="application/javascript">
function canAccessDocument(win) {
var result = true;
try {
win.document;
} catch(e) {
result = false;
}
return result;
}
var loaded = new Promise(resolve => addLoadEvent(resolve));
Promise.all([ permissions, prefs, loaded ]).then(runTest);
function runTest() {
// Test the witness frame (we can access same-origin frame).
is(canAccessDocument(frames[0]), true,
"should be able to access the first frame");
// Test different app/browserElement frames.
for (var i=1; i<frames.length; ++i) {
is(canAccessDocument(frames[i]), false,
"should not be able to access the other frames");
}
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>
+1
View File
@@ -86,6 +86,7 @@ included_inclnames_to_ignore = set([
'unicode/uclean.h', # ICU
'unicode/ucol.h', # ICU
'unicode/udat.h', # ICU
'unicode/udateintervalformat.h', # ICU
'unicode/udatpg.h', # ICU
'unicode/udisplaycontext.h',# ICU
'unicode/uenum.h', # ICU
+1 -1
View File
@@ -152,6 +152,7 @@ sources = [
'/intl/icu/source/i18n/ucol_sit.cpp',
'/intl/icu/source/i18n/ucoleitr.cpp',
'/intl/icu/source/i18n/udat.cpp',
'/intl/icu/source/i18n/udateintervalformat.cpp',
'/intl/icu/source/i18n/udatpg.cpp',
'/intl/icu/source/i18n/ufieldpositer.cpp',
'/intl/icu/source/i18n/uitercollationiterator.cpp',
@@ -217,7 +218,6 @@ other_sources = [
'/intl/icu/source/i18n/transreg.cpp',
'/intl/icu/source/i18n/tridpars.cpp',
'/intl/icu/source/i18n/ucsdet.cpp',
'/intl/icu/source/i18n/udateintervalformat.cpp',
'/intl/icu/source/i18n/ulocdata.cpp',
'/intl/icu/source/i18n/unesctrn.cpp',
'/intl/icu/source/i18n/uni2name.cpp',
+3 -5
View File
@@ -569,11 +569,9 @@ WebConsoleActor.prototype =
let startedListeners = [];
let window = !this.parentActor.isRootActor ? this.window : null;
let appId = null;
let messageManager = null;
if (this._parentIsContentActor) {
appId = this.parentActor.docShell.appId;
messageManager = this.parentActor.messageManager;
}
@@ -604,16 +602,16 @@ WebConsoleActor.prototype =
// Create a StackTraceCollector that's going to be shared both by the
// NetworkMonitorChild (getting messages about requests from parent) and
// by the NetworkMonitor that directly watches service workers requests.
this.stackTraceCollector = new StackTraceCollector({ window, appId });
this.stackTraceCollector = new StackTraceCollector({ window });
this.stackTraceCollector.init();
let processBoundary = Services.appinfo.processType !=
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
if ((appId || messageManager) && processBoundary) {
if (messageManager && processBoundary) {
// Start a network monitor in the parent process to listen to
// most requests than happen in parent
this.networkMonitor =
new NetworkMonitorChild(appId, this.parentActor.outerWindowID,
new NetworkMonitorChild(this.parentActor.outerWindowID,
messageManager, this.conn, this);
this.networkMonitor.init();
// Spawn also one in the child to listen to service workers
+4 -4
View File
@@ -37,12 +37,12 @@ function getTopWindow(win) {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
if (!docShell.isMozBrowserOrApp) {
if (!docShell.isMozBrowser) {
return win.top;
}
let topDocShell =
docShell.getSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries();
docShell.getSameTypeRootTreeItemIgnoreBrowserBoundaries();
return topDocShell
? topDocShell.contentViewer.DOMDocument.defaultView
@@ -98,12 +98,12 @@ function getParentWindow(win) {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
if (!docShell.isMozBrowserOrApp) {
if (!docShell.isMozBrowser) {
return win.parent;
}
let parentDocShell =
docShell.getSameTypeParentIgnoreBrowserAndAppBoundaries();
docShell.getSameTypeParentIgnoreBrowserBoundaries();
return parentDocShell
? parentDocShell.contentViewer.DOMDocument.defaultView
@@ -1551,8 +1551,6 @@ NetworkMonitor.prototype = {
* data to the WebConsoleActor or to a NetworkEventActor.
*
* @constructor
* @param number appId
* The web appId of the child process.
* @param number outerWindowID
* The outerWindowID of the TabActor's main window.
* @param nsIMessageManager messageManager
@@ -1562,8 +1560,7 @@ NetworkMonitor.prototype = {
* @param object owner
* The WebConsoleActor that is listening for the network requests.
*/
function NetworkMonitorChild(appId, outerWindowID, messageManager, conn, owner) {
this.appId = appId;
function NetworkMonitorChild(outerWindowID, messageManager, conn, owner) {
this.outerWindowID = outerWindowID;
this.conn = conn;
this.owner = owner;
@@ -1577,7 +1574,6 @@ function NetworkMonitorChild(appId, outerWindowID, messageManager, conn, owner)
exports.NetworkMonitorChild = NetworkMonitorChild;
NetworkMonitorChild.prototype = {
appId: null,
owner: null,
_netEvents: null,
_saveRequestAndResponseBodies: true,
@@ -1623,7 +1619,6 @@ NetworkMonitorChild.prototype = {
mm.addMessageListener(`${this._msgName}:newEvent`, this._onNewEvent);
mm.addMessageListener(`${this._msgName}:updateEvent`, this._onUpdateEvent);
mm.sendAsyncMessage(this._msgName, {
appId: this.appId,
outerWindowID: this.outerWindowID,
action: "start",
});
-22
View File
@@ -157,28 +157,6 @@ LoadContext::SetRemoteTabs(bool aUseRemoteTabs)
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
LoadContext::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
{
MOZ_ASSERT(mIsNotNull);
NS_ENSURE_ARG_POINTER(aIsInIsolatedMozBrowserElement);
*aIsInIsolatedMozBrowserElement = mOriginAttributes.mInIsolatedMozBrowser;
return NS_OK;
}
NS_IMETHODIMP
LoadContext::GetAppId(uint32_t* aAppId)
{
MOZ_ASSERT(mIsNotNull);
NS_ENSURE_ARG_POINTER(aAppId);
*aAppId = mOriginAttributes.mAppId;
return NS_OK;
}
NS_IMETHODIMP
LoadContext::GetOriginAttributes(JS::MutableHandleValue aAttrs)
{
-4
View File
@@ -38,8 +38,6 @@ public:
NS_DECL_NSILOADCONTEXT
NS_DECL_NSIINTERFACEREQUESTOR
// appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
// provided by child process.
LoadContext(const IPC::SerializedLoadContext& aToCopy,
dom::Element* aTopFrameElement,
DocShellOriginAttributes& aAttrs)
@@ -54,8 +52,6 @@ public:
{
}
// appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
// provided by child process.
LoadContext(const IPC::SerializedLoadContext& aToCopy,
uint64_t aNestedFrameId,
DocShellOriginAttributes& aAttrs)
+3 -2
View File
@@ -334,7 +334,7 @@ nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
parentDocShellItem) {
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
if (curDocShell && curDocShell->GetIsMozBrowserOrApp()) {
if (curDocShell && curDocShell->GetIsMozBrowser()) {
break;
}
@@ -427,6 +427,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal)
return false;
}
#ifdef DEBUG
// log warning to console that xfo is ignored because of CSP
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0;
@@ -440,7 +441,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal)
0, // no columnnumber
nsIScriptError::warningFlag,
"CSP", innerWindowID);
#endif
return true;
}
+18 -103
View File
@@ -193,7 +193,6 @@
#include "nsSandboxFlags.h"
#include "nsXULAppAPI.h"
#include "nsDOMNavigationTiming.h"
#include "nsIAppsService.h"
#include "nsDSURIContentListener.h"
#include "nsDocShellLoadTypes.h"
#include "nsDocShellTransferableHooks.h"
@@ -2564,7 +2563,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
NS_IMETHODIMP
nsDocShell::SetFullscreenAllowed(bool aFullscreenAllowed)
{
if (!nsIDocShell::GetIsMozBrowserOrApp()) {
if (!nsIDocShell::GetIsMozBrowser()) {
// Only allow setting of fullscreenAllowed on content/process boundaries.
// At non-boundaries the fullscreenAllowed attribute is calculated based on
// whether all enclosing frames have the "mozFullscreenAllowed" attribute
@@ -3396,7 +3395,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
if (nsIDocShell::GetIsMozBrowserOrApp()) {
if (nsIDocShell::GetIsMozBrowser()) {
return NS_OK;
}
@@ -3413,7 +3412,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
}
NS_IMETHODIMP
nsDocShell::GetSameTypeParentIgnoreBrowserAndAppBoundaries(nsIDocShell** aParent)
nsDocShell::GetSameTypeParentIgnoreBrowserBoundaries(nsIDocShell** aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
@@ -3467,18 +3466,18 @@ nsDocShell::GetSameTypeRootTreeItem(nsIDocShellTreeItem** aRootTreeItem)
}
NS_IMETHODIMP
nsDocShell::GetSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries(nsIDocShell ** aRootTreeItem)
nsDocShell::GetSameTypeRootTreeItemIgnoreBrowserBoundaries(nsIDocShell ** aRootTreeItem)
{
NS_ENSURE_ARG_POINTER(aRootTreeItem);
*aRootTreeItem = static_cast<nsIDocShell *>(this);
nsCOMPtr<nsIDocShell> parent;
NS_ENSURE_SUCCESS(GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent)),
NS_ENSURE_SUCCESS(GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent)),
NS_ERROR_FAILURE);
while (parent) {
*aRootTreeItem = parent;
NS_ENSURE_SUCCESS((*aRootTreeItem)->
GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent)),
GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent)),
NS_ERROR_FAILURE);
}
NS_ADDREF(*aRootTreeItem);
@@ -3532,12 +3531,6 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false;
}
if (targetDS->GetIsInIsolatedMozBrowserElement() !=
accessingDS->GetIsInIsolatedMozBrowserElement() ||
targetDS->GetAppId() != accessingDS->GetAppId()) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));
nsCOMPtr<nsIDocShell> accessingRootDS = do_QueryInterface(accessingRoot);
@@ -3558,7 +3551,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
if (OriginAttributes::IsFirstPartyEnabled()) {
if (accessingDS == accessingRootDS &&
aAccessingItem->ItemType() == nsIDocShellTreeItem::typeContent &&
!accessingDS->GetIsMozBrowserOrApp()) {
!accessingDS->GetIsMozBrowser()) {
nsCOMPtr<nsIDocument> accessingDoc = aAccessingItem->GetDocument();
@@ -3572,7 +3565,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
if (targetDS == targetRootDS &&
aTargetItem->ItemType() == nsIDocShellTreeItem::typeContent &&
!targetDS->GetIsMozBrowserOrApp()) {
!targetDS->GetIsMozBrowser()) {
nsCOMPtr<nsIDocument> targetDoc = aAccessingItem->GetDocument();
@@ -3769,7 +3762,7 @@ nsDocShell::DoFindItemWithName(const nsAString& aName,
// If we have a same-type parent, respecting browser and app boundaries.
// NOTE: Could use GetSameTypeParent if the issues described in bug 1310344 are fixed.
if (!GetIsMozBrowserOrApp() && parentAsTreeItem->ItemType() == mItemType) {
if (!GetIsMozBrowser() && parentAsTreeItem->ItemType() == mItemType) {
return parentAsTreeItem->FindItemWithName(
aName,
static_cast<nsIDocShellTreeItem*>(this),
@@ -5282,16 +5275,6 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
errorPageUrl.AppendLiteral("&f=");
errorPageUrl.AppendASCII(frameType.get());
// Append the manifest URL if the error comes from an app.
nsString manifestURL;
nsresult rv = GetAppManifestURL(manifestURL);
if (manifestURL.Length() > 0) {
nsCString manifestParam;
SAFE_ESCAPE(manifestParam, NS_ConvertUTF16toUTF8(manifestURL), url_Path);
errorPageUrl.AppendLiteral("&m=");
errorPageUrl.AppendASCII(manifestParam.get());
}
nsCOMPtr<nsICaptivePortalService> cps = do_GetService(NS_CAPTIVEPORTAL_CID);
int32_t cpsState;
if (cps && NS_SUCCEEDED(cps->GetState(&cpsState)) &&
@@ -5305,7 +5288,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
errorPageUrl.AppendASCII(escapedDescription.get());
nsCOMPtr<nsIURI> errorPageURI;
rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
nsresult rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
NS_ENSURE_SUCCESS(rv, rv);
return InternalLoad(errorPageURI, nullptr, false, false,
@@ -6190,9 +6173,7 @@ nsDocShell::SetIsActive(bool aIsActive)
mScriptGlobal->SetIsBackground(!aIsActive);
if (nsCOMPtr<nsIDocument> doc = mScriptGlobal->GetExtantDoc()) {
// Update orientation when the top-level browsing context becomes active.
// We make an exception for apps because they currently rely on
// orientation locks persisting across browsing contexts.
if (aIsActive && !GetIsApp()) {
if (aIsActive) {
nsCOMPtr<nsIDocShellTreeItem> parent;
GetSameTypeParent(getter_AddRefs(parent));
if (!parent) {
@@ -6229,7 +6210,7 @@ nsDocShell::SetIsActive(bool aIsActive)
continue;
}
if (!docshell->GetIsMozBrowserOrApp()) {
if (!docshell->GetIsMozBrowser()) {
docshell->SetIsActive(aIsActive);
}
}
@@ -10565,9 +10546,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// lock the orientation of the document to the document's default
// orientation. We don't explicitly check for a top-level browsing context
// here because orientation is only set on top-level browsing contexts.
// We make an exception for apps because they currently rely on
// orientation locks persisting across browsing contexts.
if (OrientationLock() != eScreenOrientation_None && !GetIsApp()) {
if (OrientationLock() != eScreenOrientation_None) {
#ifdef DEBUG
nsCOMPtr<nsIDocShellTreeItem> parent;
GetSameTypeParent(getter_AddRefs(parent));
@@ -10950,7 +10929,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
NeckoOriginAttributes neckoAttrs;
bool isTopLevelDoc = aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT &&
mItemType == typeContent &&
!GetIsMozBrowserOrApp();
!GetIsMozBrowser();
neckoAttrs.InheritFromDocShellToNecko(GetOriginAttributes(), isTopLevelDoc, aURI);
rv = loadInfo->SetOriginAttributes(neckoAttrs);
if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -14387,16 +14366,9 @@ nsDocShell::GetFrameType(uint32_t* aFrameType)
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsApp(bool* aIsApp)
nsDocShell::GetIsMozBrowser(bool* aIsMozBrowser)
{
*aIsApp = (mFrameType == FRAME_TYPE_APP);
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsMozBrowserOrApp(bool* aIsMozBrowserOrApp)
{
*aIsMozBrowserOrApp = (mFrameType != FRAME_TYPE_REGULAR);
*aIsMozBrowser = (mFrameType == FRAME_TYPE_BROWSER);
return NS_OK;
}
@@ -14419,30 +14391,9 @@ nsDocShell::GetInheritedFrameType()
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsIsolatedMozBrowserElement(bool* aIsIsolatedMozBrowserElement)
nsDocShell::GetIsInMozBrowser(bool* aIsInMozBrowser)
{
bool result = mFrameType == FRAME_TYPE_BROWSER &&
mOriginAttributes.mInIsolatedMozBrowser;
*aIsIsolatedMozBrowserElement = result;
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
{
MOZ_ASSERT(!mOriginAttributes.mInIsolatedMozBrowser ||
(GetInheritedFrameType() == FRAME_TYPE_BROWSER),
"Isolated mozbrowser should only be true inside browser frames");
bool result = (GetInheritedFrameType() == FRAME_TYPE_BROWSER) &&
mOriginAttributes.mInIsolatedMozBrowser;
*aIsInIsolatedMozBrowserElement = result;
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsInMozBrowserOrApp(bool* aIsInMozBrowserOrApp)
{
*aIsInMozBrowserOrApp = (GetInheritedFrameType() != FRAME_TYPE_REGULAR);
*aIsInMozBrowser = (GetInheritedFrameType() == FRAME_TYPE_BROWSER);
return NS_OK;
}
@@ -14460,25 +14411,6 @@ nsDocShell::GetIsTopLevelContentDocShell(bool* aIsTopLevelContentDocShell)
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetAppId(uint32_t* aAppId)
{
if (mOriginAttributes.mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
*aAppId = mOriginAttributes.mAppId;
return NS_OK;
}
nsCOMPtr<nsIDocShell> parent;
GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
if (!parent) {
*aAppId = nsIScriptSecurityManager::NO_APP_ID;
return NS_OK;
}
return parent->GetAppId(aAppId);
}
// Implements nsILoadContext.originAttributes
NS_IMETHODIMP
nsDocShell::GetOriginAttributes(JS::MutableHandle<JS::Value> aVal)
@@ -14587,23 +14519,6 @@ nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
return SetOriginAttributes(attrs);
}
NS_IMETHODIMP
nsDocShell::GetAppManifestURL(nsAString& aAppManifestURL)
{
uint32_t appId = nsIDocShell::GetAppId();
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
NS_ASSERTION(appsService, "No AppsService available");
appsService->GetManifestURLByLocalId(appId, aAppManifestURL);
} else {
aAppManifestURL.SetLength(0);
}
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut)
{
-2
View File
@@ -786,8 +786,6 @@ protected:
static const nsCString FrameTypeToString(uint32_t aFrameType)
{
switch (aFrameType) {
case FRAME_TYPE_APP:
return NS_LITERAL_CSTRING("app");
case FRAME_TYPE_BROWSER:
return NS_LITERAL_CSTRING("browser");
case FRAME_TYPE_REGULAR:
+13 -72
View File
@@ -827,109 +827,50 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[noscript] void notifyScrollObservers();
/**
* Returns true iff the docshell corresponds to an <iframe mozapp>.
*/
[infallible] readonly attribute boolean isApp;
/**
* The type of iframe that this docshell lives.
*/
const unsigned long FRAME_TYPE_REGULAR = 0;
const unsigned long FRAME_TYPE_BROWSER = 1;
const unsigned long FRAME_TYPE_APP = 2;
[infallible] attribute unsigned long frameType;
/**
* Returns true if this docshell corresponds to an <iframe mozbrowser> or
* <iframe mozapp>. <xul:browser> returns false here.
* Returns true if this docshell corresponds to an <iframe mozbrowser>.
* <xul:browser> returns false here.
*/
[infallible] readonly attribute boolean isMozBrowserOrApp;
[infallible] readonly attribute boolean isMozBrowser;
/**
* Returns true if this docshell corresponds to an isolated <iframe
* mozbrowser>.
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements. <iframe mozbrowser noisolation> does not count as
* isolated since isolation is disabled. Isolation can only be disabled if
* the containing document is chrome.
*/
[infallible] readonly attribute boolean isIsolatedMozBrowserElement;
/**
* Returns true if this docshell corresponds to an isolated <iframe
* mozbrowser> or if the docshell is contained in an isolated <iframe
* mozbrowser>.
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements. <iframe mozbrowser noisolation> does not count as
* isolated since isolation is disabled. Isolation can only be disabled if
* the containing document is chrome.
*
* Our notion here of "contained in" means: Walk up the docshell hierarchy in
* this process until we hit an <iframe mozapp> or <iframe mozbrowser> (or
* until the hierarchy ends). Return true iff the docshell we stopped on has
* isIsolatedMozBrowserElement == true.
*/
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
/**
* Returns true if this docshell corresponds to an <iframe mozbrowser> or
* <iframe mozapp>, or if this docshell is contained in an <iframe mozbrowser>
* or <iframe mozapp>. <xul:browser> returns false here.
* Returns true if this docshell corresponds to an <iframe mozbrowser>, or
* if this docshell is contained in an <iframe mozbrowser>. <xul:browser>
* returns false here.
*
* To compute this value, we walk up the docshell hierarchy. If we encounter
* a docshell with isMozBrowserOrApp before we hit the end of the hierarchy,
* a docshell with isMozBrowser before we hit the end of the hierarchy,
* we return true. Otherwise, we return false.
*/
[infallible] readonly attribute boolean isInMozBrowserOrApp;
[infallible] readonly attribute boolean isInMozBrowser;
/**
* Returns true if this docshell is the top level content docshell.
*/
[infallible] readonly attribute boolean isTopLevelContentDocShell;
/**
* Returns the id of the app associated with this docshell. If this docshell
* is an <iframe mozbrowser> inside an <iframe mozapp>, we return the app's
* appId.
*
* We compute this value by walking up the docshell hierarchy until we find a
* docshell on which origin attributes was set. (ignoring those docshells
* where x == UNKNOWN_APP_ID). We return the app id x.
*
* If we don't find a docshell with an associated app id in our hierarchy, we
* return NO_APP_ID. We never return UNKNOWN_APP_ID.
*
* Notice that a docshell may have an associated app even if it returns true
* for isBrowserElement!
*/
[infallible] readonly attribute unsigned long appId;
/**
* Return the manifest URL of the app associated with this docshell.
*
* If there is no associated app in our hierarchy, we return empty string.
*/
readonly attribute DOMString appManifestURL;
/**
* Like nsIDocShellTreeItem::GetSameTypeParent, except this ignores <iframe
* mozbrowser> and <iframe mozapp> boundaries.
* mozbrowser> boundaries.
*/
nsIDocShell getSameTypeParentIgnoreBrowserAndAppBoundaries();
nsIDocShell getSameTypeParentIgnoreBrowserBoundaries();
/**
* Like nsIDocShellTreeItem::GetSameTypeRootTreeItem, except this ignores
* <iframe mozbrowser> and <iframe mozapp> boundaries.
* <iframe mozbrowser> boundaries.
*/
nsIDocShell getSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries();
nsIDocShell getSameTypeRootTreeItemIgnoreBrowserBoundaries();
/**
* True iff asynchronous panning and zooming is enabled for this
* docshell.
* True if asynchronous panning and zooming is enabled for this docshell.
*/
readonly attribute bool asyncPanZoomEnabled;
+3 -4
View File
@@ -57,10 +57,9 @@ interface nsIDocShellTreeItem : nsISupports
/*
This getter returns the same thing parent does however if the parent
is of a different itemType, or if the parent is an <iframe mozbrowser>
or <iframe mozapp>, it will instead return nullptr. This call is a
convience function for those wishing to not cross the boundaries at
which item types change.
is of a different itemType, or if the parent is an <iframe mozbrowser>.
It will instead return nullptr. This call is a convience function for
Ithose wishing to not cross the boundaries at which item types change.
*/
readonly attribute nsIDocShellTreeItem sameTypeParent;
-15
View File
@@ -104,21 +104,6 @@ interface nsILoadContext : nsISupports
*/
[noscript] void SetRemoteTabs(in boolean aUseRemoteTabs);
/**
* Returns true iff the load is occurring inside an isolated mozbrowser
* element. <iframe mozbrowser mozapp> and <xul:browser> are not considered to
* be mozbrowser elements. <iframe mozbrowser noisolation> does not count as
* isolated since isolation is disabled. Isolation can only be disabled if
* the containing document is chrome.
*/
readonly attribute boolean isInIsolatedMozBrowserElement;
/**
* Returns the app id of the app the load is occurring is in. Returns
* nsIScriptSecurityManager::NO_APP_ID if the load is not part of an app.
*/
readonly attribute unsigned long appId;
/**
* A dictionary of the non-default origin attributes associated with this
* nsILoadContext.
-114
View File
@@ -1,114 +0,0 @@
/* 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/. */
"use strict"
function debug(s) {
//dump("-*- AppsService.js: " + s + "\n");
}
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
function AppsService()
{
debug("AppsService Constructor");
this.inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
debug("inParent: " + this.inParent);
if (!this.inParent) {
Cu.import("resource://gre/modules/AppsServiceChild.jsm");
}
}
AppsService.prototype = {
isInvalidId: function(localId) {
return (localId == Ci.nsIScriptSecurityManager.NO_APP_ID ||
localId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID);
},
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
debug("GetAppByManifestURL( " + aManifestURL + " )");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getManifestFor: function getManifestFor(aManifestURL) {
debug("getManifestFor(" + aManifestURL + ")");
if (this.inParent) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
} else {
return Promise.reject(
new Error("Calling getManifestFor() from child is not supported"));
}
},
getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
debug("getAppLocalIdByManifestURL( " + aManifestURL + " )");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getAppLocalIdByStoreId: function getAppLocalIdByStoreId(aStoreId) {
debug("getAppLocalIdByStoreId( " + aStoreId + " )");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getAppByLocalId: function getAppByLocalId(aLocalId) {
debug("getAppByLocalId( " + aLocalId + " )");
if (this.isInvalidId(aLocalId)) {
return null;
}
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
debug("getManifestURLByLocalId( " + aLocalId + " )");
if (this.isInvalidId(aLocalId)) {
return null;
}
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getCoreAppsBasePath: function getCoreAppsBasePath() {
debug("getCoreAppsBasePath()");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getWebAppsBasePath: function getWebAppsBasePath() {
debug("getWebAppsBasePath()");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
areAnyAppsInstalled: function() {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getAppInfo: function getAppInfo(aAppId) {
debug("getAppInfo()");
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
getScopeByLocalId: function(aLocalId) {
debug("getScopeByLocalId( " + aLocalId + " )");
if (this.isInvalidId(aLocalId)) {
return null;
}
// TODO : implement properly!
// We just return null for now to not break PushService.jsm
return null;
},
classID : APPS_SERVICE_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppsService])
-2
View File
@@ -1,2 +0,0 @@
component {05072afa-92fe-45bf-ae22-39b69c117058} AppsService.js
contract @mozilla.org/AppsService;1 {05072afa-92fe-45bf-ae22-39b69c117058}
-408
View File
@@ -1,408 +0,0 @@
/* 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/. */
"use strict";
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
// This module exposes a subset of the functionalities of the parent DOM
// Registry to content processes, to be used from the AppsService component.
this.EXPORTED_SYMBOLS = ["DOMApplicationRegistry", "WrappedManifestCache"];
Cu.import("resource://gre/modules/AppsUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function debug(s) {
//dump("-*- AppsServiceChild.jsm: " + s + "\n");
}
const APPS_IPC_MSG_NAMES = [
"Webapps:AddApp",
"Webapps:RemoveApp",
"Webapps:UpdateApp",
"Webapps:CheckForUpdate:Return:KO",
"Webapps:FireEvent",
"Webapps:UpdateState"
];
// A simple cache for the wrapped manifests.
this.WrappedManifestCache = {
_cache: { },
// Gets an entry from the cache, and populates the cache if needed.
get: function mcache_get(aManifestURL, aManifest, aWindow, aInnerWindowID) {
if (!aManifest) {
return;
}
if (!(aManifestURL in this._cache)) {
this._cache[aManifestURL] = { };
}
let winObjs = this._cache[aManifestURL];
if (!(aInnerWindowID in winObjs)) {
winObjs[aInnerWindowID] = Cu.cloneInto(aManifest, aWindow);
}
return winObjs[aInnerWindowID];
},
// Invalidates an entry in the cache.
evict: function mcache_evict(aManifestURL, aInnerWindowID) {
debug("Evicting manifest " + aManifestURL + " window ID " +
aInnerWindowID);
if (aManifestURL in this._cache) {
let winObjs = this._cache[aManifestURL];
if (aInnerWindowID in winObjs) {
delete winObjs[aInnerWindowID];
}
if (Object.keys(winObjs).length == 0) {
delete this._cache[aManifestURL];
}
}
},
observe: function(aSubject, aTopic, aData) {
// Clear the cache on memory pressure.
this._cache = { };
Cu.forceGC();
},
init: function() {
Services.obs.addObserver(this, "memory-pressure", false);
}
};
this.WrappedManifestCache.init();
// DOMApplicationRegistry keeps a cache containing a list of apps in the device.
// This information is updated with the data received from the main process and
// it is queried by the DOM objects to set their state.
// This module handle all the messages broadcasted from the parent process,
// including DOM events, which are dispatched to the corresponding DOM objects.
this.DOMApplicationRegistry = {
// DOMApps will hold a list of arrays of weak references to
// mozIDOMApplication objects indexed by manifest URL.
DOMApps: {},
ready: false,
webapps: null,
init: function init() {
this.cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsISyncMessageSender);
APPS_IPC_MSG_NAMES.forEach((function(aMsgName) {
this.cpmm.addMessageListener(aMsgName, this);
}).bind(this));
this.webapps = { };
// We need a fast mapping from localId -> app, so we add an index.
// We also add the manifest to the app object.
this.localIdIndex = { };
for (let id in this.webapps) {
let app = this.webapps[id];
this.localIdIndex[app.localId] = app;
app.manifest = list.manifests[id];
}
Services.obs.addObserver(this, "xpcom-shutdown", false);
},
observe: function(aSubject, aTopic, aData) {
// cpmm.addMessageListener causes the DOMApplicationRegistry object to
// live forever if we don't clean up properly.
this.webapps = null;
this.DOMApps = null;
APPS_IPC_MSG_NAMES.forEach((aMsgName) => {
this.cpmm.removeMessageListener(aMsgName, this);
});
},
receiveMessage: function receiveMessage(aMessage) {
debug("Received " + aMessage.name + " message.");
let msg = aMessage.data;
switch (aMessage.name) {
case "Webapps:AddApp":
this.webapps[msg.id] = msg.app;
this.localIdIndex[msg.app.localId] = msg.app;
if (msg.manifest) {
this.webapps[msg.id].manifest = msg.manifest;
}
break;
case "Webapps:RemoveApp":
delete this.DOMApps[this.webapps[msg.id].manifestURL];
delete this.localIdIndex[this.webapps[msg.id].localId];
delete this.webapps[msg.id];
break;
case "Webapps:UpdateApp":
let app = this.webapps[msg.oldId];
if (!app) {
return;
}
if (msg.app) {
for (let prop in msg.app) {
app[prop] = msg.app[prop];
}
}
this.webapps[msg.newId] = app;
this.localIdIndex[app.localId] = app;
delete this.webapps[msg.oldId];
let apps = this.DOMApps[msg.app.manifestURL];
if (!apps) {
return;
}
for (let i = 0; i < apps.length; i++) {
let domApp = apps[i].get();
if (!domApp || domApp._window === null) {
apps.splice(i, 1);
continue;
}
domApp._proxy = new Proxy(domApp, {
get: function(target, prop) {
if (!DOMApplicationRegistry.webapps[msg.newId]) {
return;
}
return DOMApplicationRegistry.webapps[msg.newId][prop];
},
set: function(target, prop, val) {
if (!DOMApplicationRegistry.webapps[msg.newId]) {
return;
}
DOMApplicationRegistry.webapps[msg.newId][prop] = val;
return;
},
});
}
break;
case "Webapps:FireEvent":
this._fireEvent(aMessage);
break;
case "Webapps:UpdateState":
this._updateState(msg);
break;
case "Webapps:CheckForUpdate:Return:KO":
let DOMApps = this.DOMApps[msg.manifestURL];
if (!DOMApps || !msg.requestID) {
return;
}
DOMApps.forEach((DOMApp) => {
let domApp = DOMApp.get();
if (domApp && msg.requestID) {
domApp._fireRequestResult(aMessage, true /* aIsError */);
}
});
break;
}
},
/**
* mozIDOMApplication management
*/
// Every time a DOM app is created, we save a weak reference to it that will
// be used to dispatch events and fire request results.
addDOMApp: function(aApp, aManifestURL, aId) {
let weakRef = Cu.getWeakReference(aApp);
if (!this.DOMApps[aManifestURL]) {
this.DOMApps[aManifestURL] = [];
}
let apps = this.DOMApps[aManifestURL];
// Get rid of dead weak references.
for (let i = 0; i < apps.length; i++) {
let app = apps[i].get();
if (!app || app._window === null) {
apps.splice(i, 1);
}
}
apps.push(weakRef);
// Each DOM app contains a proxy object used to build their state. We
// return the handler for this proxy object with traps to get and set
// app properties kept in the DOMApplicationRegistry app cache.
return {
get: function(target, prop) {
if (!DOMApplicationRegistry.webapps[aId]) {
return;
}
if (prop in DOMApplicationRegistry.webapps[aId]) {
return DOMApplicationRegistry.webapps[aId][prop];
}
return null;
},
set: function(target, prop, val) {
if (!DOMApplicationRegistry.webapps[aId]) {
return;
}
DOMApplicationRegistry.webapps[aId][prop] = val;
return;
},
};
},
_fireEvent: function(aMessage) {
let msg = aMessage.data;
debug("_fireEvent " + JSON.stringify(msg));
if (!this.DOMApps || !msg.manifestURL || !msg.eventType) {
return;
}
let DOMApps = this.DOMApps[msg.manifestURL];
if (!DOMApps) {
return;
}
// The parent might ask childs to trigger more than one event in one
// shot, so in order to avoid needless IPC we allow an array for the
// 'eventType' IPC message field.
if (!Array.isArray(msg.eventType)) {
msg.eventType = [msg.eventType];
}
DOMApps.forEach((DOMApp) => {
let domApp = DOMApp.get();
if (!domApp) {
return;
}
msg.eventType.forEach((aEventType) => {
if ('on' + aEventType in domApp) {
domApp._fireEvent(aEventType);
}
});
if (msg.requestID) {
aMessage.data.result = msg.manifestURL;
domApp._fireRequestResult(aMessage);
}
});
},
_updateState: function(aMessage) {
if (!this.DOMApps || !aMessage.id) {
return;
}
let app = this.webapps[aMessage.id];
if (!app) {
return;
}
if (aMessage.app) {
for (let prop in aMessage.app) {
app[prop] = aMessage.app[prop];
}
}
if ("error" in aMessage) {
app.downloadError = aMessage.error;
}
if (aMessage.manifest) {
app.manifest = aMessage.manifest;
// Evict the wrapped manifest cache for all the affected DOM objects.
let DOMApps = this.DOMApps[app.manifestURL];
if (!DOMApps) {
return;
}
DOMApps.forEach((DOMApp) => {
let domApp = DOMApp.get();
if (!domApp) {
return;
}
WrappedManifestCache.evict(app.manifestURL, domApp.innerWindowID);
});
}
},
getAll: function(aCallback) {
debug("getAll()\n");
if (!aCallback || typeof aCallback !== "function") {
return;
}
let res = [];
for (let id in this.webapps) {
res.push(this.webapps[id]);
}
aCallback(res);
},
getAdditionalLanguages: function(aManifestURL) {
for (let id in this.webapps) {
if (this.webapps[id].manifestURL == aManifestURL) {
return this.webapps[id].additionalLanguages || {};
}
}
return {};
},
/**
* nsIAppsService API
*/
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
debug("getAppByManifestURL " + aManifestURL);
return AppsUtils.getAppByManifestURL(this.webapps, aManifestURL);
},
getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
debug("getAppLocalIdByManifestURL " + aManifestURL);
return AppsUtils.getAppLocalIdByManifestURL(this.webapps, aManifestURL);
},
getAppLocalIdByStoreId: function(aStoreId) {
debug("getAppLocalIdByStoreId:" + aStoreId);
return AppsUtils.getAppLocalIdByStoreId(this.webapps, aStoreId);
},
getAppByLocalId: function getAppByLocalId(aLocalId) {
debug("getAppByLocalId " + aLocalId + " - ready: " + this.ready);
let app = this.localIdIndex[aLocalId];
if (!app) {
debug("Ouch, No app!");
return null;
}
return new mozIApplication(app);
},
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
debug("getManifestURLByLocalId " + aLocalId);
return AppsUtils.getManifestURLByLocalId(this.webapps, aLocalId);
},
getCoreAppsBasePath: function getCoreAppsBasePath() {
debug("getCoreAppsBasePath() not yet supported on child!");
return null;
},
getWebAppsBasePath: function getWebAppsBasePath() {
debug("getWebAppsBasePath() not yet supported on child!");
return null;
},
areAnyAppsInstalled: function() {
return AppsUtils.areAnyAppsInstalled(this.webapps);
},
getAppInfo: function getAppInfo(aAppId) {
return AppsUtils.getAppInfo(this.webapps, aAppId);
}
}
DOMApplicationRegistry.init();
+2 -81
View File
@@ -19,14 +19,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
"@mozilla.org/AppsService;1",
"nsIAppsService");
// Shared code for AppsServiceChild.jsm, Webapps.jsm and Webapps.js
// Shared code for Webapps.jsm and Webapps.js
this.EXPORTED_SYMBOLS =
["AppsUtils", "ManifestHelper", "isAbsoluteURI", "mozIApplication"];
["AppsUtils", "ManifestHelper", "isAbsoluteURI"];
function debug(s) {
//dump("-*- AppsUtils.jsm: " + s + "\n");
@@ -39,46 +35,6 @@ this.isAbsoluteURI = function(aURI) {
Services.io.newURI(aURI, null, bar).prePath != bar.prePath;
}
this.mozIApplication = function(aApp) {
_setAppProperties(this, aApp);
}
mozIApplication.prototype = {
hasPermission: function(aPermission) {
// This helper checks an URI inside |aApp|'s origin and part of |aApp| has a
// specific permission. It is not checking if browsers inside |aApp| have such
// permission.
let perm = Services.perms.testExactPermissionFromPrincipal(this.principal,
aPermission);
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
},
get principal() {
if (this._principal) {
return this._principal;
}
this._principal = null;
try {
this._principal = Services.scriptSecurityManager.createCodebasePrincipal(
Services.io.newURI(this.origin, null, null),
{appId: this.localId});
} catch(e) {
dump("Could not create app principal " + e + "\n");
}
return this._principal;
},
QueryInterface: function(aIID) {
if (aIID.equals(Ci.mozIApplication) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
function _setAppProperties(aObj, aApp) {
aObj.name = aApp.name;
aObj.csp = aApp.csp;
@@ -217,21 +173,6 @@ this.AppsUtils = {
return aPagePath.substr(pathPos, pathLen);
},
getAppByManifestURL: function getAppByManifestURL(aApps, aManifestURL) {
debug("getAppByManifestURL " + aManifestURL);
// This could be O(1) if |webapps| was a dictionary indexed on manifestURL
// which should be the unique app identifier.
// It's currently O(n).
for (let id in aApps) {
let app = aApps[id];
if (app.manifestURL == aManifestURL) {
return new mozIApplication(app);
}
}
return null;
},
getManifestFor: function getManifestFor(aManifestURL) {
debug("getManifestFor(" + aManifestURL + ")");
return DOMApplicationRegistry.getManifestFor(aManifestURL);
@@ -259,18 +200,6 @@ this.AppsUtils = {
return Ci.nsIScriptSecurityManager.NO_APP_ID;
},
getAppByLocalId: function getAppByLocalId(aApps, aLocalId) {
debug("getAppByLocalId " + aLocalId);
for (let id in aApps) {
let app = aApps[id];
if (app.localId == aLocalId) {
return new mozIApplication(app);
}
}
return null;
},
getManifestURLByLocalId: function getManifestURLByLocalId(aApps, aLocalId) {
debug("getManifestURLByLocalId " + aLocalId);
for (let id in aApps) {
@@ -697,14 +626,6 @@ this.AppsUtils = {
return this.computeHash(JSON.stringify(aObject));
},
getAppManifestURLFromWindow: function(aWindow) {
let appId = aWindow.document.nodePrincipal.appId;
if (appId === Ci.nsIScriptSecurityManager.NO_APP_ID) {
return null;
}
return appsService.getManifestURLByLocalId(appId);
},
}
/**
-5
View File
@@ -233,11 +233,6 @@ this.PermissionsTable = { geolocation: {
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"embed-apps": {
app: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"background-sensors": {
app: DENY_ACTION,
privileged: DENY_ACTION,
-6
View File
@@ -5,13 +5,7 @@
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
EXTRA_COMPONENTS += [
'AppsService.js',
'AppsService.manifest',
]
EXTRA_JS_MODULES += [
'AppsServiceChild.jsm',
'AppsUtils.jsm',
'PermissionsInstaller.jsm',
'PermissionsTable.jsm',
@@ -1,64 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource:///modules/AppsUtils.jsm");
add_test(() => {
let app = {
name: "TestApp",
csp: "aCsp",
installOrigin: "http://installorigin.com",
origin: "http://www.example.com",
installTime: Date.now(),
manifestURL: "http://www.example.com/manifest.webapp",
appStatus: Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED,
removable: false,
id: 123,
localId: 123,
basePath: "/",
progress: 1.0,
installState: "installed",
downloadAvailable: false,
downloading: false,
lastUpdateCheck: Date.now(),
updateTime: Date.now(),
etag: "aEtag",
packageEtag: "aPackageEtag",
manifestHash: "aManifestHash",
packageHash: "aPackageHash",
staged: false,
installerAppId: 345,
installerIsBrowser: false,
storeId: "aStoreId",
storeVersion: 1,
role: "aRole",
kind: "aKind",
enabled: true,
sideloaded: false
};
let mozapp = new mozIApplication(app);
Object.keys(app).forEach((key) => {
if (key == "principal") {
return;
}
Assert.equal(app[key], mozapp[key],
"app[" + key + "] should be equal to mozapp[" + key + "]");
});
Assert.ok(mozapp.principal, "app principal should exist");
let expectedPrincipalOrigin = app.origin + "^appId=" + app.localId;
Assert.equal(mozapp.principal.origin, expectedPrincipalOrigin,
"app principal origin ok");
Assert.equal(mozapp.principal.appId, app.localId, "app principal appId ok");
Assert.equal(mozapp.principal.isInIsolatedMozBrowserElement, false,
"app principal isInIsolatedMozBrowserElement ok");
run_next_test();
});
function run_test() {
run_next_test();
}
-1
View File
@@ -2,4 +2,3 @@
[test_manifestSanitizer.js]
[test_manifestHelper.js]
[test_moziapplication.js]
+40 -150
View File
@@ -30,7 +30,6 @@
#include "nsIAtom.h"
#include "nsIFile.h"
#include "nsIIPCBackgroundChildCreateCallback.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIRunnable.h"
#include "nsISimpleEnumerator.h"
@@ -443,11 +442,9 @@ public:
mPrincipalInfo(aPrincipalInfo),
mOpenMode(aOpenMode),
mWriteParams(aWriteParams),
mPersistence(quota::PERSISTENCE_TYPE_INVALID),
mState(eInitial),
mResult(JS::AsmJSCache_InternalError),
mIsApp(false),
mEnforcingQuota(true),
mDeleteReceived(false),
mActorDestroyed(false),
mOpened(false)
{
@@ -488,31 +485,6 @@ private:
MOZ_ASSERT(!IsOnOwningThread());
}
// This method is called on the owning thread when no cache entry was found
// to open. If we just tried a lookup in persistent storage then we might
// still get a hit in temporary storage (for an asm.js module that wasn't
// compiled at install-time).
void
CacheMiss()
{
AssertIsOnOwningThread();
MOZ_ASSERT(mState == eFailedToReadMetadata ||
mState == eWaitingToOpenCacheFileForRead);
MOZ_ASSERT(mOpenMode == eOpenForRead);
if (mPersistence == quota::PERSISTENCE_TYPE_TEMPORARY) {
Fail();
return;
}
// Try again with a clean slate. InitOnMainThread will see that mPersistence
// is initialized and switch to temporary storage.
MOZ_ASSERT(mPersistence == quota::PERSISTENCE_TYPE_PERSISTENT);
FinishOnOwningThread();
mState = eInitial;
NS_DispatchToMainThread(this);
}
// This method is called on the owning thread when the JS engine is finished
// reading/writing the cache entry.
void
@@ -542,7 +514,7 @@ private:
FinishOnOwningThread();
if (!mActorDestroyed) {
if (!mDeleteReceived && !mActorDestroyed) {
Unused << Send__delete__(this, mResult);
}
}
@@ -561,9 +533,6 @@ private:
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
}
void
InitPersistenceType();
nsresult
InitOnMainThread();
@@ -615,6 +584,10 @@ private:
AssertIsOnOwningThread();
MOZ_ASSERT(mState != eFinished);
MOZ_ASSERT(!mDeleteReceived);
mDeleteReceived = true;
if (mOpened) {
Close();
} else {
@@ -666,23 +639,12 @@ private:
return true;
}
bool
RecvCacheMiss() override
{
AssertIsOnOwningThread();
CacheMiss();
return true;
}
nsCOMPtr<nsIEventTarget> mOwningThread;
const PrincipalInfo mPrincipalInfo;
const OpenMode mOpenMode;
const WriteParams mWriteParams;
// State initialized during eInitial:
quota::PersistenceType mPersistence;
nsCString mSuffix;
nsCString mGroup;
nsCString mOrigin;
@@ -702,7 +664,6 @@ private:
eWaitingToOpenDirectory, // Waiting to open directory
eWaitingToOpenMetadata, // Waiting to be called back from OpenDirectory
eReadyToReadMetadata, // Waiting to read the metadata file on the IO thread
eFailedToReadMetadata, // Waiting to be dispatched to owning thread after fail
eSendingMetadataForRead, // Waiting to send OnOpenMetadataForRead
eWaitingToOpenCacheFileForRead, // Waiting to hear back from child
eReadyToOpenCacheFileForRead, // Waiting to open cache file for read
@@ -714,58 +675,11 @@ private:
State mState;
JS::AsmJSCacheResult mResult;
bool mIsApp;
bool mEnforcingQuota;
bool mDeleteReceived;
bool mActorDestroyed;
bool mOpened;
};
void
ParentRunnable::InitPersistenceType()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == eInitial);
if (mOpenMode == eOpenForWrite) {
MOZ_ASSERT(mPersistence == quota::PERSISTENCE_TYPE_INVALID);
// If we are performing install-time caching of an app, we'd like to store
// the cache entry in persistent storage so the entry is never evicted,
// but we need to check that quota is not enforced for the app.
// That justifies us in skipping all quota checks when storing the cache
// entry and avoids all the issues around the persistent quota prompt.
// If quota is enforced for the app, then we can still cache in temporary
// for a likely good first-run experience.
MOZ_ASSERT_IF(mWriteParams.mInstalled, mIsApp);
if (mWriteParams.mInstalled &&
!QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_PERSISTENT,
mOrigin, mIsApp)) {
mPersistence = quota::PERSISTENCE_TYPE_PERSISTENT;
} else {
mPersistence = quota::PERSISTENCE_TYPE_TEMPORARY;
}
return;
}
// For the reasons described above, apps may have cache entries in both
// persistent and temporary storage. At lookup time we don't know how and
// where the given script was cached, so start the search in persistent
// storage and, if that fails, search in temporary storage. (Non-apps can
// only be stored in temporary storage.)
MOZ_ASSERT_IF(mPersistence != quota::PERSISTENCE_TYPE_INVALID,
mIsApp && mPersistence == quota::PERSISTENCE_TYPE_PERSISTENT);
if (mPersistence == quota::PERSISTENCE_TYPE_INVALID && mIsApp) {
mPersistence = quota::PERSISTENCE_TYPE_PERSISTENT;
} else {
mPersistence = quota::PERSISTENCE_TYPE_TEMPORARY;
}
}
nsresult
ParentRunnable::InitOnMainThread()
{
@@ -780,15 +694,9 @@ ParentRunnable::InitOnMainThread()
return rv;
}
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup,
&mOrigin, &mIsApp);
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &mOrigin);
NS_ENSURE_SUCCESS(rv, rv);
InitPersistenceType();
mEnforcingQuota =
QuotaManager::IsQuotaEnforced(mPersistence, mOrigin, mIsApp);
return NS_OK;
}
@@ -803,10 +711,9 @@ ParentRunnable::OpenDirectory()
mState = eWaitingToOpenMetadata;
// XXX The exclusive lock shouldn't be needed for read operations.
QuotaManager::Get()->OpenDirectory(mPersistence,
QuotaManager::Get()->OpenDirectory(quota::PERSISTENCE_TYPE_TEMPORARY,
mGroup,
mOrigin,
mIsApp,
quota::Client::ASMJS,
/* aExclusive */ true,
this);
@@ -822,8 +729,11 @@ ParentRunnable::ReadMetadata()
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
nsresult rv =
qm->EnsureOriginIsInitialized(mPersistence, mSuffix, mGroup, mOrigin,
mIsApp, getter_AddRefs(mDirectory));
qm->EnsureOriginIsInitialized(quota::PERSISTENCE_TYPE_TEMPORARY,
mSuffix,
mGroup,
mOrigin,
getter_AddRefs(mDirectory));
if (NS_WARN_IF(NS_FAILED(rv))) {
mResult = JS::AsmJSCache_StorageInitFailure;
return rv;
@@ -894,25 +804,23 @@ ParentRunnable::OpenCacheFileForWrite()
QuotaManager* qm = QuotaManager::Get();
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
if (mEnforcingQuota) {
// Create the QuotaObject before all file IO and keep it alive until caching
// completes to get maximum assertion coverage in QuotaManager against
// concurrent removal, etc.
mQuotaObject = qm->GetQuotaObject(mPersistence, mGroup, mOrigin, file);
NS_ENSURE_STATE(mQuotaObject);
// Create the QuotaObject before all file IO and keep it alive until caching
// completes to get maximum assertion coverage in QuotaManager against
// concurrent removal, etc.
mQuotaObject = qm->GetQuotaObject(quota::PERSISTENCE_TYPE_TEMPORARY, mGroup, mOrigin, file);
NS_ENSURE_STATE(mQuotaObject);
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
/* aTruncate */ false)) {
// If the request fails, it might be because mOrigin is using too much
// space (MaybeUpdateSize will not evict our own origin since it is
// active). Try to make some space by evicting LRU entries until there is
// enough space.
EvictEntries(mDirectory, mGroup, mOrigin, mWriteParams.mSize, mMetadata);
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
/* aTruncate */ false)) {
// If the request fails, it might be because mOrigin is using too much
// space (MaybeUpdateSize will not evict our own origin since it is
// active). Try to make some space by evicting LRU entries until there is
// enough space.
EvictEntries(mDirectory, mGroup, mOrigin, mWriteParams.mSize, mMetadata);
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
/* aTruncate */ false)) {
mResult = JS::AsmJSCache_QuotaExceeded;
return NS_ERROR_FAILURE;
}
mResult = JS::AsmJSCache_QuotaExceeded;
return NS_ERROR_FAILURE;
}
}
@@ -948,13 +856,11 @@ ParentRunnable::OpenCacheFileForRead()
QuotaManager* qm = QuotaManager::Get();
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
if (mEnforcingQuota) {
// Even though it's not strictly necessary, create the QuotaObject before
// all file IO and keep it alive until caching completes to get maximum
// assertion coverage in QuotaManager against concurrent removal, etc.
mQuotaObject = qm->GetQuotaObject(mPersistence, mGroup, mOrigin, file);
NS_ENSURE_STATE(mQuotaObject);
}
// Even though it's not strictly necessary, create the QuotaObject before
// all file IO and keep it alive until caching completes to get maximum
// assertion coverage in QuotaManager against concurrent removal, etc.
mQuotaObject = qm->GetQuotaObject(quota::PERSISTENCE_TYPE_TEMPORARY, mGroup, mOrigin, file);
NS_ENSURE_STATE(mQuotaObject);
rv = file->GetFileSize(&mFileSize);
NS_ENSURE_SUCCESS(rv, rv);
@@ -1058,8 +964,7 @@ ParentRunnable::Run()
rv = ReadMetadata();
if (NS_FAILED(rv)) {
mState = eFailedToReadMetadata;
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
FailOnNonOwningThread();
return NS_OK;
}
@@ -1081,18 +986,6 @@ ParentRunnable::Run()
return NS_OK;
}
case eFailedToReadMetadata: {
AssertIsOnOwningThread();
if (mOpenMode == eOpenForRead) {
CacheMiss();
return NS_OK;
}
Fail();
return NS_OK;
}
case eSendingMetadataForRead: {
AssertIsOnOwningThread();
MOZ_ASSERT(mOpenMode == eOpenForRead);
@@ -1404,11 +1297,13 @@ private:
MOZ_ASSERT(mState == eOpening);
uint32_t moduleIndex;
if (FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
return SendSelectCacheFileToRead(moduleIndex);
if (!FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
Fail(JS::AsmJSCache_InternalError);
Send__delete__(this, JS::AsmJSCache_InternalError);
return true;
}
return SendCacheMiss();
return SendSelectCacheFileToRead(moduleIndex);
}
bool
@@ -1760,7 +1655,6 @@ CloseEntryForRead(size_t aSize,
JS::AsmJSCacheResult
OpenEntryForWrite(nsIPrincipal* aPrincipal,
bool aInstalled,
const char16_t* aBegin,
const char16_t* aEnd,
size_t aSize,
@@ -1777,7 +1671,6 @@ OpenEntryForWrite(nsIPrincipal* aPrincipal,
static_assert(sNumFastHashChars < sMinCachedModuleLength, "HashString safe");
WriteParams writeParams;
writeParams.mInstalled = aInstalled;
writeParams.mSize = aSize;
writeParams.mFastHash = HashString(aBegin, sNumFastHashChars);
writeParams.mNumChars = aEnd - aBegin;
@@ -2043,7 +1936,6 @@ ParamTraits<WriteParams>::Write(Message* aMsg, const paramType& aParam)
WriteParam(aMsg, aParam.mFastHash);
WriteParam(aMsg, aParam.mNumChars);
WriteParam(aMsg, aParam.mFullHash);
WriteParam(aMsg, aParam.mInstalled);
}
bool
@@ -2053,8 +1945,7 @@ ParamTraits<WriteParams>::Read(const Message* aMsg, PickleIterator* aIter,
return ReadParam(aMsg, aIter, &aResult->mSize) &&
ReadParam(aMsg, aIter, &aResult->mFastHash) &&
ReadParam(aMsg, aIter, &aResult->mNumChars) &&
ReadParam(aMsg, aIter, &aResult->mFullHash) &&
ReadParam(aMsg, aIter, &aResult->mInstalled);
ReadParam(aMsg, aIter, &aResult->mFullHash);
}
void
@@ -2064,7 +1955,6 @@ ParamTraits<WriteParams>::Log(const paramType& aParam, std::wstring* aLog)
LogParam(aParam.mFastHash, aLog);
LogParam(aParam.mNumChars, aLog);
LogParam(aParam.mFullHash, aLog);
LogParam(aParam.mInstalled, aLog);
}
} // namespace IPC
+6 -9
View File
@@ -72,14 +72,12 @@ struct WriteParams
int64_t mFastHash;
int64_t mNumChars;
int64_t mFullHash;
bool mInstalled;
WriteParams()
: mSize(0),
mFastHash(0),
mNumChars(0),
mFullHash(0),
mInstalled(false)
: mSize(0)
, mFastHash(0)
, mNumChars(0)
, mFullHash(0)
{ }
};
@@ -90,8 +88,8 @@ struct ReadParams
const char16_t* mLimit;
ReadParams()
: mBegin(nullptr),
mLimit(nullptr)
: mBegin(nullptr)
, mLimit(nullptr)
{ }
};
@@ -120,7 +118,6 @@ CloseEntryForRead(size_t aSize,
intptr_t aHandle);
JS::AsmJSCacheResult
OpenEntryForWrite(nsIPrincipal* aPrincipal,
bool aInstalled,
const char16_t* aBegin,
const char16_t* aEnd,
size_t aSize,
-1
View File
@@ -22,7 +22,6 @@ child:
async OnOpenMetadataForRead(Metadata metadata);
parent:
async SelectCacheFileToRead(uint32_t moduleIndex);
async CacheMiss();
child:
// Once the cache file has been opened, the child is notified and sent an
-2
View File
@@ -64,8 +64,6 @@
#include "nsIHttpChannelInternal.h"
#include "TimeManager.h"
#include "nsStreamUtils.h"
#include "nsIAppsService.h"
#include "mozIApplication.h"
#include "WidgetUtils.h"
#include "mozilla/dom/MediaDevices.h"
#include "MediaManager.h"
+2 -1
View File
@@ -17,6 +17,7 @@
#include "nsIURI.h"
#include "nsThreadUtils.h"
#include "mozilla/Logging.h"
#include "nsPIDOMWindow.h"
NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
@@ -145,7 +146,7 @@ ThirdPartyUtil::IsThirdPartyWindow(mozIDOMWindowProxy* aWindow,
nsCOMPtr<nsIURI> parentURI;
do {
// We use GetScriptableParent rather than GetParent because we consider
// <iframe mozbrowser/mozapp> to be a top-level frame.
// <iframe mozbrowser> to be a top-level frame.
parent = current->GetScriptableParent();
if (SameCOMIdentity(parent, current)) {
// We're at the topmost content window. We already know the answer.
+23 -5
View File
@@ -472,6 +472,7 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
nsAutoString media;
nsAutoString anchor;
nsAutoString crossOrigin;
nsAutoString referrerPolicy;
nsAutoString destination;
crossOrigin.SetIsVoid(true);
@@ -660,6 +661,15 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
destination = value;
destination.StripWhitespace();
}
} else if (attr.LowerCaseEqualsLiteral("referrerpolicy")) {
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#referrer-policy-attribute
// The spec says that the referrer policy attribute is an enumerated attribute,
// case insensitive and includes the empty string.
// We will parse the value with AttributeReferrerPolicyFromString
// later, which will handle parsing it as an enumerated attribute.
if (referrerPolicy.IsEmpty()) {
referrerPolicy = value;
}
}
}
}
@@ -673,7 +683,7 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
rv = ProcessLink(anchor, href, rel,
// prefer RFC 5987 variant over non-I18zed version
titleStar.IsEmpty() ? title : titleStar,
type, media, crossOrigin, destination);
type, media, crossOrigin, referrerPolicy, destination);
}
href.Truncate();
@@ -682,6 +692,7 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
type.Truncate();
media.Truncate();
anchor.Truncate();
referrerPolicy.Truncate();
crossOrigin.SetIsVoid(true);
destination.Truncate();
@@ -696,7 +707,7 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
rv = ProcessLink(anchor, href, rel,
// prefer RFC 5987 variant over non-I18zed version
titleStar.IsEmpty() ? title : titleStar,
type, media, crossOrigin, destination);
type, media, crossOrigin, referrerPolicy, destination);
}
return rv;
@@ -708,6 +719,7 @@ nsContentSink::ProcessLink(const nsSubstring& aAnchor, const nsSubstring& aHref,
const nsSubstring& aRel, const nsSubstring& aTitle,
const nsSubstring& aType, const nsSubstring& aMedia,
const nsSubstring& aCrossOrigin,
const nsAString& aReferrerPolicy,
const nsSubstring& aDestination)
{
uint32_t linkTypes =
@@ -749,7 +761,7 @@ nsContentSink::ProcessLink(const nsSubstring& aAnchor, const nsSubstring& aHref,
bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;
return ProcessStyleLink(nullptr, aHref, isAlternate, aTitle, aType,
aMedia);
aMedia, aReferrerPolicy);
}
nsresult
@@ -758,7 +770,8 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
bool aAlternate,
const nsSubstring& aTitle,
const nsSubstring& aType,
const nsSubstring& aMedia)
const nsSubstring& aMedia,
const nsSubstring& aReferrerPolicy)
{
if (aAlternate && aTitle.IsEmpty()) {
// alternates must have title return without error, for now
@@ -797,13 +810,18 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
("nsContentSink::ProcessStyleLink, integrity=%s",
NS_ConvertUTF16toUTF8(integrity).get()));
}
mozilla::net::ReferrerPolicy referrerPolicy =
mozilla::net::AttributeReferrerPolicyFromString(aReferrerPolicy);
if (referrerPolicy == net::RP_Unset) {
referrerPolicy = mDocument->GetReferrerPolicy();
}
// If this is a fragment parser, we don't want to observe.
// We don't support CORS for processing instructions
bool isAlternate;
bool isExplicitlyEnabled;
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
CORS_NONE, mDocument->GetReferrerPolicy(),
CORS_NONE, referrerPolicy,
integrity, mRunsToCompletion ? nullptr : this,
&isAlternate, &isExplicitlyEnabled);
NS_ENSURE_SUCCESS(rv, rv);
+3 -1
View File
@@ -154,6 +154,7 @@ protected:
const nsSubstring& aHref, const nsSubstring& aRel,
const nsSubstring& aTitle, const nsSubstring& aType,
const nsSubstring& aMedia, const nsSubstring& aCrossOrigin,
const nsSubstring& aReferrerPolicy,
const nsSubstring& aDestination);
virtual nsresult ProcessStyleLink(nsIContent* aElement,
@@ -161,7 +162,8 @@ protected:
bool aAlternate,
const nsSubstring& aTitle,
const nsSubstring& aType,
const nsSubstring& aMedia);
const nsSubstring& aMedia,
const nsSubstring& aReferrerPolicy);
void PrefetchOrPreloadHref(const nsAString &aHref,
nsINode *aSource,
+3 -5
View File
@@ -6616,7 +6616,7 @@ nsContentUtils::IsUserFocusIgnored(nsINode* aNode)
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aNode);
if (browserFrame &&
aNode->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::ignoreuserfocus) &&
browserFrame->GetReallyIsBrowserOrApp()) {
browserFrame->GetReallyIsBrowser()) {
return true;
}
nsPIDOMWindowOuter* win = aNode->OwnerDoc()->GetWindow();
@@ -8868,10 +8868,8 @@ nsContentUtils::SetFetchReferrerURIWithPolicy(nsIPrincipal* aPrincipal,
referrerURI = principalURI;
}
net::ReferrerPolicy referrerPolicy = aReferrerPolicy;
if (referrerPolicy == net::RP_Default) {
referrerPolicy = aDoc->GetReferrerPolicy();
}
net::ReferrerPolicy referrerPolicy = (aReferrerPolicy != net::RP_Unset) ?
aReferrerPolicy : net::RP_Default;
return aChannel->SetReferrerWithPolicy(referrerURI, referrerPolicy);
}
+1 -2
View File
@@ -3026,8 +3026,7 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId,
nsCString origin;
nsresult rv =
quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin,
nullptr);
quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin);
NS_ENSURE_SUCCESS(rv, rv);
IDBOpenDBOptions options;
+23 -164
View File
@@ -12,9 +12,7 @@
#include "prenv.h"
#include "mozIApplication.h"
#include "nsDocShell.h"
#include "nsIAppsService.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMMozBrowserFrame.h"
@@ -90,7 +88,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "nsIAppsService.h"
#include "GeckoProfiler.h"
#include "jsapi.h"
@@ -1071,12 +1068,6 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
return NS_ERROR_NOT_IMPLEMENTED;
}
if (mRemoteBrowser->IsIsolatedMozBrowserElement() !=
aOther->mRemoteBrowser->IsIsolatedMozBrowserElement() ||
mRemoteBrowser->HasOwnApp() != aOther->mRemoteBrowser->HasOwnApp()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// When we swap docShells, maybe we have to deal with a new page created just
// for this operation. In this case, the browser code should already have set
// the correct userContextId attribute value in the owning XULElement, but our
@@ -1145,10 +1136,10 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
}
// Destroy browser frame scripts for content leaving a frame with browser API
if (OwnerIsMozBrowserOrAppFrame() && !aOther->OwnerIsMozBrowserOrAppFrame()) {
if (OwnerIsMozBrowserFrame() && !aOther->OwnerIsMozBrowserFrame()) {
DestroyBrowserFrameScripts();
}
if (!OwnerIsMozBrowserOrAppFrame() && aOther->OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame() && aOther->OwnerIsMozBrowserFrame()) {
aOther->DestroyBrowserFrameScripts();
}
@@ -1322,12 +1313,12 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
bool ourFullscreenAllowed =
ourContent->IsXULElement() ||
(OwnerIsMozBrowserOrAppFrame() &&
(OwnerIsMozBrowserFrame() &&
(ourContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
ourContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)));
bool otherFullscreenAllowed =
otherContent->IsXULElement() ||
(aOther->OwnerIsMozBrowserOrAppFrame() &&
(aOther->OwnerIsMozBrowserFrame() &&
(otherContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
otherContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)));
if (ourFullscreenAllowed != otherFullscreenAllowed) {
@@ -1472,12 +1463,6 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
return NS_ERROR_NOT_IMPLEMENTED;
}
if (ourDocshell->GetIsIsolatedMozBrowserElement() !=
otherDocshell->GetIsIsolatedMozBrowserElement() ||
ourDocshell->GetIsApp() != otherDocshell->GetIsApp()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// When we swap docShells, maybe we have to deal with a new page created just
// for this operation. In this case, the browser code should already have set
// the correct userContextId attribute value in the owning XULElement, but our
@@ -1524,10 +1509,10 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
}
// Destroy browser frame scripts for content leaving a frame with browser API
if (OwnerIsMozBrowserOrAppFrame() && !aOther->OwnerIsMozBrowserOrAppFrame()) {
if (OwnerIsMozBrowserFrame() && !aOther->OwnerIsMozBrowserFrame()) {
DestroyBrowserFrameScripts();
}
if (!OwnerIsMozBrowserOrAppFrame() && aOther->OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame() && aOther->OwnerIsMozBrowserFrame()) {
aOther->DestroyBrowserFrameScripts();
}
@@ -1886,102 +1871,20 @@ nsFrameLoader::SetOwnerContent(Element* aContent)
}
bool
nsFrameLoader::OwnerIsMozBrowserOrAppFrame()
nsFrameLoader::OwnerIsMozBrowserFrame()
{
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
return browserFrame ? browserFrame->GetReallyIsBrowserOrApp() : false;
return browserFrame ? browserFrame->GetReallyIsBrowser() : false;
}
// The xpcom getter version
NS_IMETHODIMP
nsFrameLoader::GetOwnerIsMozBrowserOrAppFrame(bool* aResult)
nsFrameLoader::GetOwnerIsMozBrowserFrame(bool* aResult)
{
*aResult = OwnerIsMozBrowserOrAppFrame();
*aResult = OwnerIsMozBrowserFrame();
return NS_OK;
}
bool
nsFrameLoader::OwnerIsAppFrame()
{
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
return browserFrame ? browserFrame->GetReallyIsApp() : false;
}
bool
nsFrameLoader::OwnerIsMozBrowserFrame()
{
return OwnerIsMozBrowserOrAppFrame() && !OwnerIsAppFrame();
}
bool
nsFrameLoader::OwnerIsIsolatedMozBrowserFrame()
{
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
if (!browserFrame) {
return false;
}
if (!OwnerIsMozBrowserFrame()) {
return false;
}
bool isolated = browserFrame->GetIsolated();
if (isolated) {
return true;
}
return false;
}
void
nsFrameLoader::GetOwnerAppManifestURL(nsAString& aOut)
{
aOut.Truncate();
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
if (browserFrame) {
browserFrame->GetAppManifestURL(aOut);
}
}
already_AddRefed<mozIApplication>
nsFrameLoader::GetOwnApp()
{
nsAutoString manifest;
GetOwnerAppManifestURL(manifest);
if (manifest.IsEmpty()) {
return nullptr;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(appsService, nullptr);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(manifest, getter_AddRefs(app));
return app.forget();
}
already_AddRefed<mozIApplication>
nsFrameLoader::GetContainingApp()
{
// See if our owner content's principal has an associated app.
uint32_t appId = mOwnerContent->NodePrincipal()->GetAppId();
MOZ_ASSERT(appId != nsIScriptSecurityManager::UNKNOWN_APP_ID);
if (appId == nsIScriptSecurityManager::NO_APP_ID ||
appId == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
return nullptr;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(appsService, nullptr);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByLocalId(appId, getter_AddRefs(app));
return app.forget();
}
bool
nsFrameLoader::ShouldUseRemoteProcess()
{
@@ -2005,7 +1908,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
// If we're an <iframe mozbrowser> and we don't have a "remote" attribute,
// fall back to the default.
if (OwnerIsMozBrowserOrAppFrame() &&
if (OwnerIsMozBrowserFrame() &&
!mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::Remote)) {
return Preferences::GetBool("dom.ipc.browser_frames.oop_by_default", false);
@@ -2013,7 +1916,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
// Otherwise, we're remote if we have "remote=true" and we're either a
// browser frame or a XUL element.
return (OwnerIsMozBrowserOrAppFrame() ||
return (OwnerIsMozBrowserFrame() ||
mOwnerContent->GetNameSpaceID() == kNameSpaceID_XUL) &&
mOwnerContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::Remote,
@@ -2191,13 +2094,13 @@ nsFrameLoader::MaybeCreateDocShell()
// Inherit origin attributes from parent document if
// 1. It's in a content docshell.
// 2. its nodePrincipal is not a SystemPrincipal.
// 3. It's not a mozbrowser nor mozapp frame.
// 3. It's not a mozbrowser frame.
//
// For example, firstPartyDomain is computed from top-level document, it
// doesn't exist in the top-level docshell.
if (parentType == nsIDocShellTreeItem::typeContent &&
!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) &&
!OwnerIsMozBrowserOrAppFrame()) {
!OwnerIsMozBrowserFrame()) {
PrincipalOriginAttributes poa = BasePrincipal::Cast(doc->NodePrincipal())->OriginAttributesRef();
// Assert on the firstPartyDomain from top-level docshell should be empty
@@ -2212,42 +2115,14 @@ nsFrameLoader::MaybeCreateDocShell()
"docshell and document should have the same appId attribute.");
MOZ_ASSERT(attrs.mUserContextId == poa.mUserContextId,
"docshell and document should have the same userContextId attribute.");
MOZ_ASSERT(attrs.mInIsolatedMozBrowser == poa.mInIsolatedMozBrowser,
"docshell and document should have the same inIsolatedMozBrowser attribute.");
MOZ_ASSERT(attrs.mPrivateBrowsingId == poa.mPrivateBrowsingId,
"docshell and document should have the same privateBrowsingId attribute.");
attrs.InheritFromDocToChildDocShell(poa);
}
if (OwnerIsAppFrame()) {
// You can't be both an app and a browser frame.
MOZ_ASSERT(!OwnerIsMozBrowserFrame());
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
MOZ_ASSERT(ownApp);
uint32_t ownAppId = nsIScriptSecurityManager::NO_APP_ID;
if (ownApp) {
NS_ENSURE_SUCCESS(ownApp->GetLocalId(&ownAppId), NS_ERROR_FAILURE);
}
attrs.mAppId = ownAppId;
mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_APP);
}
if (OwnerIsMozBrowserFrame()) {
// You can't be both a browser and an app frame.
MOZ_ASSERT(!OwnerIsAppFrame());
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
uint32_t containingAppId = nsIScriptSecurityManager::NO_APP_ID;
if (containingApp) {
NS_ENSURE_SUCCESS(containingApp->GetLocalId(&containingAppId),
NS_ERROR_FAILURE);
}
attrs.mAppId = containingAppId;
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
}
@@ -2278,7 +2153,7 @@ nsFrameLoader::MaybeCreateDocShell()
}
attrs.SyncAttributesWithPrivateBrowsing(isPrivate);
if (OwnerIsMozBrowserOrAppFrame()) {
if (OwnerIsMozBrowserFrame()) {
// For inproc frames, set the docshell properties.
nsAutoString name;
if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
@@ -2677,7 +2552,7 @@ nsFrameLoader::TryRemoteBrowser()
}
// <iframe mozbrowser> gets to skip these checks.
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
if (parentDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
return false;
}
@@ -2718,8 +2593,8 @@ nsFrameLoader::TryRemoteBrowser()
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<Element> ownerElement = mOwnerContent;
mRemoteBrowser = ContentParent::CreateBrowserOrApp(context, ownerElement,
openerContentParent, mFreshProcess);
mRemoteBrowser = ContentParent::CreateBrowser(context, ownerElement,
openerContentParent, mFreshProcess);
if (!mRemoteBrowser) {
return false;
}
@@ -2982,7 +2857,7 @@ nsFrameLoader::EnsureMessageManager()
}
if (!mIsTopLevelContent &&
!OwnerIsMozBrowserOrAppFrame() &&
!OwnerIsMozBrowserFrame() &&
!IsRemoteFrame() &&
!(mOwnerContent->IsXULElement() &&
mOwnerContent->AttrValueIs(kNameSpaceID_None,
@@ -3287,7 +3162,7 @@ nsFrameLoader::GetLoadContext(nsILoadContext** aLoadContext)
void
nsFrameLoader::InitializeBrowserAPI()
{
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
return;
}
if (!IsRemoteFrame()) {
@@ -3311,7 +3186,7 @@ nsFrameLoader::InitializeBrowserAPI()
void
nsFrameLoader::DestroyBrowserFrameScripts()
{
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
return;
}
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
@@ -3392,24 +3267,10 @@ nsresult
nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
nsIURI* aURI)
{
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
DocShellOriginAttributes attrs;
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
nsresult rv;
// Get the AppId from ownApp
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
if (ownApp) {
rv = ownApp->GetLocalId(&appId);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(appId != nsIScriptSecurityManager::NO_APP_ID);
} else if (containingApp) {
rv = containingApp->GetLocalId(&appId);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(appId != nsIScriptSecurityManager::NO_APP_ID);
}
attrs.mAppId = appId;
attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID; // No longer used...
// set the userContextId on the attrs before we pass them into
// the tab context
@@ -3439,8 +3300,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
bool tabContextUpdated =
aTabContext->SetTabContext(OwnerIsMozBrowserFrame(),
mIsPrerendered,
ownApp,
containingApp,
showAccelerators,
showFocusRings,
attrs);
-35
View File
@@ -241,53 +241,18 @@ private:
*/
bool IsRemoteFrame();
/**
* Is this a frameloader for a bona fide <iframe mozbrowser> or
* <iframe mozapp>? (I.e., does the frame return true for
* nsIMozBrowserFrame::GetReallyIsBrowserOrApp()?)
* <xul:browser> is not a mozbrowser or app, so this is false for that case.
*/
bool OwnerIsMozBrowserOrAppFrame();
/**
* Is this a frameloader for a bona fide <iframe mozapp>? (I.e., does the
* frame return true for nsIMozBrowserFrame::GetReallyIsApp()?)
*/
bool OwnerIsAppFrame();
/**
* Is this a frame loader for a bona fide <iframe mozbrowser>?
* <xul:browser> is not a mozbrowser, so this is false for that case.
*/
bool OwnerIsMozBrowserFrame();
/**
* Is this a frame loader for an isolated <iframe mozbrowser>?
*
* By default, mozbrowser frames are isolated. Isolation can be disabled by
* setting the frame's noisolation attribute. Disabling isolation is
* only allowed if the containing document is chrome.
*/
bool OwnerIsIsolatedMozBrowserFrame();
/**
* Get our owning element's app manifest URL, or return the empty string if
* our owning element doesn't have an app manifest URL.
*/
void GetOwnerAppManifestURL(nsAString& aOut);
/**
* Get the app for our frame. This is the app whose manifest is returned by
* GetOwnerAppManifestURL.
*/
already_AddRefed<mozIApplication> GetOwnApp();
/**
* Get the app which contains this frame. This is the app associated with
* the frame element's principal.
*/
already_AddRefed<mozIApplication> GetContainingApp();
/**
* If we are an IPC frame, set mRemoteFrame. Otherwise, create and
* initialize mDocShell.
-3
View File
@@ -101,7 +101,6 @@ GK_ATOM(animations, "animations")
GK_ATOM(anonid, "anonid")
GK_ATOM(anonlocation, "anonlocation")
GK_ATOM(any, "any")
GK_ATOM(mozapp, "mozapp")
GK_ATOM(applet, "applet")
GK_ATOM(applyImports, "apply-imports")
GK_ATOM(applyTemplates, "apply-templates")
@@ -664,7 +663,6 @@ GK_ATOM(nodeSet, "node-set")
GK_ATOM(noembed, "noembed")
GK_ATOM(noframes, "noframes")
GK_ATOM(nohref, "nohref")
GK_ATOM(noisolation, "noisolation")
GK_ATOM(nomodule, "nomodule")
GK_ATOM(nonce, "nonce")
GK_ATOM(none, "none")
@@ -1002,7 +1000,6 @@ GK_ATOM(panel, "panel")
GK_ATOM(param, "param")
GK_ATOM(parameter, "parameter")
GK_ATOM(parent, "parent")
GK_ATOM(parentapp, "parentapp")
GK_ATOM(parentfocused, "parentfocused")
GK_ATOM(parsetype, "parsetype")
GK_ATOM(password, "password")
+13 -16
View File
@@ -2300,13 +2300,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
#ifdef DEBUG
void
nsGlobalWindow::RiskyUnlink()
{
NS_CYCLE_COLLECTION_INNERNAME.Unlink(this);
}
#endif
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsGlobalWindow)
if (tmp->mCachedXBLPrototypeHandlers) {
@@ -4485,7 +4483,7 @@ nsGlobalWindow::GetParentOuter()
}
nsCOMPtr<nsPIDOMWindowOuter> parent;
if (mDocShell->GetIsMozBrowserOrApp()) {
if (mDocShell->GetIsMozBrowser()) {
parent = AsOuter();
} else {
parent = GetParent();
@@ -4543,7 +4541,7 @@ nsGlobalWindow::GetParent()
}
nsCOMPtr<nsIDocShell> parent;
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsPIDOMWindowOuter> win = parent->GetWindow();
@@ -4662,9 +4660,9 @@ nsGlobalWindow::GetContentInternal(ErrorResult& aError, bool aUnprivilegedCaller
return domWindow.forget();
}
// If we're contained in <iframe mozbrowser> or <iframe mozapp>, then
// GetContent is the same as window.top.
if (mDocShell && mDocShell->GetIsInMozBrowserOrApp()) {
// If we're contained in <iframe mozbrowser>, then GetContent is the same as
// window.top.
if (mDocShell && mDocShell->GetIsInMozBrowser()) {
return GetTopOuter();
}
@@ -7988,7 +7986,7 @@ nsGlobalWindow::ResizeToOuter(int32_t aWidth, int32_t aHeight, ErrorResult& aErr
* If caller is a browser-element then dispatch a resize event to
* the embedder.
*/
if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
if (mDocShell && mDocShell->GetIsMozBrowser()) {
CSSIntSize size(aWidth, aHeight);
if (!DispatchResizeEvent(size)) {
// The embedder chose to prevent the default action for this
@@ -8038,7 +8036,7 @@ nsGlobalWindow::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
* If caller is a browser-element then dispatch a resize event to
* parent.
*/
if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
if (mDocShell && mDocShell->GetIsMozBrowser()) {
CSSIntSize size;
if (NS_FAILED(GetInnerSize(size))) {
return;
@@ -9009,7 +9007,7 @@ nsGlobalWindow::CloseOuter(bool aTrustedCaller)
MOZ_RELEASE_ASSERT(IsOuterWindow());
if (!mDocShell || IsInModalState() ||
(IsFrame() && !mDocShell->GetIsMozBrowserOrApp())) {
(IsFrame() && !mDocShell->GetIsMozBrowser())) {
// window.close() is called on a frame in a frameset, on a window
// that's already closed, or on a window for which there's
// currently a modal dialog open. Ignore such calls.
@@ -9030,14 +9028,13 @@ nsGlobalWindow::CloseOuter(bool aTrustedCaller)
return;
}
// Don't allow scripts from content to close non-app or non-neterror
// windows that were not opened by script.
// Don't allow scripts from content to close non-neterror windows that
// were not opened by script.
nsAutoString url;
nsresult rv = mDoc->GetURL(url);
NS_ENSURE_SUCCESS_VOID(rv);
if (!mDocShell->GetIsApp() &&
!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
!mHadOriginalOpener && !aTrustedCaller) {
bool allowClose = mAllowScriptsToClose ||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
@@ -9485,7 +9482,7 @@ nsGlobalWindow::GetFrameElementOuter(nsIPrincipal& aSubjectPrincipal)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
if (!mDocShell || mDocShell->GetIsMozBrowserOrApp()) {
if (!mDocShell || mDocShell->GetIsMozBrowser()) {
return nullptr;
}
@@ -9520,7 +9517,7 @@ nsGlobalWindow::GetRealFrameElementOuter()
}
nsCOMPtr<nsIDocShell> parent;
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
if (!parent || parent == mDocShell) {
// We're at a chrome boundary, don't expose the chrome iframe
-2
View File
@@ -597,11 +597,9 @@ public:
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindow,
nsIDOMEventTarget)
#ifdef DEBUG
// Call Unlink on this window. This may cause bad things to happen, so use
// with caution.
void RiskyUnlink();
#endif
virtual JSObject*
GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) override;
+3 -11
View File
@@ -5,7 +5,6 @@
#include "nsISupports.idl"
interface mozIApplication;
interface nsFrameLoader;
interface nsIDocShell;
interface nsIURI;
@@ -216,11 +215,10 @@ interface nsIFrameLoader : nsISupports
[infallible] attribute boolean visible;
/**
* Find out whether the owner content really is a mozbrowser or app frame
* Especially, a widget frame is regarded as an app frame. <xul:browser> is
* not considered to be a mozbrowser frame.
* Find out whether the owner content really is a mozbrowser. <xul:browser>
* is not considered to be a mozbrowser frame.
*/
readonly attribute boolean ownerIsMozBrowserOrAppFrame;
readonly attribute boolean ownerIsMozBrowserFrame;
/**
* The last known width of the frame. Reading this property will not trigger
@@ -265,12 +263,6 @@ interface nsIFrameLoaderOwner : nsISupports
[binaryname(FrameLoaderXPCOM)] readonly attribute nsIFrameLoader frameLoader;
[noscript, notxpcom] alreadyAddRefed_nsFrameLoader GetFrameLoader();
/**
* The principal of parent mozIApplication in case of nested mozbrowser
* iframes.
*/
readonly attribute mozIApplication parentApplication;
/**
* Puts the FrameLoaderOwner in prerendering mode.
*/
+10 -7
View File
@@ -88,21 +88,24 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
nsIContent* aOwner,
nsFrameMessageManager* aChrome)
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
mPreventEventsEscaping(false),
mOwner(aOwner), mChromeMessageManager(aChrome)
: mDocShell(aShell)
, mInitialized(false)
, mLoadingScript(false)
, mPreventEventsEscaping(false)
, mOwner(aOwner)
, mChromeMessageManager(aChrome)
{
SetIsNotDOMBinding();
mozilla::HoldJSObjects(this);
// If owner corresponds to an <iframe mozbrowser> or <iframe mozapp>, we'll
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
// GetEventTargetParent implementation.
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwner);
if (browserFrame) {
mIsBrowserOrAppFrame = browserFrame->GetReallyIsBrowserOrApp();
mIsBrowserFrame = browserFrame->GetReallyIsBrowser();
}
else {
mIsBrowserOrAppFrame = false;
mIsBrowserFrame = false;
}
}
@@ -272,7 +275,7 @@ nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
return NS_OK;
}
if (mIsBrowserOrAppFrame &&
if (mIsBrowserFrame &&
(!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
if (mOwner) {
if (nsPIDOMWindowInner* innerWindow = mOwner->OwnerDoc()->GetInnerWindow()) {
+3 -4
View File
@@ -165,10 +165,9 @@ protected:
bool mInitialized;
bool mLoadingScript;
// Is this the message manager for an in-process <iframe mozbrowser> or
// <iframe mozapp>? This affects where events get sent, so it affects
// GetEventTargetParent.
bool mIsBrowserOrAppFrame;
// Is this the message manager for an in-process <iframe mozbrowser>? This
// affects where events get sent, so it affects GetEventTargetParent.
bool mIsBrowserFrame;
bool mPreventEventsEscaping;
// We keep a strong reference to the frameloader after we've started
+1 -3
View File
@@ -2265,7 +2265,6 @@ AsmJSCacheOpenEntryForRead(JS::Handle<JSObject*> aGlobal,
static JS::AsmJSCacheResult
AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
bool aInstalled,
const char16_t* aBegin,
const char16_t* aEnd,
size_t aSize,
@@ -2274,8 +2273,7 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
{
nsIPrincipal* principal =
nsJSPrincipals::get(JS_GetCompartmentPrincipals(js::GetObjectCompartment(aGlobal)));
return asmjscache::OpenEntryForWrite(principal, aInstalled, aBegin, aEnd,
aSize, aMemory, aHandle);
return asmjscache::OpenEntryForWrite(principal, aBegin, aEnd, aSize, aMemory, aHandle);
}
class AsyncTaskRunnable final : public Runnable
-11
View File
@@ -1253,17 +1253,6 @@ nsObjectLoadingContent::GetFrameLoader()
return loader.forget();
}
NS_IMETHODIMP
nsObjectLoadingContent::GetParentApplication(mozIApplication** aApplication)
{
if (!aApplication) {
return NS_ERROR_FAILURE;
}
*aApplication = nullptr;
return NS_OK;
}
void
nsObjectLoadingContent::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, mozilla::ErrorResult& aRv)
{
+11 -10
View File
@@ -411,6 +411,16 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
bool doneLoading = false;
nsresult rv = NS_OK;
// Load the link's referrerpolicy attribute. If the link does not provide a
// referrerpolicy attribute, ignore this and use the document's referrer
// policy
net::ReferrerPolicy referrerPolicy = GetLinkReferrerPolicy();
if (referrerPolicy == net::RP_Unset) {
referrerPolicy = doc->GetReferrerPolicy();
}
if (isInline) {
nsAutoString text;
if (!nsContentUtils::GetNodeTextContent(thisContent, false, text, fallible)) {
@@ -429,7 +439,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
// Parse the style sheet.
rv = doc->CSSLoader()->
LoadInlineStyle(thisContent, text, mLineNumber, title, media,
LoadInlineStyle(thisContent, text, mLineNumber, title, media, referrerPolicy,
scopeElement, aObserver, &doneLoading, &isAlternate, &isExplicitlyEnabled);
} else {
nsAutoString integrity;
@@ -440,15 +450,6 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
NS_ConvertUTF16toUTF8(integrity).get()));
}
// if referrer attributes are enabled in preferences, load the link's referrer
// attribute. If the link does not provide a referrer attribute, ignore this
// and use the document's referrer policy
net::ReferrerPolicy referrerPolicy = GetLinkReferrerPolicy();
if (referrerPolicy == net::RP_Unset) {
referrerPolicy = doc->GetReferrerPolicy();
}
// XXXbz clone the URI here to work around content policies modifying URIs.
nsCOMPtr<nsIURI> clonedURI;
uri->Clone(getter_AddRefs(clonedURI));
-2
View File
@@ -829,7 +829,6 @@ nsWindowMemoryReporter::KillCheckTimer()
}
}
#ifdef DEBUG
/* static */ void
nsWindowMemoryReporter::UnlinkGhostWindows()
{
@@ -866,4 +865,3 @@ nsWindowMemoryReporter::UnlinkGhostWindows()
}
}
}
#endif
-2
View File
@@ -150,13 +150,11 @@ public:
static void Init();
#ifdef DEBUG
/**
* Unlink all known ghost windows, to enable investigating what caused them
* to become ghost windows in the first place.
*/
static void UnlinkGhostWindows();
#endif
static nsWindowMemoryReporter* Get();
void ObserveDOMWindowDetached(nsGlobalWindow* aWindow);
+1 -1
View File
@@ -26,7 +26,7 @@ function parentDocShell(docshell) {
function isTopBrowserElement(docShell) {
while (docShell) {
docShell = parentDocShell(docShell);
if (docShell && docShell.isMozBrowserOrApp) {
if (docShell && docShell.isMozBrowser) {
return false;
}
}
@@ -112,7 +112,7 @@ var CopyPasteAssistent = {
let targetDocShell = currentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
if(targetDocShell.isMozBrowserOrApp) {
if(targetDocShell.isMozBrowser) {
break;
}
}
@@ -54,23 +54,6 @@ CreateIframe(Element* aOpenerFrameElement, const nsAString& aName, bool aRemote)
popupFrameElement->SetMozbrowser(true);
// Copy the opener frame's mozapp attribute to the popup frame.
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)) {
nsAutoString mozapp;
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, mozapp);
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::mozapp,
mozapp, /* aNotify = */ false);
}
// Copy the opener frame's parentApp attribute to the popup frame.
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::parentapp)) {
nsAutoString parentApp;
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
parentApp);
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
parentApp, /* aNotify = */ false);
}
// Copy the window name onto the iframe.
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
aName, /* aNotify = */ false);
@@ -8,27 +8,6 @@
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
// We'll need to get the appId from the current document,
// it's either SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID when
// we are not running inside an app (e.g. Firefox Desktop),
// or the appId of Mochitest app when we are running inside that app
// (e.g. Emulator).
var currentAppId = SpecialPowers.wrap(document).nodePrincipal.appId;
var inApp =
currentAppId !== SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID;
// We will also need the manifest URL and set it on iframes.
var currentAppManifestURL;
if (inApp) {
let appsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"]
.getService(SpecialPowers.Ci.nsIAppsService);
currentAppManifestURL = appsService.getManifestURLByLocalId(currentAppId);
};
info('appId=' + currentAppId);
info('manifestURL=' + currentAppManifestURL);
function setup() {
let appInfo = SpecialPowers.Cc['@mozilla.org/xre/app-info;1']
.getService(SpecialPowers.Ci.nsIXULAppInfo);
@@ -73,9 +52,6 @@ function createFrames() {
for (let i = 0; i < 2; i++) {
let frame = gInputMethodFrames[i] = document.createElement('iframe');
frame.setAttribute('mozbrowser', 'true');
if (currentAppManifestURL) {
frame.setAttribute('mozapp', currentAppManifestURL);
}
frame.addEventListener('mozbrowserloadend', countLoadend);
frame.src = 'file_empty.html#' + i;
document.body.appendChild(frame);
@@ -88,20 +64,10 @@ function setPermissions() {
allow: true,
context: {
url: SimpleTest.getTestFileURL('/file_empty.html'),
originAttributes: {
appId: currentAppId,
inIsolatedMozBrowser: true
}
originAttributes: {}
}
}];
if (inApp) {
// The current document would also need to be given access for IPC to
// recognize our permission (why)?
permissions.push({
type: 'input', allow: true, context: document });
}
SpecialPowers.pushPermissions(permissions,
SimpleTest.waitForFocus.bind(SimpleTest, startTest));
}
@@ -20,7 +20,6 @@
// set 'remote' to true here will make the the iframe remote in _inproc_
// test and in-process in _oop_ test.
iframe.setAttribute('remote', 'true');
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
iframe.addEventListener('mozbrowserloadend', function(e) {
ok("mute" in iframe, "iframe.mute exists");
@@ -13,7 +13,5 @@ support-files =
[test_Simple.html]
[test_HighPriority.html]
[test_Preallocated.html]
disabled = bug 968604, bug 987164
[test_WebGLContextLost.html]
disabled = bug 865844
@@ -1,71 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Test that the preallocated process starts up with priority BACKGROUND.
-->
<head>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
browserElementTestHelpers.enableProcessPriorityManager();
var preallocationEnabledPref = null;
try {
preallocationEnabledPref = SpecialPowers.getBoolPref('dom.ipc.processPrelaunch.enabled');
}
catch(e) {
preallocationEnabledPref = null;
}
var childID = null;
var cleanedUp = false;
function cleanUp()
{
if (cleanedUp) {
return;
}
cleanedUp = true;
}
// Even if this test times out, we still want to run cleanUp so as to set the
// pref back.
addEventListener('unload', cleanUp);
function runTest()
{
if (preallocationEnabledPref) {
ok(false, "dom.ipc.processPrelaunch.enabled must be " +
"false for this test to work.");
SimpleTest.finish();
return;
}
// Ensure that the preallocated process initially gets BACKGROUND priority.
// That's it.
expectProcessCreated('PREALLOC').then(function() {
// We need to set the pref asynchoronously or the preallocated process won't
// be shut down.
SimpleTest.executeSoon(function(){
cleanUp();
SimpleTest.finish();
});
});
}
// Setting this pref to true should cause us to prelaunch a process.
addEventListener('testready', function() {
SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processPrelaunch.enabled",true]]},runTest);
});
</script>
</body>
</html>
+1 -4
View File
@@ -259,7 +259,6 @@ Context::QuotaInitRunnable::OpenDirectory()
QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT,
mQuotaInfo.mGroup,
mQuotaInfo.mOrigin,
mQuotaInfo.mIsApp,
quota::Client::DOMCACHE,
/* aExclusive */ false,
this);
@@ -376,8 +375,7 @@ Context::QuotaInitRunnable::Run()
nsresult rv = QuotaManager::GetInfoFromPrincipal(principal,
&mQuotaInfo.mSuffix,
&mQuotaInfo.mGroup,
&mQuotaInfo.mOrigin,
&mQuotaInfo.mIsApp);
&mQuotaInfo.mOrigin);
if (NS_WARN_IF(NS_FAILED(rv))) {
resolver->Resolve(rv);
break;
@@ -436,7 +434,6 @@ Context::QuotaInitRunnable::Run()
mQuotaInfo.mSuffix,
mQuotaInfo.mGroup,
mQuotaInfo.mOrigin,
mQuotaInfo.mIsApp,
getter_AddRefs(mQuotaInfo.mDir));
if (NS_FAILED(rv)) {
resolver->Resolve(rv);
+4 -1
View File
@@ -196,7 +196,10 @@ static_assert(int(ReferrerPolicy::_empty) == 0 &&
int(ReferrerPolicy::Origin) == 3 &&
int(ReferrerPolicy::Origin_when_cross_origin) == 4 &&
int(ReferrerPolicy::Unsafe_url) == 5 &&
int(ReferrerPolicy::EndGuard_) == 6,
int(ReferrerPolicy::Same_origin) == 6 &&
int(ReferrerPolicy::Strict_origin) == 7 &&
int(ReferrerPolicy::Strict_origin_when_cross_origin) == 8 &&
int(ReferrerPolicy::EndGuard_) == 9,
"ReferrerPolicy values are as expected");
static_assert(int(RequestMode::Same_origin) == 0 &&
int(RequestMode::No_cors) == 1 &&
+1 -2
View File
@@ -29,8 +29,7 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut)
nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal,
nullptr, // suffix
nullptr, // group
&quotaOrigin,
nullptr); // is app
&quotaOrigin);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
RefPtr<ManagerId> ref = new ManagerId(aPrincipal, quotaOrigin);
-2
View File
@@ -28,12 +28,10 @@ static const CacheId INVALID_CACHE_ID = -1;
struct QuotaInfo
{
QuotaInfo() : mIsApp(false) { }
nsCOMPtr<nsIFile> mDir;
nsCString mSuffix;
nsCString mGroup;
nsCString mOrigin;
bool mIsApp;
};
} // namespace cache
+4
View File
@@ -1824,7 +1824,9 @@ WebGLContext::UpdateContextLossStatus()
void
WebGLContext::ForceLoseContext(bool simulateLosing)
{
#ifdef DEBUG
printf_stderr("WebGL(%p)::ForceLoseContext\n", this);
#endif
MOZ_ASSERT(!IsContextLost());
mContextStatus = ContextLostAwaitingEvent;
mContextLostErrorSet = false;
@@ -1840,7 +1842,9 @@ WebGLContext::ForceLoseContext(bool simulateLosing)
void
WebGLContext::ForceRestoreContext()
{
#ifdef DEBUG
printf_stderr("WebGL(%p)::ForceRestoreContext\n", this);
#endif
mContextStatus = ContextLostAwaitingRestore;
mAllowContextRestore = true; // Hey, you did say 'force'.
+2 -2
View File
@@ -1279,9 +1279,9 @@ EventStateManager::IsRemoteTarget(nsIContent* target) {
return true;
}
// <frame/iframe mozbrowser/mozapp>
// <frame/iframe mozbrowser>
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(target);
if (browserFrame && browserFrame->GetReallyIsBrowserOrApp()) {
if (browserFrame && browserFrame->GetReallyIsBrowser()) {
return !!TabParent::GetFrom(target);
}
+30 -75
View File
@@ -33,6 +33,7 @@
#include "mozilla/Unused.h"
#include "Fetch.h"
#include "FetchUtil.h"
#include "InternalRequest.h"
#include "InternalResponse.h"
@@ -262,62 +263,30 @@ FetchDriver::HttpFetch()
// Set the same headers.
SetRequestHeaders(httpChan);
// Step 2. Set the referrer.
nsAutoString referrer;
mRequest->GetReferrer(referrer);
// The Referrer Policy in Request can be used to override a referrer policy
// associated with an environment settings object.
// If there's no Referrer Policy in the request, it should be inherited
// from environment.
ReferrerPolicy referrerPolicy = mRequest->ReferrerPolicy_();
net::ReferrerPolicy net_referrerPolicy = mRequest->GetEnvironmentReferrerPolicy();
switch (referrerPolicy) {
case ReferrerPolicy::_empty:
break;
case ReferrerPolicy::No_referrer:
net_referrerPolicy = net::RP_No_Referrer;
break;
case ReferrerPolicy::No_referrer_when_downgrade:
net_referrerPolicy = net::RP_No_Referrer_When_Downgrade;
break;
case ReferrerPolicy::Origin:
net_referrerPolicy = net::RP_Origin;
break;
case ReferrerPolicy::Origin_when_cross_origin:
net_referrerPolicy = net::RP_Origin_When_Crossorigin;
break;
case ReferrerPolicy::Unsafe_url:
net_referrerPolicy = net::RP_Unsafe_URL;
break;
default:
MOZ_ASSERT_UNREACHABLE("Invalid ReferrerPolicy enum value?");
break;
// Step 6 of
// https://fetch.spec.whatwg.org/#main-fetch
// If request's referrer policy is the empty string and request's client is
// non-null, then set request's referrer policy to request's client's
// associated referrer policy.
// Basically, "client" is not in our implementation, we use
// EnvironmentReferrerPolicy of the worker or document context
if (mRequest->ReferrerPolicy_() == ReferrerPolicy::_empty) {
mRequest->SetReferrerPolicy(net_referrerPolicy);
}
// Step 7 of
// https://fetch.spec.whatwg.org/#main-fetch
// If request’s referrer policy is the empty string,
// then set request’s referrer policy to "no-referrer-when-downgrade".
if (mRequest->ReferrerPolicy_() == ReferrerPolicy::_empty) {
mRequest->SetReferrerPolicy(net::RP_No_Referrer_When_Downgrade);
}
if (referrer.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
rv = nsContentUtils::SetFetchReferrerURIWithPolicy(mPrincipal,
mDocument,
httpChan,
net_referrerPolicy);
NS_ENSURE_SUCCESS(rv, rv);
} else if (referrer.IsEmpty()) {
rv = httpChan->SetReferrerWithPolicy(nullptr, net::RP_No_Referrer);
NS_ENSURE_SUCCESS(rv, rv);
} else {
// From "Determine request's Referrer" step 3
// "If request's referrer is a URL, let referrerSource be request's
// referrer."
nsCOMPtr<nsIURI> referrerURI;
rv = NS_NewURI(getter_AddRefs(referrerURI), referrer, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
rv =
httpChan->SetReferrerWithPolicy(referrerURI,
referrerPolicy == ReferrerPolicy::_empty ?
mRequest->GetEnvironmentReferrerPolicy() :
net_referrerPolicy);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = FetchUtil::SetRequestReferrer(mPrincipal,
mDocument,
httpChan,
mRequest);
NS_ENSURE_SUCCESS(rv, rv);
// Bug 1120722 - Authorization will be handled later.
// Auth may require prompting, we don't support it yet.
@@ -864,29 +833,15 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
net::ReferrerPolicy net_referrerPolicy =
nsContentUtils::GetReferrerPolicyFromHeader(tRPHeaderValue);
if (net_referrerPolicy != net::RP_Unset) {
ReferrerPolicy referrerPolicy = mRequest->ReferrerPolicy_();
switch (net_referrerPolicy) {
case net::RP_No_Referrer:
referrerPolicy = ReferrerPolicy::No_referrer;
break;
case net::RP_No_Referrer_When_Downgrade:
referrerPolicy = ReferrerPolicy::No_referrer_when_downgrade;
break;
case net::RP_Origin:
referrerPolicy = ReferrerPolicy::Origin;
break;
case net::RP_Origin_When_Crossorigin:
referrerPolicy = ReferrerPolicy::Origin_when_cross_origin;
break;
case net::RP_Unsafe_URL:
referrerPolicy = ReferrerPolicy::Unsafe_url;
break;
default:
MOZ_ASSERT_UNREACHABLE("Invalid ReferrerPolicy value");
break;
mRequest->SetReferrerPolicy(net_referrerPolicy);
// Should update channel's referrer policy
if (httpChannel) {
rv = FetchUtil::SetRequestReferrer(mPrincipal,
mDocument,
httpChannel,
mRequest);
NS_ENSURE_SUCCESS(rv, rv);
}
mRequest->SetReferrerPolicy(referrerPolicy);
}
}
+56
View File
@@ -4,8 +4,10 @@
#include "nsIUnicodeDecoder.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "nsIDocument.h"
#include "mozilla/dom/EncodingUtils.h"
#include "mozilla/dom/InternalRequest.h"
namespace mozilla {
namespace dom {
@@ -111,5 +113,59 @@ FetchUtil::ExtractHeader(nsACString::const_iterator& aStart,
return PushOverLine(aStart, aEnd);
}
// static
nsresult
FetchUtil::SetRequestReferrer(nsIPrincipal* aPrincipal,
nsIDocument* aDoc,
nsIHttpChannel* aChannel,
InternalRequest* aRequest) {
MOZ_ASSERT(NS_IsMainThread());
nsAutoString referrer;
aRequest->GetReferrer(referrer);
net::ReferrerPolicy policy = aRequest->GetReferrerPolicy();
nsresult rv = NS_OK;
if (referrer.IsEmpty()) {
// This is the case request’s referrer is "no-referrer"
rv = aChannel->SetReferrerWithPolicy(nullptr, net::RP_No_Referrer);
NS_ENSURE_SUCCESS(rv, rv);
} else if (referrer.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
rv = nsContentUtils::SetFetchReferrerURIWithPolicy(aPrincipal,
aDoc,
aChannel,
policy);
NS_ENSURE_SUCCESS(rv, rv);
} else {
// From "Determine request's Referrer" step 3
// "If request's referrer is a URL, let referrerSource be request's
// referrer."
nsCOMPtr<nsIURI> referrerURI;
rv = NS_NewURI(getter_AddRefs(referrerURI), referrer, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
rv = aChannel->SetReferrerWithPolicy(referrerURI, policy);
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIURI> referrerURI;
aChannel->GetReferrer(getter_AddRefs(referrerURI));
// Step 8 https://fetch.spec.whatwg.org/#main-fetch
// If request’s referrer is not "no-referrer", set request’s referrer to
// the result of invoking determine request’s referrer.
if (referrerURI) {
nsAutoCString spec;
rv = referrerURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
aRequest->SetReferrer(NS_ConvertUTF8toUTF16(spec));
} else {
aRequest->SetReferrer(EmptyString());
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla
+13
View File
@@ -8,9 +8,15 @@
#include "mozilla/dom/File.h"
#include "mozilla/dom/FormData.h"
class nsIPrincipal;
class nsIDocument;
class nsIHttpChannel;
namespace mozilla {
namespace dom {
class InternalRequest;
class FetchUtil final
{
private:
@@ -35,6 +41,13 @@ public:
nsCString& aHeaderName,
nsCString& aHeaderValue,
bool* aWasEmptyHeader);
static nsresult
SetRequestReferrer(nsIPrincipal* aPrincipal,
nsIDocument* aDoc,
nsIHttpChannel* aChannel,
InternalRequest* aRequest);
};
} // namespace dom
+66
View File
@@ -232,6 +232,72 @@ public:
mReferrerPolicy = aReferrerPolicy;
}
void
SetReferrerPolicy(net::ReferrerPolicy aReferrerPolicy)
{
switch (aReferrerPolicy) {
case net::RP_Unset:
mReferrerPolicy = ReferrerPolicy::_empty;
break;
case net::RP_No_Referrer:
mReferrerPolicy = ReferrerPolicy::No_referrer;
break;
case net::RP_No_Referrer_When_Downgrade:
mReferrerPolicy = ReferrerPolicy::No_referrer_when_downgrade;
break;
case net::RP_Origin:
mReferrerPolicy = ReferrerPolicy::Origin;
break;
case net::RP_Origin_When_Crossorigin:
mReferrerPolicy = ReferrerPolicy::Origin_when_cross_origin;
break;
case net::RP_Unsafe_URL:
mReferrerPolicy = ReferrerPolicy::Unsafe_url;
break;
case net::RP_Same_Origin:
mReferrerPolicy = ReferrerPolicy::Same_origin;
break;
case net::RP_Strict_Origin:
mReferrerPolicy = ReferrerPolicy::Strict_origin;
break;
case net::RP_Strict_Origin_When_Cross_Origin:
mReferrerPolicy = ReferrerPolicy::Strict_origin_when_cross_origin;
break;
default:
MOZ_ASSERT_UNREACHABLE("Invalid ReferrerPolicy value");
break;
}
}
net::ReferrerPolicy
GetReferrerPolicy()
{
switch (mReferrerPolicy) {
case ReferrerPolicy::_empty:
return net::RP_Unset;
case ReferrerPolicy::No_referrer:
return net::RP_No_Referrer;
case ReferrerPolicy::No_referrer_when_downgrade:
return net::RP_No_Referrer_When_Downgrade;
case ReferrerPolicy::Origin:
return net::RP_Origin;
case ReferrerPolicy::Origin_when_cross_origin:
return net::RP_Origin_When_Crossorigin;
case ReferrerPolicy::Unsafe_url:
return net::RP_Unsafe_URL;
case ReferrerPolicy::Strict_origin:
return net::RP_Strict_Origin;
case ReferrerPolicy::Same_origin:
return net::RP_Same_Origin;
case ReferrerPolicy::Strict_origin_when_cross_origin:
return net::RP_Strict_Origin_When_Cross_Origin;
default:
MOZ_ASSERT_UNREACHABLE("Invalid ReferrerPolicy enum value?");
break;
}
return net::RP_Unset;
}
net::ReferrerPolicy
GetEnvironmentReferrerPolicy() const
{
+7 -1
View File
@@ -5595,8 +5595,14 @@ HTMLMediaElement::CopyInnerTo(Element* aDest)
{
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
NS_ENSURE_SUCCESS(rv, rv);
// Make sure cloned <audio> and <video> respect their "muted" attribute.
HTMLMediaElement* dest = static_cast<HTMLMediaElement*>(aDest);
if (HasAttr(kNameSpaceID_None, nsGkAtoms::muted)) {
dest->mMuted |= MUTED_BY_CONTENT;
}
if (aDest->OwnerDoc()->IsStaticDocument()) {
HTMLMediaElement* dest = static_cast<HTMLMediaElement*>(aDest);
dest->SetMediaInfo(mMediaInfo);
}
return rv;
+6
View File
@@ -324,6 +324,12 @@ HTMLScriptElement::GetCORSMode() const
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
}
mozilla::net::ReferrerPolicy
HTMLScriptElement::GetReferrerPolicy()
{
return GetReferrerPolicyAsEnum();
}
bool
HTMLScriptElement::HasScriptContent()
{
+9
View File
@@ -42,6 +42,7 @@ public:
virtual void GetScriptCharset(nsAString& charset) override;
virtual void FreezeExecutionAttrs(nsIDocument* aOwnerDoc) override;
virtual CORSMode GetCORSMode() const override;
virtual mozilla::net::ReferrerPolicy GetReferrerPolicy() override;
// nsIContent
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
@@ -96,6 +97,14 @@ public:
{
SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, rv);
}
void SetReferrerPolicy(const nsAString& aReferrerPolicy, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrerPolicy, aError);
}
void GetReferrerPolicy(nsAString& aReferrerPolicy)
{
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrerPolicy);
}
bool Async();
void SetAsync(bool aValue, ErrorResult& rv);
bool NoModule();
+6 -8
View File
@@ -15,11 +15,9 @@
#include "AudioChannelService.h"
#include "mozIApplication.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsFrameLoader.h"
#include "nsIAppsService.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDOMRequest.h"
#include "nsIDOMElement.h"
@@ -44,13 +42,13 @@ nsBrowserElement::IsBrowserElementOrThrow(ErrorResult& aRv)
void
nsBrowserElement::InitBrowserElementAPI()
{
bool isMozBrowserOrApp;
bool isMozBrowser;
nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
NS_ENSURE_TRUE_VOID(frameLoader);
nsresult rv = frameLoader->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
nsresult rv = frameLoader->GetOwnerIsMozBrowserFrame(&isMozBrowser);
NS_ENSURE_SUCCESS_VOID(rv);
if (!isMozBrowserOrApp) {
if (!isMozBrowser) {
return;
}
@@ -495,13 +493,13 @@ nsBrowserElement::GetAllowedAudioChannels(
return;
}
bool isMozBrowserOrApp;
aRv = frameLoader->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
bool isMozBrowser;
aRv = frameLoader->GetOwnerIsMozBrowserFrame(&isMozBrowser);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
if (!isMozBrowserOrApp) {
if (!isMozBrowser) {
return;
}
-1
View File
@@ -123,7 +123,6 @@ public:
protected:
NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
NS_IMETHOD GetParentApplication(mozIApplication** aApplication) = 0;
void InitBrowserElementAPI();
void DestroyBrowserElementFrameScripts();
+2 -156
View File
@@ -11,10 +11,8 @@
#include "mozilla/Preferences.h"
#include "mozilla/ErrorResult.h"
#include "GeckoProfiler.h"
#include "mozIApplication.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
#include "nsIAppsService.h"
#include "nsIDocShell.h"
#include "nsIDOMDocument.h"
#include "nsIFrame.h"
@@ -191,31 +189,6 @@ nsGenericHTMLFrameElement::GetFrameLoader()
return loader.forget();
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::GetParentApplication(mozIApplication** aApplication)
{
if (!aApplication) {
return NS_ERROR_FAILURE;
}
*aApplication = nullptr;
nsIPrincipal *principal = NodePrincipal();
uint32_t appId = principal->GetAppId();
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
if (NS_WARN_IF(!appsService)) {
return NS_ERROR_FAILURE;
}
nsresult rv = appsService->GetAppByLocalId(appId, aApplication);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
void
nsGenericHTMLFrameElement::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, ErrorResult& aRv)
{
@@ -512,144 +485,17 @@ nsGenericHTMLFrameElement::BrowserFramesEnabled()
}
/**
* Return true if this frame element really is a mozbrowser or mozapp. (It
* Return true if this frame element really is a mozbrowser. (It
* needs to have the right attributes, and its creator must have the right
* permissions.)
*/
/* [infallible] */ nsresult
nsGenericHTMLFrameElement::GetReallyIsBrowserOrApp(bool *aOut)
nsGenericHTMLFrameElement::GetReallyIsBrowser(bool *aOut)
{
*aOut = mReallyIsBrowser;
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsGenericHTMLFrameElement::GetReallyIsApp(bool *aOut)
{
nsAutoString manifestURL;
GetAppManifestURL(manifestURL);
*aOut = !manifestURL.IsEmpty();
return NS_OK;
}
namespace {
bool NestedEnabled()
{
static bool sMozNestedEnabled = false;
static bool sBoolVarCacheInitialized = false;
if (!sBoolVarCacheInitialized) {
sBoolVarCacheInitialized = true;
Preferences::AddBoolVarCache(&sMozNestedEnabled,
"dom.ipc.tabs.nested.enabled");
}
return sMozNestedEnabled;
}
} // namespace
/* [infallible] */ NS_IMETHODIMP
nsGenericHTMLFrameElement::GetIsolated(bool *aOut)
{
*aOut = true;
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
return NS_OK;
}
// Isolation is only disabled if the attribute is present
*aOut = !HasAttr(kNameSpaceID_None, nsGkAtoms::noisolation);
return NS_OK;
}
/*
* Get manifest url of app.
*/
void nsGenericHTMLFrameElement::GetManifestURL(nsAString& aManifestURL)
{
aManifestURL.Truncate();
nsAutoString manifestURL;
GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, manifestURL);
if (manifestURL.IsEmpty()) {
return;
}
// Check permission.
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
NS_ENSURE_TRUE_VOID(permMgr);
nsIPrincipal *principal = NodePrincipal();
const char* aPermissionType = "embed-apps";
uint32_t permission = nsIPermissionManager::DENY_ACTION;
nsresult rv = permMgr->TestPermissionFromPrincipal(principal,
aPermissionType,
&permission);
NS_ENSURE_SUCCESS_VOID(rv);
if (permission != nsIPermissionManager::ALLOW_ACTION) {
return;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(appsService);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(manifestURL, getter_AddRefs(app));
if (!app) {
return;
}
aManifestURL.Assign(manifestURL);
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut)
{
aOut.Truncate();
// At the moment, you can't be an app without being a browser.
if (!nsIMozBrowserFrame::GetReallyIsBrowserOrApp()) {
return NS_OK;
}
// Only allow content process to embed an app when nested content
// process is enabled.
if (!XRE_IsParentProcess() &&
!(GetBoolAttr(nsGkAtoms::Remote) && NestedEnabled())){
NS_WARNING("Can't embed-apps. Embed-apps is restricted to in-proc apps "
"or content processes with nested pref enabled, see bug 1097479");
return NS_OK;
}
nsAutoString appManifestURL;
GetManifestURL(appManifestURL);
bool isApp = !appManifestURL.IsEmpty();
if (!isApp) {
// No valid case to get manifest
return NS_OK;
}
if (isApp) {
NS_WARNING("Can not simultaneously be mozapp");
return NS_OK;
}
nsAutoString manifestURL;
if (isApp) {
manifestURL.Assign(appManifestURL);
}
aOut.Assign(manifestURL);
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::DisallowCreateFrameLoader()
{
+1 -1
View File
@@ -24,7 +24,7 @@ SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);
function runTests() {
var elements = [ "iframe", "img", "a", "area", "link" ];
var elements = [ "iframe", "img", "a", "area", "link", "script"];
for (var i = 0; i < elements.length; ++i) {
reflectLimitedEnumerated({
+15 -29
View File
@@ -74,7 +74,6 @@
#include "nsHashKeys.h"
#include "nsNetUtil.h"
#include "nsISimpleEnumerator.h"
#include "nsIAppsService.h"
#include "nsIEventTarget.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
@@ -7394,7 +7393,6 @@ protected:
nsCString mDatabaseId;
nsString mDatabaseFilePath;
State mState;
bool mIsApp;
bool mEnforcingQuota;
const bool mDeleting;
bool mBlockedDatabaseOpen;
@@ -16904,7 +16902,6 @@ Cursor::RecvContinue(const CursorRequestParams& aParams)
FileManager::FileManager(PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
bool aIsApp,
const nsAString& aDatabaseName,
bool aEnforcingQuota)
: mPersistenceType(aPersistenceType)
@@ -16912,7 +16909,6 @@ FileManager::FileManager(PersistenceType aPersistenceType,
, mOrigin(aOrigin)
, mDatabaseName(aDatabaseName)
, mLastFileId(0)
, mIsApp(aIsApp)
, mEnforcingQuota(aEnforcingQuota)
, mInvalidated(false)
{ }
@@ -18293,7 +18289,7 @@ Maintenance::DirectoryWork()
// The storage directory is structured like this:
//
// <profile>/storage/<persistence>/<origin>/idb/*.sqlite
// <profile>\storage\<persistence>\<origin>\idb\*.sqlite
//
// We have to find all database files that match any persistence type and any
// origin. We ignore anything out of the ordinary for now.
@@ -18489,7 +18485,6 @@ Maintenance::DirectoryWork()
nsCString suffix;
nsCString group;
nsCString origin;
bool isApp;
nsTArray<nsString> databasePaths;
while (true) {
@@ -18555,8 +18550,7 @@ Maintenance::DirectoryWork()
&dummyTimeStamp,
suffix,
group,
origin,
&isApp)))) {
origin)))) {
// Not much we can do here...
continue;
}
@@ -18582,7 +18576,6 @@ Maintenance::DirectoryWork()
suffix,
group,
origin,
isApp,
getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -19426,7 +19419,6 @@ UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory,
new FileManager(PERSISTENCE_TYPE_INVALID,
EmptyCString(),
EmptyCString(),
false,
EmptyString(),
false);
@@ -20669,7 +20661,6 @@ FactoryOp::FactoryOp(Factory* aFactory,
, mContentParent(Move(aContentParent))
, mCommonParams(aCommonParams)
, mState(State::Initial)
, mIsApp(false)
, mEnforcingQuota(true)
, mDeleting(aDeleting)
, mBlockedDatabaseOpen(false)
@@ -21021,13 +21012,11 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
}
if (State::Initial == mState) {
QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin, &mIsApp);
QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin);
MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType, mOrigin,
mIsApp));
MOZ_ASSERT(QuotaManager::IsOriginInternal(mOrigin));
mEnforcingQuota =
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
mEnforcingQuota = false;
}
*aPermission = PermissionRequestBase::kPermissionAllowed;
@@ -21046,22 +21035,24 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
nsCString suffix;
nsCString group;
nsCString origin;
bool isApp;
rv = QuotaManager::GetInfoFromPrincipal(principal,
&suffix,
&group,
&origin,
&isApp);
&origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
PermissionRequestBase::PermissionValue permission;
if (QuotaManager::IsFirstPromptRequired(persistenceType, origin, isApp)) {
rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT) {
if (QuotaManager::IsOriginInternal(origin)) {
permission = PermissionRequestBase::kPermissionAllowed;
} else {
rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
} else {
permission = PermissionRequestBase::kPermissionAllowed;
@@ -21072,10 +21063,8 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
mSuffix = suffix;
mGroup = group;
mOrigin = origin;
mIsApp = isApp;
mEnforcingQuota =
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
mEnforcingQuota = persistenceType != PERSISTENCE_TYPE_PERSISTENT;
}
*aPermission = permission;
@@ -21232,7 +21221,6 @@ FactoryOp::OpenDirectory()
quotaManager->OpenDirectory(persistenceType,
mGroup,
mOrigin,
mIsApp,
Client::IDB,
/* aExclusive */ false,
this);
@@ -21497,7 +21485,6 @@ OpenDatabaseOp::DoDatabaseWork()
mSuffix,
mGroup,
mOrigin,
mIsApp,
getter_AddRefs(dbDirectory));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@@ -21618,7 +21605,6 @@ OpenDatabaseOp::DoDatabaseWork()
fileManager = new FileManager(persistenceType,
mGroup,
mOrigin,
mIsApp,
databaseName,
mEnforcingQuota);
-8
View File
@@ -41,7 +41,6 @@ class FileManager final
// Protected by IndexedDatabaseManager::FileMutex()
nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
const bool mIsApp;
const bool mEnforcingQuota;
bool mInvalidated;
@@ -65,7 +64,6 @@ public:
FileManager(PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
bool aIsApp,
const nsAString& aDatabaseName,
bool aEnforcingQuota);
@@ -87,12 +85,6 @@ public:
return mOrigin;
}
bool
IsApp() const
{
return mIsApp;
}
const nsAString&
DatabaseName() const
{
+2 -3
View File
@@ -1074,7 +1074,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
MOZ_CRASH("Is this needed?!");
case PrincipalInfo::TSystemPrincipalInfo:
QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin, nullptr);
QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin);
return NS_OK;
case PrincipalInfo::TContentPrincipalInfo: {
@@ -1088,8 +1088,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
rv = QuotaManager::GetInfoFromPrincipal(principal,
nullptr,
nullptr,
&aOrigin,
nullptr);
&aOrigin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
-1
View File
@@ -1272,7 +1272,6 @@ DeleteFilesRunnable::Open()
quotaManager->OpenDirectory(mFileManager->Type(),
mFileManager->Group(),
mFileManager->Origin(),
mFileManager->IsApp(),
Client::IDB,
/* aExclusive */ false,
this);
@@ -1,88 +0,0 @@
<!DOCTYPE html>
<html>
<body>
foobar!
</body>
<script>
var data = [
{ id: "0", name: "foo" },
];
var action = window.location.search.substring(1);
var finished = false;
var created = false; // We use that for 'read-no' action.
function finish(value) {
value ? alert('success') : alert('failure');
finished = true;
}
var request = window.indexedDB.open('AppIsolationTest');
request.onupgradeneeded = function(event) {
if (finished) {
finish(false);
return;
}
switch (action) {
case 'read-no':
created = true;
break;
case 'read-yes':
finish(false);
break;
case 'write':
created = true;
var db = event.target.result;
var objectStore = db.createObjectStore("test", { keyPath: "id" });
for (var i in data) {
objectStore.add(data[i]);
}
break;
}
}
request.onsuccess = function(event) {
if (finished) {
finish(false);
return;
}
var db = event.target.result;
// Think about close the db!
switch (action) {
case 'read-no':
db.close();
if (created) { // That means we have created it.
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
finish(true);
};
} else {
finish(false);
}
break;
case 'read-yes':
db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
var name = event.target.result.name;
db.close();
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
finish(name == 'foo');
};
};
break;
case 'write':
db.close();
// Success only if the db was actually created.
finish(created);
break;
}
};
</script>
</html>
-161
View File
@@ -1,161 +0,0 @@
SimpleTest.waitForExplicitFinish();
var fileTestOnCurrentOrigin = (location.protocol + '//' + location.host + location.pathname)
.replace('test_', 'file_')
.replace('_inproc', '').replace('_oop', '');
var previousPrefs = {
mozBrowserFramesEnabled: undefined,
oop_by_default: undefined,
};
try {
previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
} catch(e)
{
}
try {
previousPrefs.oop_by_default = SpecialPowers.getBoolPref('dom.ipc.browser_frames.oop_by_default');
} catch(e) {
}
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", location.pathname.indexOf('_inproc') == -1);
SpecialPowers.addPermission("browser", true, window.document);
var gData = [
// APP 1
{
app: 'http://example.org/manifest.webapp',
action: 'read-no',
src: fileTestOnCurrentOrigin,
},
{
app: 'http://example.org/manifest.webapp',
action: 'write',
src: fileTestOnCurrentOrigin,
},
{
app: 'http://example.org/manifest.webapp',
action: 'read-yes',
src: fileTestOnCurrentOrigin,
},
// APP 2
{
app: 'https://example.com/manifest.webapp',
action: 'read-no',
src: fileTestOnCurrentOrigin,
},
{
app: 'https://example.com/manifest.webapp',
action: 'write',
src: fileTestOnCurrentOrigin,
},
{
app: 'https://example.com/manifest.webapp',
action: 'read-yes',
src: fileTestOnCurrentOrigin,
},
// Browser
{
browser: true,
action: 'read-no',
src: fileTestOnCurrentOrigin,
},
{
browser: true,
action: 'write',
src: fileTestOnCurrentOrigin,
},
{
browser: true,
action: 'read-yes',
src: fileTestOnCurrentOrigin,
},
];
function runTest() {
for (var i in gData) {
var iframe = document.createElement('iframe');
var data = gData[i];
if (data.app) {
iframe.setAttribute('mozbrowser', '');
iframe.setAttribute('mozapp', data.app);
} else if (data.browser) {
iframe.setAttribute('mozbrowser', '');
}
if (data.app || data.browser) {
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
is(e.detail.message, 'success', 'test number ' + i);
// document.getElementById('content').removeChild(iframe);
i++;
if (i >= gData.length) {
if (previousPrefs.mozBrowserFramesEnabled !== undefined) {
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled);
}
if (previousPrefs.oop_by_default !== undefined) {
SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", previousPrefs.oop_by_default);
}
SpecialPowers.removePermission("browser", window.document);
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
SimpleTest.finish();
};
} else {
gTestRunner.next();
}
});
}
iframe.src = data.src + '?' + data.action;
document.getElementById('content').appendChild(iframe);
yield undefined;
}
}
var gTestRunner = runTest();
function startTest() {
var request = window.indexedDB.open('AppIsolationTest');
var created = false;
request.onupgradeneeded = function(event) {
created = true;
var db = event.target.result;
var data = [
{ id: "0", name: "foo" },
];
var objectStore = db.createObjectStore("test", { keyPath: "id" });
for (var i in data) {
objectStore.add(data[i]);
}
}
request.onsuccess = function(event) {
var db = event.target.result;
is(created, true, "we should have created the db");
db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
is(event.target.result.name, 'foo', 'data have been written');
db.close();
gTestRunner.next();
};
}
}
// TODO: remove unsetting network.disable.ipc.security as part of bug 820712
SpecialPowers.pushPrefEnv({
"set": [
["network.disable.ipc.security", true],
]
}, startTest);
-8
View File
@@ -11,8 +11,6 @@ support-files =
event_propagation_iframe.html
exceptions_in_events_iframe.html
file.js
file_app_isolation.html
file_app_isolation.js
helpers.js
leaving_page_iframe.html
service_worker.js
@@ -125,12 +123,6 @@ support-files =
[test_add_put.html]
[test_add_twice_failure.html]
[test_advance.html]
[test_app_isolation_inproc.html]
# The app isolation tests are only supposed to run in the main process.
skip-if = e10s
[test_app_isolation_oop.html]
# The app isolation tests are only supposed to run in the main process.
skip-if = e10s
[test_autoIncrement.html]
[test_autoIncrement_indexes.html]
[test_bfcache.html]
@@ -1,21 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
-->
<head>
<title>Test for IndexedDB app isolation (unique process)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
</script>
</pre>
</body>
</html>
@@ -1,21 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
-->
<head>
<title>Test for IndexedDB app isolation (unique process)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
</script>
</pre>
</body>
</html>
+2 -40
View File
@@ -19,10 +19,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
"resource://gre/modules/SystemAppProxy.jsm");
XPCOMUtils.defineLazyGetter(this, "appsService", function() {
return Cc["@mozilla.org/AppsService;1"].getService(Ci.nsIAppsService);
});
XPCOMUtils.defineLazyGetter(this, "hardwareKeyHandler", function() {
return null;
});
@@ -174,8 +170,8 @@ this.Keyboard = {
this.formMM = null;
}
} else {
// Ignore notifications that aren't from a BrowserOrApp
if (!frameLoader.ownerIsMozBrowserOrAppFrame) {
// Ignore notifications that aren't from a Browser
if (!frameLoader.ownerIsMozBrowserFrame) {
return;
}
this.initFormsFrameScript(mm);
@@ -554,24 +550,6 @@ InputRegistryGlue.prototype.addInput = function(msg, mm) {
mm: mm,
requestId: msg.data.requestId
});
let manifestURL = appsService.getManifestURLByLocalId(msg.data.appId);
Keyboard.sendToSystem('System:InputRegistry:Add', {
id: msgId,
manifestURL: manifestURL,
inputId: msg.data.inputId,
inputManifest: msg.data.inputManifest
});
// XXX: To be removed when content migrate away from mozChromeEvents.
SystemAppProxy.dispatchEvent({
type: 'inputregistry-add',
id: msgId,
manifestURL: manifestURL,
inputId: msg.data.inputId,
inputManifest: msg.data.inputManifest
});
};
InputRegistryGlue.prototype.removeInput = function(msg, mm) {
@@ -580,22 +558,6 @@ InputRegistryGlue.prototype.removeInput = function(msg, mm) {
mm: mm,
requestId: msg.data.requestId
});
let manifestURL = appsService.getManifestURLByLocalId(msg.data.appId);
Keyboard.sendToSystem('System:InputRegistry:Remove', {
id: msgId,
manifestURL: manifestURL,
inputId: msg.data.inputId
});
// XXX: To be removed when content migrate away from mozChromeEvents.
SystemAppProxy.dispatchEvent({
type: 'inputregistry-remove',
id: msgId,
manifestURL: manifestURL,
inputId: msg.data.inputId
});
};
InputRegistryGlue.prototype.returnMessage = function(detail) {
-13
View File
@@ -1,13 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# 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/.
XPIDL_SOURCES += [
'mozIApplication.idl',
'mozIApplicationClearPrivateDataParams.idl',
'nsIAppsService.idl',
]
XPIDL_MODULE = 'dom_apps'
-58
View File
@@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "domstubs.idl"
interface nsIPrincipal;
/**
* We expose Gecko-internal helpers related to "web apps" through this
* sub-interface.
*/
[scriptable, uuid(e76aa5e0-80b2-404f-bccc-1067828bb6ed)]
interface mozIApplication: nsISupports
{
/* Return true if this app has |permission|. */
boolean hasPermission(in string permission);
/* Application status as defined in nsIPrincipal. */
readonly attribute unsigned short appStatus;
/* Returns the uuid of the app. */
readonly attribute DOMString id;
/* Returns the origin of the app. */
readonly attribute DOMString origin;
/* Returns the manifest url of the app. */
readonly attribute DOMString manifestURL;
/* Returns the local id of the app. */
readonly attribute unsigned long localId;
/* Returns the base directory for the app */
readonly attribute DOMString basePath;
/* Name copied from the manifest */
readonly attribute DOMString name;
/* CSP copied from the manifest */
readonly attribute DOMString csp;
/* Store ID if the app is installed from a store */
readonly attribute DOMString storeID;
/* Store version if the app is installed from a store */
readonly attribute unsigned long storeVersion;
/* role copied from the manifest */
readonly attribute DOMString role;
/* Returns the kind of the app. */
readonly attribute DOMString kind;
/* Returns the app's principal */
readonly attribute nsIPrincipal principal;
};
@@ -1,18 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "nsISupports.idl"
[scriptable, uuid(ba0e6c8e-8c03-4b9b-8f9b-4fb14216f56e)]
interface mozIApplicationClearPrivateDataParams : nsISupports
{
readonly attribute unsigned long appId;
readonly attribute boolean browserOnly;
};
%{C++
#define TOPIC_WEB_APP_CLEAR_DATA "webapps-clear-data"
#define TOPIC_CLEAR_ORIGIN_DATA "clear-origin-attributes-data"
%}
-75
View File
@@ -1,75 +0,0 @@
/* 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 "domstubs.idl"
interface mozIApplication;
interface nsIURI;
%{C++
#define APPS_SERVICE_CID { 0x05072afa, 0x92fe, 0x45bf, { 0xae, 0x22, 0x39, 0xb6, 0x9c, 0x11, 0x70, 0x58 } }
#define APPS_SERVICE_CONTRACTID "@mozilla.org/AppsService;1"
%}
/*
* This service allows accessing some DOMApplicationRegistry methods from
* non-javascript code.
*/
[scriptable, uuid(711cfab6-7b72-4aa2-a60c-17952ea05661)]
interface nsIAppsService : nsISupports
{
mozIApplication getAppByManifestURL(in DOMString manifestURL);
/**
* Returns a Promise for the manifest for a given manifestURL.
* This is only supported in the parent process: the promise will be rejected
* in content processes.
*/
jsval getManifestFor(in DOMString manifestURL);
/**
* Returns the |localId| of the app associated with the |manifestURL| passed
* in parameter.
* Returns nsIScriptSecurityManager::NO_APP_ID if |manifestURL| isn't a valid
* installed manifest URL.
*/
unsigned long getAppLocalIdByManifestURL(in DOMString manifestURL);
/**
* Returns the application associated to this localId.
*/
mozIApplication getAppByLocalId(in unsigned long localId);
/**
* Returns the manifest URL associated to this localId.
*/
DOMString getManifestURLByLocalId(in unsigned long localId);
/**
* Returns the basepath for core apps
*/
DOMString getCoreAppsBasePath();
/**
* Returns the basepath for regular packaged apps
*/
DOMString getWebAppsBasePath();
/**
* Returns true if at least one app is in the registry.
*/
boolean areAnyAppsInstalled();
jsval getAppInfo(in DOMString appId);
/**
* Returns the localId if the app was installed from a store
*/
DOMString getAppLocalIdByStoreId(in DOMString storeID);
/**
* Returns the scope for app to use with service workers.
*/
DOMString getScopeByLocalId(in unsigned long localId);
};
+2 -33
View File
@@ -12,44 +12,13 @@ interface nsITabParent;
interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame
{
/**
* Gets whether this frame really is a browser or app frame.
* Gets whether this frame really is a browser frame.
*
* In order to really be a browser frame, this frame's
* nsIDOMMozBrowserFrame::mozbrowser attribute must be true, and the frame
* may have to pass various security checks.
*/
[infallible] readonly attribute boolean reallyIsBrowserOrApp;
/**
* Gets whether this frame really is an app frame.
*
* In order to really be an app frame, this frame must really be a browser
* frame (this requirement will go away eventually), and the frame's mozapp
* attribute must point to the manifest of a valid app.
*/
[infallible] readonly attribute boolean reallyIsApp;
/**
* Gets whether this frame is an isolated frame.
*
* By default, browser frames are isolated, meaning they have a principal
* where OriginAttributes.mIsInIsolatedMozBrowser == true. This isolates
* storage and other origin related items from non-browser apps, xul:browsers,
* etc.
*
* Isolation can be disabled by setting the frame's isolated attribute to
* false. Disabling isolation is only allowed if the containing document has
* browser permission (or equivalent access).
*/
[infallible] readonly attribute boolean isolated;
/**
* Gets this frame's app manifest URL, if the frame really is an app frame.
* Otherwise, returns the empty string.
*
* This method is guaranteed not to fail.
*/
readonly attribute AString appManifestURL;
[infallible] readonly attribute boolean reallyIsBrowser;
/**
* Normally, a frame tries to create its frame loader when its src is
-6
View File
@@ -77,7 +77,6 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeChild::SendPBrowserConstructor(aActor,
@@ -85,7 +84,6 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@@ -130,14 +128,12 @@ ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aTabId,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@@ -153,7 +149,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
@@ -161,7 +156,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
-3
View File
@@ -42,7 +42,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual mozilla::ipc::PFileDescriptorSetChild*
@@ -60,7 +59,6 @@ protected:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserChild(PBrowserChild*) override;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
@@ -68,7 +66,6 @@ protected:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
-4
View File
@@ -102,7 +102,6 @@ ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeParent::SendPBrowserConstructor(aActor,
@@ -110,7 +109,6 @@ ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@@ -143,14 +141,12 @@ ContentBridgeParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
-12
View File
@@ -42,7 +42,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
@@ -53,10 +52,6 @@ public:
{
return mChildID;
}
virtual bool IsForApp() const override
{
return mIsForApp;
}
virtual bool IsForBrowser() const override
{
return mIsForBrowser;
@@ -75,11 +70,6 @@ protected:
mChildID = aId;
}
void SetIsForApp(bool aIsForApp)
{
mIsForApp = aIsForApp;
}
void SetIsForBrowser(bool aIsForBrowser)
{
mIsForBrowser = aIsForBrowser;
@@ -114,7 +104,6 @@ protected:
const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserParent(PBrowserParent*) override;
@@ -140,7 +129,6 @@ protected: // members
RefPtr<ContentBridgeParent> mSelfRef;
Transport* mTransport; // owned
ContentParentId mChildID;
bool mIsForApp;
bool mIsForBrowser;
private:
+2 -72
View File
@@ -558,8 +558,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
SendBackUpXResources(FileDescriptor(xSocketFd));
#endif
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
InitProcessAttributes();
SendGetProcessAttributes(&mID, &mIsForBrowser);
#ifdef NS_PRINTING
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
@@ -570,12 +569,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
return true;
}
void
ContentChild::InitProcessAttributes()
{
SetProcessName(NS_LITERAL_STRING("Web Content"), true);
}
void
ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
{
@@ -682,7 +675,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
// We release this ref in DeallocPBrowserChild
RefPtr<TabChild>(newChild).forget().take(),
tabId, *ipcContext, aChromeFlags,
GetID(), IsForApp(), IsForBrowser());
GetID(), IsForBrowser());
nsString name(aName);
nsAutoCString features(aFeatures);
@@ -1248,15 +1241,6 @@ ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
return true;
}
static CancelableRunnable* sFirstIdleTask;
static void FirstIdle(void)
{
MOZ_ASSERT(sFirstIdleTask);
sFirstIdleTask = nullptr;
ContentChild::GetSingleton()->SendFirstIdle();
}
mozilla::jsipc::PJavaScriptChild *
ContentChild::AllocPJavaScriptChild()
{
@@ -1276,14 +1260,12 @@ ContentChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aTabId,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@@ -1293,7 +1275,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
if (IsShuttingDown()) {
@@ -1305,7 +1286,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@@ -1315,7 +1295,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
MOZ_ASSERT(!IsShuttingDown());
@@ -1330,23 +1309,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
os->NotifyObservers(tc, "tab-child-created", nullptr);
}
static bool hasRunOnce = false;
if (!hasRunOnce) {
hasRunOnce = true;
MOZ_ASSERT(!sFirstIdleTask);
RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
sFirstIdleTask = firstIdleTask;
MessageLoop::current()->PostIdleTask(firstIdleTask.forget());
// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
mID = aCpID;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
InitProcessAttributes();
}
return true;
}
@@ -1795,9 +1757,6 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
// keep persistent state.
ProcessChild::QuickExit();
#else
if (sFirstIdleTask) {
sFirstIdleTask->Cancel();
}
nsHostObjectProtocolHandler::RemoveDataEntries();
@@ -2091,16 +2050,6 @@ ContentChild::RecvCycleCollect()
return true;
}
static void
PreloadSlowThings()
{
// This fetches and creates all the built-in stylesheets.
nsLayoutStylesheetCache::Get()->UserContentSheet();
TabChild::PreloadSlowThings();
}
bool
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
const nsCString& name, const nsCString& UAName,
@@ -2116,25 +2065,6 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
return true;
}
bool
ContentChild::RecvAppInit()
{
if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
return true;
}
// If we're part of the mozbrowser machinery, go ahead and start
// preloading things. We can only do this for mozbrowser because
// PreloadSlowThings() may set the docshell of the first TabChild
// inactive, and we can only safely restore it to active from
// BrowserElementChild.js.
if (mIsForApp || mIsForBrowser) {
PreloadSlowThings();
}
return true;
}
bool
ContentChild::RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig)
{
-9
View File
@@ -91,8 +91,6 @@ public:
base::ProcessId aParentPid,
IPC::Channel* aChannel);
void InitProcessAttributes();
void InitXPCOM();
void InitGraphicsDeviceData();
@@ -175,7 +173,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserChild(PBrowserChild*) override;
@@ -381,8 +378,6 @@ public:
const nsCString& name, const nsCString& UAName,
const nsCString& ID, const nsCString& vendor) override;
virtual bool RecvAppInit() override;
virtual bool
RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig) override;
@@ -483,7 +478,6 @@ public:
uint32_t GetMsaaID() const { return mMsaaID; }
#endif
bool IsForApp() const { return mIsForApp; }
bool IsForBrowser() const { return mIsForBrowser; }
virtual PBlobChild*
@@ -504,7 +498,6 @@ public:
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
@@ -512,7 +505,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)
@@ -618,7 +610,6 @@ private:
AppInfo mAppInfo;
bool mIsForApp;
bool mIsForBrowser;
bool mCanOverrideProcessName;
bool mIsAlive;
+92 -471
View File
@@ -27,7 +27,6 @@
#include "HandlerServiceParent.h"
#include "IHistory.h"
#include "imgIContainer.h"
#include "mozIApplication.h"
#if defined(XP_WIN) && defined(ACCESSIBILITY)
#include "mozilla/a11y/AccessibleWrap.h"
#endif
@@ -99,7 +98,6 @@
#include "nsFrameMessageManager.h"
#include "nsHashPropertyBag.h"
#include "nsIAlertsService.h"
#include "nsIAppsService.h"
#include "nsIClipboard.h"
#include "nsContentPermissionHelper.h"
#include "nsICycleCollectorListener.h"
@@ -147,7 +145,6 @@
#include "nsThreadUtils.h"
#include "nsToolkitCompsCID.h"
#include "nsWidgetsCID.h"
#include "PreallocatedProcessManager.h"
#include "ProcessPriorityManager.h"
#include "SandboxHal.h"
#include "ScreenManagerParent.h"
@@ -457,8 +454,7 @@ ContentParentsMemoryReporter::CollectReports(
return NS_OK;
}
nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
nsTArray<ContentParent*>* ContentParent::sBrowserContentParents;
nsTArray<ContentParent*>* ContentParent::sLargeAllocationContentParents;
nsTArray<ContentParent*>* ContentParent::sPrivateContent;
StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
@@ -474,11 +470,6 @@ static bool sDisableUnsafeCPOWWarnings = false;
// The first content child has ID 1, so the chrome process can have ID 0.
static uint64_t gContentChildID = 1;
// We want the prelaunched process to know that it's for apps, but not
// actually for any app in particular. Use a magic manifest URL.
// Can't be a static constant.
#define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
static const char* sObserverTopics[] = {
"xpcom-shutdown",
"profile-before-change",
@@ -497,77 +488,6 @@ static const char* sObserverTopics[] = {
"cacheservice:empty-cache",
};
// PreallocateAppProcess is called by the PreallocatedProcessManager.
// ContentParent then takes this process back within
// GetNewOrPreallocatedAppProcess.
/*static*/ already_AddRefed<ContentParent>
ContentParent::PreallocateAppProcess()
{
RefPtr<ContentParent> process =
new ContentParent(/* app = */ nullptr,
/* aOpener = */ nullptr,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ true);
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
return nullptr;
}
process->Init();
return process.forget();
}
/*static*/ already_AddRefed<ContentParent>
ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
ProcessPriority aInitialPriority,
ContentParent* aOpener,
/*out*/ bool* aTookPreAllocated)
{
MOZ_ASSERT(aApp);
RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
if (process) {
if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
// Kill the process just in case it's not actually dead; we don't want
// to "leak" this process!
process->KillHard("GetNewOrPreallocatedAppProcess");
}
else {
nsAutoString manifestURL;
if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
NS_ERROR("Failed to get manifest URL");
return nullptr;
}
process->TransformPreallocatedIntoApp(aOpener, manifestURL);
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = true;
}
return process.forget();
}
}
NS_WARNING("Unable to use pre-allocated app process");
process = new ContentParent(aApp,
/* aOpener = */ aOpener,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ false);
if (!process->LaunchSubprocess(aInitialPriority)) {
return nullptr;
}
process->Init();
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = false;
}
return process.forget();
}
/*static*/ void
ContentParent::StartUp()
{
@@ -589,9 +509,6 @@ ContentParent::StartUp()
BackgroundChild::Startup();
// Try to preallocate a process that we can transform into an app later.
PreallocatedProcessManager::AllocateAfterDelay();
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
}
@@ -669,10 +586,10 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
maxContentParents = Preferences::GetInt("dom.ipc.dedicatedProcessCount", 2);
} else {
if (!sNonAppContentParents) {
sNonAppContentParents = new nsTArray<ContentParent*>();
if (!sBrowserContentParents) {
sBrowserContentParents = new nsTArray<ContentParent*>();
}
contentParents = sNonAppContentParents;
contentParents = sBrowserContentParents;
maxContentParents = Preferences::GetInt("dom.ipc.processCount", 1);
}
@@ -688,7 +605,7 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
uint32_t currIdx = startIdx;
do {
RefPtr<ContentParent> p = (*contentParents)[currIdx];
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sBrowserContntParents?");
if (p->mOpener == aOpener) {
return p.forget();
}
@@ -696,24 +613,14 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
} while (currIdx != startIdx);
}
// Try to take and transform the preallocated process into browser.
RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
if (p) {
p->TransformPreallocatedIntoBrowser(aOpener);
} else {
// Failed in using the preallocated process: fork from the chrome process.
p = new ContentParent(/* app = */ nullptr,
aOpener,
aForBrowserElement,
/* isForPreallocated = */ false);
RefPtr<ContentParent> p = new ContentParent(aOpener, aForBrowserElement);
if (!p->LaunchSubprocess(aPriority)) {
return nullptr;
}
p->Init();
if (!p->LaunchSubprocess(aPriority)) {
return nullptr;
}
p->Init();
p->mLargeAllocationProcess = aLargeAllocationProcess;
p->ForwardKnownInfo();
@@ -771,18 +678,11 @@ ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
ContentParent::SendAsyncUpdate(nsIWidget* aWidget) {}
#endif
bool
ContentParent::PreallocatedProcessReady()
{
return true;
}
bool
ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId)
{
@@ -800,24 +700,16 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
return false;
}
nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
if (ownApp) {
cp = GetNewOrPreallocatedAppProcess(ownApp, aPriority, this);
}
else {
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
aPriority, this);
}
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
aPriority, this);
if (!cp) {
*aCpId = 0;
*aIsForApp = false;
*aIsForBrowser = false;
return true;
}
*aCpId = cp->ChildID();
*aIsForApp = cp->IsForApp();
*aIsForBrowser = cp->IsForBrowser();
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
@@ -964,10 +856,10 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
#endif
/*static*/ TabParent*
ContentParent::CreateBrowserOrApp(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess)
ContentParent::CreateBrowser(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess)
{
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
@@ -990,222 +882,74 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
openerTabId = TabParent::GetTabIdFrom(docShell);
}
if (aContext.IsMozBrowserElement() || !aContext.HasOwnApp()) {
RefPtr<nsIContentParent> constructorSender;
if (isInContentProcess) {
MOZ_ASSERT(aContext.IsMozBrowserElement());
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
openerTabId, &tabId);
} else {
if (aOpenerContentParent) {
constructorSender = aOpenerContentParent;
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
initialPriority,
nullptr,
aFreshProcess);
if (!constructorSender) {
return nullptr;
}
}
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
}
if (constructorSender) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner) {
return nullptr;
}
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
if (!wbc) {
return nullptr;
}
uint32_t chromeFlags = 0;
wbc->GetChromeFlags(&chromeFlags);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
if (docShell->GetAffectPrivateSessionLifetime()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
if (tabId == 0) {
return nullptr;
}
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
aContext, chromeFlags));
tp->SetInitedByParent();
PBrowserParent* browser =
constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
tp.forget().take(), tabId,
aContext.AsIPCTabContext(),
chromeFlags,
constructorSender->ChildID(),
constructorSender->IsForApp(),
constructorSender->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
return constructedTabParent;
}
}
return nullptr;
}
// If we got here, we have an app and we're not a browser element. ownApp
// shouldn't be null, because we otherwise would have gone into the
// !HasOwnApp() branch above.
RefPtr<nsIContentParent> parent;
bool reused = false;
bool tookPreallocated = false;
nsAutoString manifestURL;
RefPtr<nsIContentParent> constructorSender;
if (isInContentProcess) {
parent = CreateContentBridgeParent(aContext,
initialPriority,
openerTabId,
&tabId);
}
else {
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
if (!sAppContentParents) {
sAppContentParents =
new nsDataHashtable<nsStringHashKey, ContentParent*>();
MOZ_ASSERT(aContext.IsMozBrowserElement());
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
openerTabId, &tabId);
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
initialPriority, nullptr, aFreshProcess);
if (!constructorSender) {
return nullptr;
}
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
}
// Each app gets its own ContentParent instance unless it shares it with
// a parent app.
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
NS_ERROR("Failed to get manifest URL");
if (constructorSender) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner) {
return nullptr;
}
RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
nsAutoString parentAppManifestURL;
aFrameElement->GetAttr(kNameSpaceID_None,
nsGkAtoms::parentapp, parentAppManifestURL);
nsAdoptingString systemAppManifestURL =
Preferences::GetString("b2g.system_manifest_url");
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
if (!parentAppManifestURL.IsEmpty() &&
!parentAppManifestURL.Equals(systemAppManifestURL) &&
appsService) {
nsCOMPtr<mozIApplication> parentApp;
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(parentAppManifestURL,
getter_AddRefs(parentApp));
appsService->GetAppByManifestURL(manifestURL,
getter_AddRefs(app));
// Only let certified apps re-use the same process.
unsigned short parentAppStatus = 0;
unsigned short appStatus = 0;
if (app &&
NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
parentApp &&
NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
// Check if we can re-use the process of the parent app.
p = sAppContentParents->Get(parentAppManifestURL);
}
}
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
if (!wbc) {
return nullptr;
}
if (p) {
// Check that the process is still alive and set its priority.
// Hopefully the process won't die after this point, if this call
// succeeds.
if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
p = nullptr;
}
uint32_t chromeFlags = 0;
wbc->GetChromeFlags(&chromeFlags);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
reused = !!p;
if (!p) {
p = GetNewOrPreallocatedAppProcess(ownApp, initialPriority, nullptr,
&tookPreallocated);
MOZ_ASSERT(p);
sAppContentParents->Put(manifestURL, p);
}
tabId = AllocateTabId(openerTabId, aContext.AsIPCTabContext(),
p->ChildID());
parent = static_cast<nsIContentParent*>(p);
}
if (!parent || (tabId == 0)) {
return nullptr;
}
uint32_t chromeFlags = 0;
RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
tp->SetInitedByParent();
PBrowserParent* browser = parent->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
RefPtr<TabParent>(tp).forget().take(),
tabId,
aContext.AsIPCTabContext(),
chromeFlags,
parent->ChildID(),
parent->IsForApp(),
parent->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
}
if (isInContentProcess) {
// Just return directly without the following check in content process.
return TabParent::GetFrom(browser);
}
if (!browser) {
// We failed to actually start the PBrowser. This can happen if the
// other process has already died.
if (!reused) {
// Don't leave a broken ContentParent in the hashtable.
parent->AsContentParent()->KillHard("CreateBrowserOrApp");
sAppContentParents->Remove(manifestURL);
parent = nullptr;
if (docShell->GetAffectPrivateSessionLifetime()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
// If we took the preallocated process and it was already dead, try
// again with a non-preallocated process. We can be sure this won't
// loop forever, because the next time through there will be no
// preallocated process to take.
if (tookPreallocated) {
return ContentParent::CreateBrowserOrApp(aContext, aFrameElement,
aOpenerContentParent);
if (tabId == 0) {
return nullptr;
}
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
aContext, chromeFlags));
tp->SetInitedByParent();
PBrowserParent* browser =
constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
tp.forget().take(), tabId,
aContext.AsIPCTabContext(),
chromeFlags,
constructorSender->ChildID(),
constructorSender->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
// Otherwise just give up.
return nullptr;
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
return constructedTabParent;
}
}
return TabParent::GetFrom(browser);
return nullptr;
}
/*static*/ ContentBridgeParent*
@@ -1218,13 +962,11 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
ContentChild* child = ContentChild::GetSingleton();
ContentParentId cpId;
bool isForApp;
bool isForBrowser;
if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
aPriority,
aOpenerTabId,
&cpId,
&isForApp,
&isForBrowser,
aTabId)) {
return nullptr;
@@ -1237,7 +979,6 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
}
ContentBridgeParent* parent = child->GetLastBridge();
parent->SetChildID(cpId);
parent->SetIsForApp(isForApp);
parent->SetIsForBrowser(isForBrowser);
return parent;
}
@@ -1352,51 +1093,6 @@ ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
return true;
}
// Helper for ContentParent::TransformPreallocatedIntoApp.
static void
TryGetNameFromManifestURL(const nsAString& aManifestURL,
nsAString& aName)
{
aName.Truncate();
if (aManifestURL.IsEmpty() ||
aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
return;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(appsService);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
if (!app) {
return;
}
app->GetName(aName);
}
void
ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
const nsAString& aAppManifestURL)
{
MOZ_ASSERT(IsPreallocated());
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL = aAppManifestURL;
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
}
void
ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
{
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL.Truncate();
mIsForBrowser = true;
}
void
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
{
@@ -1480,29 +1176,19 @@ ContentParent::ShutDownMessageManager()
void
ContentParent::MarkAsDead()
{
if (!mAppManifestURL.IsEmpty()) {
if (sAppContentParents) {
sAppContentParents->Remove(mAppManifestURL);
if (!sAppContentParents->Count()) {
delete sAppContentParents;
sAppContentParents = nullptr;
}
}
} else {
if (sNonAppContentParents) {
sNonAppContentParents->RemoveElement(this);
if (!sNonAppContentParents->Length()) {
delete sNonAppContentParents;
sNonAppContentParents = nullptr;
}
if (sBrowserContentParents) {
sBrowserContentParents->RemoveElement(this);
if (!sBrowserContentParents->Length()) {
delete sBrowserContentParents;
sBrowserContentParents = nullptr;
}
}
if (sLargeAllocationContentParents) {
sLargeAllocationContentParents->RemoveElement(this);
if (!sLargeAllocationContentParents->Length()) {
delete sLargeAllocationContentParents;
sLargeAllocationContentParents = nullptr;
}
if (sLargeAllocationContentParents) {
sLargeAllocationContentParents->RemoveElement(this);
if (!sLargeAllocationContentParents->Length()) {
delete sLargeAllocationContentParents;
sLargeAllocationContentParents = nullptr;
}
}
@@ -1805,7 +1491,7 @@ ContentParent::NotifyTabDestroying(const TabId& aTabId,
return;
}
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
if (!cp->mLargeAllocationProcess && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive) {
return;
@@ -1862,7 +1548,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
// We might want to keep alive some content processes for testing, because of performance
// reasons, but we don't want to alter behavior if the pref is not set.
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
bool shouldKeepAliveAny = !mLargeAllocationProcess && processesToKeepAlive > 0;
bool shouldKeepAliveThis = shouldKeepAliveAny && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive;
@@ -1956,10 +1642,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
return true;
}
ContentParent::ContentParent(mozIApplication* aApp,
ContentParent* aOpener,
bool aIsForBrowser,
bool aIsForPreallocated)
ContentParent::ContentParent(ContentParent* aOpener,
bool aIsForBrowser)
: nsIContentParent()
, mOpener(aOpener)
, mIsForBrowser(aIsForBrowser)
@@ -1967,10 +1651,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
{
InitializeMembers(); // Perform common initialization.
// No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
// true.
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
mMetamorphosed = true;
// Insert ourselves into the global linked list of ContentParent objects.
@@ -1979,13 +1659,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
}
sContentParents->insertBack(this);
if (aApp) {
aApp->GetManifestURL(mAppManifestURL);
aApp->GetName(mAppName);
} else if (aIsForPreallocated) {
mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
}
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
// PID along with the warning.
nsDebugImpl::SetMultiprocessMode("Parent");
@@ -2012,19 +1685,10 @@ ContentParent::~ContentParent()
// We should be removed from all these lists in ActorDestroy.
MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
if (mAppManifestURL.IsEmpty()) {
MOZ_ASSERT((!sNonAppContentParents ||
!sNonAppContentParents->Contains(this)) &&
(!sLargeAllocationContentParents ||
!sLargeAllocationContentParents->Contains(this)));
} else {
// In general, we expect sAppContentParents->Get(mAppManifestURL) to be
// nullptr. But it could be that we created another ContentParent for
// this app after we did this->ActorDestroy(), so the right check is
// that sAppContentParents->Get(mAppManifestURL) != this.
MOZ_ASSERT(!sAppContentParents ||
sAppContentParents->Get(mAppManifestURL) != this);
}
MOZ_ASSERT((!sBrowserContentParents ||
!sBrowserContentParents->Contains(this)) &&
(!sLargeAllocationContentParents ||
!sLargeAllocationContentParents->Contains(this)));
}
void
@@ -2096,11 +1760,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
}
}
if (gAppData) {
// Sending all information to content process.
Unused << SendAppInit();
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
// This looks like a lot of work, but in a normal browser session we just
@@ -2160,12 +1819,6 @@ ContentParent::IsAlive() const
return mIsAlive;
}
bool
ContentParent::IsForApp() const
{
return !mAppManifestURL.IsEmpty();
}
int32_t
ContentParent::Pid() const
{
@@ -2406,17 +2059,6 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
return true;
}
bool
ContentParent::RecvFirstIdle()
{
// When the ContentChild goes idle, it sends us a FirstIdle message
// which we use as a good time to prelaunch another process. If we
// prelaunch any sooner than this, then we'll be competing with the
// child process and slowing it down.
PreallocatedProcessManager::AllocateAfterDelay();
return true;
}
bool
ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
const bool& aHidden)
@@ -2587,10 +2229,9 @@ ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
bool
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp, bool* aIsForBrowser)
bool* aIsForBrowser)
{
*aCpId = mChildID;
*aIsForApp = IsForApp();
*aIsForBrowser = mIsForBrowser;
return true;
@@ -2699,14 +2340,12 @@ ContentParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
aChromeFlags,
aCpId,
aIsForApp,
aIsForBrowser);
}
@@ -2804,27 +2443,14 @@ ContentParent::KillHard(const char* aReason)
otherProcessHandle, /*force=*/true));
}
bool
ContentParent::IsPreallocated() const
{
return mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL;
}
void
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
{
aName.Truncate();
if (IsPreallocated()) {
aName.AssignLiteral("(Preallocated)");
} else if (mIsForBrowser) {
if (mIsForBrowser) {
aName.AssignLiteral("Browser");
} else if (aAnonymize) {
aName.AssignLiteral("<anonymized-name>");
} else if (!mAppName.IsEmpty()) {
aName = mAppName;
} else if (!mAppManifestURL.IsEmpty()) {
aName.AssignLiteral("Unknown app: ");
aName.Append(mAppManifestURL);
} else {
aName.AssignLiteral("???");
}
@@ -3661,7 +3287,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentParent::SendPBrowserConstructor(aActor,
@@ -3669,7 +3294,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
aContext,
aChromeFlags,
aCpId,
aIsForApp,
aIsForBrowser);
}
@@ -3787,12 +3411,9 @@ ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus,
// recording-device-ipc-events needs to gather more information from content process
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), ChildID());
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), IsForApp());
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
nsString requestURL = IsForApp() ? AppManifestURL() : aPageURL;
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), aPageURL);
obs->NotifyObservers((nsIPropertyBag2*) props,
"recording-device-ipc-events",
@@ -4247,7 +3868,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
thisTabParent = TabParent::GetFrom(aThisTab);
}
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowserOrApp())) {
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowser())) {
return false;
}
+9 -60
View File
@@ -114,8 +114,6 @@ public:
*/
static void JoinAllSubprocesses();
static bool PreallocatedProcessReady();
/**
* Get or create a content process for:
* 1. browser iframe
@@ -129,21 +127,16 @@ public:
ContentParent* aOpener = nullptr,
bool aLargeAllocationProcess = false);
/**
* Create a subprocess suitable for use as a preallocated app process.
*/
static already_AddRefed<ContentParent> PreallocateAppProcess();
/**
* Get or create a content process for the given TabContext. aFrameElement
* should be the frame/iframe element with which this process will
* associated.
*/
static TabParent*
CreateBrowserOrApp(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess = false);
CreateBrowser(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess = false);
static void GetAll(nsTArray<ContentParent*>& aArray);
@@ -231,7 +224,6 @@ public:
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId) override;
@@ -323,8 +315,6 @@ public:
bool IsAlive() const;
virtual bool IsForApp() const override;
virtual bool IsForBrowser() const override
{
return mIsForBrowser;
@@ -357,10 +347,6 @@ public:
ContentParentId ChildID() const override { return mChildID; }
const nsString& AppManifestURL() const { return mAppManifestURL; }
bool IsPreallocated() const;
/**
* Get a user-friendly name for this ContentParent. We make no guarantees
* about this name: It might not be unique, apps can spoof special names,
@@ -546,8 +532,7 @@ protected:
void OnCompositorUnexpectedShutdown() override;
private:
static nsDataHashtable<nsStringHashKey, ContentParent*> *sAppContentParents;
static nsTArray<ContentParent*>* sNonAppContentParents;
static nsTArray<ContentParent*>* sBrowserContentParents;
static nsTArray<ContentParent*>* sLargeAllocationContentParents;
static nsTArray<ContentParent*>* sPrivateContent;
static StaticAutoPtr<LinkedList<ContentParent> > sContentParents;
@@ -555,15 +540,6 @@ private:
static void JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
Monitor* aMonitor, bool* aDone);
// Take the preallocated process and transform it into a "real" app process,
// for the specified manifest URL. If there is no preallocated process (or
// if it's dead), create a new one and set aTookPreAllocated to false.
static already_AddRefed<ContentParent>
GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
hal::ProcessPriority aInitialPriority,
ContentParent* aOpener,
/*out*/ bool* aTookPreAllocated = nullptr);
static hal::ProcessPriority GetInitialProcessPriority(Element* aFrameElement);
static ContentBridgeParent* CreateContentBridgeParent(const TabContext& aContext,
@@ -579,18 +555,13 @@ private:
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
using PContentParent::SendPTestShellConstructor;
FORWARD_SHMEM_ALLOCATOR_TO(PContentParent)
// No more than one of !!aApp, aIsForBrowser, and aIsForPreallocated may be
// true.
ContentParent(mozIApplication* aApp,
ContentParent* aOpener,
bool aIsForBrowser,
bool aIsForPreallocated);
ContentParent(ContentParent* aOpener,
bool aIsForBrowser);
// The common initialization for the constructors.
void InitializeMembers();
@@ -610,7 +581,7 @@ private:
// Some information could be sent to content very early, it
// should be send from this function. This function should only be
// called after the process has been transformed to app or browser.
// called after the process has been transformed to browser.
void ForwardKnownInfo();
// Set the child process's priority and then check whether the child is
@@ -619,15 +590,6 @@ private:
// unlikely that the process will be killed after this point.
bool SetPriorityAndCheckIsAlive(hal::ProcessPriority aPriority);
// Transform a pre-allocated app process into a "real" app
// process, for the specified manifest URL.
void TransformPreallocatedIntoApp(ContentParent* aOpener,
const nsAString& aAppManifestURL);
// Transform a pre-allocated app process into a browser process. If this
// returns false, the child process has died.
void TransformPreallocatedIntoBrowser(ContentParent* aOpener);
/**
* Mark this ContentParent as dead for the purposes of Get*().
* This method is idempotent.
@@ -688,7 +650,6 @@ private:
ProcessId aOtherProcess) override;
virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser) override;
virtual bool
@@ -713,7 +674,6 @@ private:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserParent(PBrowserParent* frame) override;
@@ -912,8 +872,6 @@ private:
virtual bool RecvPrivateDocShellsExist(const bool& aExist) override;
virtual bool RecvFirstIdle() override;
virtual bool RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
const bool& aHidden) override;
@@ -1049,17 +1007,8 @@ private:
ContentParentId mChildID;
int32_t mGeolocationWatchID;
nsString mAppManifestURL;
nsCString mKillHardAnnotation;
/**
* We cache mAppName instead of looking it up using mAppManifestURL when we
* need it because it turns out that getting an app from the apps service is
* expensive.
*/
nsString mAppName;
// After we initiate shutdown, we also start a timer to ensure
// that even content processes that are 100% blocked (say from
// SIGSTOP), are still killed eventually. This task enforces that
@@ -1075,7 +1024,7 @@ private:
// through.
bool mIsAlive;
// True only the if process is already a browser or app or has
// True only the if process is already a browser or has
// been transformed into one.
bool mMetamorphosed;
-14
View File
@@ -353,19 +353,5 @@ ContentProcessManager::GetTabParentsByProcessId(const ContentParentId& aChildCpI
return Move(tabIdList);
}
uint32_t
ContentProcessManager::GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId)
{
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
if (aChildCpId && aChildTabId) {
TabContext tabContext;
if (GetTabContextByProcessAndTabId(aChildCpId, aChildTabId, &tabContext)) {
appId = tabContext.OwnOrContainingAppId();
}
}
return appId;
}
} // namespace dom
} // namespace mozilla
-9
View File
@@ -142,15 +142,6 @@ public:
GetTopLevelTabParentByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId);
/**
* Return appId by given TabId and ContentParentId.
* It will return nsIScriptSecurityManager::NO_APP_ID
* if the given tab is not an app.
*/
uint32_t
GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId);
private:
static StaticAutoPtr<ContentProcessManager> sSingleton;
TabId mUniqueId;
Loaded 100 of 770 files, more files were not shown because too many files have changed in this diff. Show more