Bug 1310845 - Remove support for mozapp iframes; r=fabrice,jryans,baku,mcmanus

This patch removes support for mozapp iframes, leaving support for
mozbrowser iframes intact.  Some of the code has been rewritten in order
to phrase things in terms of mozbrowser only, as opposed to mozbrowser
or app.  In some places, code that was only useful with apps has been
completely removed, so that the APIs consumed can also be removed.  In
some places where the notion of appId was bleeding out of this API, now
we use NO_APP_ID.  Other notions of appId which were restricted to this
API have been removed.
This commit is contained in:
Ehsan Akhgari 2016-10-14 21:46:26 -04:00
Родитель 24085dac28
Коммит eac76d9772
102 изменённых файлов: 325 добавлений и 2715 удалений

Просмотреть файл

@ -342,9 +342,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);

Просмотреть файл

@ -36,8 +36,6 @@ XPCOMUtils.defineLazyGetter(this, 'MemoryFront', function() {
return devtools.require('devtools/server/actors/memory').MemoryFront;
});
Cu.import('resource://gre/modules/Frames.jsm');
var _telemetryDebug = false;
function telemetryDebug(...args) {
@ -54,7 +52,6 @@ function telemetryDebug(...args) {
*/
var developerHUD = {
_targets: new Map(),
_histograms: new Set(),
_customHistograms: new Set(),
_client: null,
@ -99,13 +96,6 @@ var developerHUD = {
}
}
Frames.addObserver(this);
let appFrames = Frames.list().filter(frame => frame.getAttribute('mozapp'));
for (let frame of appFrames) {
this.trackFrame(frame);
}
SettingsListener.observe('hud.logging', this._logging, enabled => {
this._logging = enabled;
});
@ -124,63 +114,10 @@ var developerHUD = {
return;
}
for (let frame of this._targets.keys()) {
this.untrackFrame(frame);
}
Frames.removeObserver(this);
this._client.close();
delete this._client;
},
/**
* This method will ask all registered watchers to track and update metrics
* on an app frame.
*/
trackFrame(frame) {
if (this._targets.has(frame)) {
return;
}
DebuggerServer.connectToChild(this._conn, frame).then(actor => {
let target = new Target(frame, actor);
this._targets.set(frame, target);
for (let w of this._watchers) {
w.trackTarget(target);
}
});
},
untrackFrame(frame) {
let target = this._targets.get(frame);
if (target) {
for (let w of this._watchers) {
w.untrackTarget(target);
}
target.destroy();
this._targets.delete(frame);
}
},
onFrameCreated(frame, isFirstAppFrame) {
let mozapp = frame.getAttribute('mozapp');
if (!mozapp) {
return;
}
this.trackFrame(frame);
},
onFrameDestroyed(frame, isLastAppFrame) {
let mozapp = frame.getAttribute('mozapp');
if (!mozapp) {
return;
}
this.untrackFrame(frame);
},
log(message) {
if (this._logging) {
dump(DEVELOPER_HUD_LOG_PREFIX + ': ' + message + '\n');

Просмотреть файл

@ -358,7 +358,6 @@ var shell = {
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:iframe');
systemAppFrame.setAttribute('id', 'systemapp');
systemAppFrame.setAttribute('mozbrowser', 'true');
systemAppFrame.setAttribute('mozapp', manifestURL);
systemAppFrame.setAttribute('allowfullscreen', 'true');
systemAppFrame.setAttribute('src', 'blank.html');
let container = document.getElementById('container');

Просмотреть файл

@ -53,7 +53,6 @@ var remoteShell = {
document.createElementNS("http://www.w3.org/1999/xhtml", "html:iframe");
systemAppFrame.setAttribute("id", this.id);
systemAppFrame.setAttribute("mozbrowser", "true");
systemAppFrame.setAttribute("mozapp", manifestURL);
systemAppFrame.setAttribute("allowfullscreen", "true");
systemAppFrame.setAttribute("src", "blank.html");

Просмотреть файл

@ -30,10 +30,7 @@ function B2GTabList(connection) {
B2GTabList.prototype = Object.create(BrowserTabList.prototype);
B2GTabList.prototype._getBrowsers = function() {
return Frames.list().filter(frame => {
// Ignore app frames
return !frame.getAttribute("mozapp");
});
return Frames.list();
};
B2GTabList.prototype._getSelectedBrowser = function() {
@ -59,21 +56,11 @@ B2GTabList.prototype._listenForEventsIf = function(shouldListen) {
};
B2GTabList.prototype.onFrameCreated = function(frame) {
let mozapp = frame.getAttribute("mozapp");
if (mozapp) {
// Ignore app frames
return;
}
this._notifyListChanged();
this._checkListening();
};
B2GTabList.prototype.onFrameDestroyed = function(frame) {
let mozapp = frame.getAttribute("mozapp");
if (mozapp) {
// Ignore app frames
return;
}
let actor = this._actorByBrowser.get(frame);
if (actor) {
this._handleActorClose(actor, frame);

Просмотреть файл

@ -176,8 +176,8 @@ var ErrorPage = {
observe: function errorPageObserve(aSubject, aTopic, aData) {
let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader);
// Ignore notifications that aren't from a BrowserOrApp
if (!frameLoader.ownerIsMozBrowserOrAppFrame) {
// Ignore notifications that aren't from a Browser
if (!frameLoader.ownerIsMozBrowserFrame) {
return;
}
this._listenError(frameLoader);

Просмотреть файл

@ -19,9 +19,6 @@ const Observer = {
// the FrameDestroyed event with a frame reference.
_frames: new Map(),
// Also save current number of iframes opened by app
_apps: new Map(),
start: function () {
Services.obs.addObserver(this, 'remote-browser-shown', false);
Services.obs.addObserver(this, 'inprocess-browser-shown', false);
@ -30,10 +27,6 @@ const Observer = {
SystemAppProxy.getFrames().forEach(frame => {
let mm = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
this._frames.set(mm, frame);
let mozapp = frame.getAttribute('mozapp');
if (mozapp) {
this._apps.set(mozapp, (this._apps.get(mozapp) || 0) + 1);
}
});
},
@ -42,7 +35,6 @@ const Observer = {
Services.obs.removeObserver(this, 'inprocess-browser-shown');
Services.obs.removeObserver(this, 'message-manager-close');
this._frames.clear();
this._apps.clear();
},
observe: function (subject, topic, data) {
@ -70,17 +62,9 @@ const Observer = {
onMessageManagerCreated: function (mm, frame) {
this._frames.set(mm, frame);
let isFirstAppFrame = null;
let mozapp = frame.getAttribute('mozapp');
if (mozapp) {
let count = (this._apps.get(mozapp) || 0) + 1;
this._apps.set(mozapp, count);
isFirstAppFrame = (count === 1);
}
listeners.forEach(function (listener) {
try {
listener.onFrameCreated(frame, isFirstAppFrame);
listener.onFrameCreated(frame);
} catch(e) {
dump('Exception while calling Frames.jsm listener:' + e + '\n' +
e.stack + '\n');
@ -97,17 +81,9 @@ const Observer = {
this._frames.delete(mm);
let isLastAppFrame = null;
let mozapp = frame.getAttribute('mozapp');
if (mozapp) {
let count = (this._apps.get(mozapp) || 0) - 1;
this._apps.set(mozapp, count);
isLastAppFrame = (count === 0);
}
listeners.forEach(function (listener) {
try {
listener.onFrameDestroyed(frame, isLastAppFrame);
listener.onFrameDestroyed(frame);
} catch(e) {
dump('Exception while calling Frames.jsm listener:' + e + '\n' +
e.stack + '\n');

Просмотреть файл

@ -76,7 +76,6 @@ this.SafeMode = {
debug("Registry is ready, loading " + url);
let frame = document.createElementNS("http://www.w3.org/1999/xhtml", "html:iframe");
frame.setAttribute("mozbrowser", "true");
frame.setAttribute("mozapp", shell.manifestURL);
frame.setAttribute("id", "systemapp"); // To keep screen.js happy.
let contentBrowser = document.body.appendChild(frame);

Просмотреть файл

@ -1,6 +1,5 @@
user_pref("devtools.debugger.prompt-connection", false);
user_pref("devtools.debugger.forbid-certified-apps", false);
user_pref("devtools.apps.forbidden-permissions", "");
user_pref("b2g.software-buttons", true);
// Required for Mulet in order to run the debugger server from the command line

Просмотреть файл

@ -298,10 +298,10 @@ interface nsIPrincipal : nsISerializable
/**
* 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.
* <xul:browser> is not considered to be a mozbrowser element.
* <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;

Просмотреть файл

@ -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>

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -1508,8 +1508,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
@ -1519,8 +1517,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;
@ -1533,7 +1530,6 @@ function NetworkMonitorChild(appId, outerWindowID, messageManager, conn, owner)
exports.NetworkMonitorChild = NetworkMonitorChild;
NetworkMonitorChild.prototype = {
appId: null,
owner: null,
_netEvents: null,
_saveRequestAndResponseBodies: true,
@ -1581,7 +1577,6 @@ NetworkMonitorChild.prototype = {
mm.addMessageListener("debug:netmonitor:updateEvent",
this._onUpdateEvent);
mm.sendAsyncMessage("debug:netmonitor", {
appId: this.appId,
outerWindowID: this.outerWindowID,
action: "start",
});

Просмотреть файл

@ -169,17 +169,6 @@ LoadContext::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserEleme
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)
{

Просмотреть файл

@ -331,7 +331,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;
}

Просмотреть файл

@ -2603,7 +2603,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
@ -3433,7 +3433,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
if (nsIDocShell::GetIsMozBrowserOrApp()) {
if (nsIDocShell::GetIsMozBrowser()) {
return NS_OK;
}
@ -3450,7 +3450,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
}
NS_IMETHODIMP
nsDocShell::GetSameTypeParentIgnoreBrowserAndAppBoundaries(nsIDocShell** aParent)
nsDocShell::GetSameTypeParentIgnoreBrowserBoundaries(nsIDocShell** aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
@ -3504,18 +3504,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);
@ -3570,8 +3570,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
}
if (targetDS->GetIsInIsolatedMozBrowserElement() !=
accessingDS->GetIsInIsolatedMozBrowserElement() ||
targetDS->GetAppId() != accessingDS->GetAppId()) {
accessingDS->GetIsInIsolatedMozBrowserElement()) {
return false;
}
@ -3595,7 +3594,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
if (OriginAttributes::IsFirstPartyEnabled()) {
if (accessingDS == accessingRootDS &&
aAccessingItem->ItemType() == nsIDocShellTreeItem::typeContent &&
!accessingDS->GetIsMozBrowserOrApp()) {
!accessingDS->GetIsMozBrowser()) {
nsCOMPtr<nsIDocument> accessingDoc = aAccessingItem->GetDocument();
@ -3609,7 +3608,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
if (targetDS == targetRootDS &&
aTargetItem->ItemType() == nsIDocShellTreeItem::typeContent &&
!targetDS->GetIsMozBrowserOrApp()) {
!targetDS->GetIsMozBrowser()) {
nsCOMPtr<nsIDocument> targetDoc = aAccessingItem->GetDocument();
@ -3806,7 +3805,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),
@ -5369,23 +5368,13 @@ 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());
}
// netError.xhtml's getDescription only handles the "d" parameter at the
// end of the URL, so append it last.
errorPageUrl.AppendLiteral("&d=");
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, nullptr,
@ -6205,9 +6194,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) {
@ -6244,7 +6231,7 @@ nsDocShell::SetIsActive(bool aIsActive)
continue;
}
if (!docshell->GetIsMozBrowserOrApp()) {
if (!docshell->GetIsMozBrowser()) {
docshell->SetIsActive(aIsActive);
}
}
@ -10556,9 +10543,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));
@ -10911,7 +10896,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))) {
@ -14238,16 +14223,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;
}
@ -14291,9 +14269,9 @@ nsDocShell::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElemen
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsInMozBrowserOrApp(bool* aIsInMozBrowserOrApp)
nsDocShell::GetIsInMozBrowser(bool* aIsInMozBrowser)
{
*aIsInMozBrowserOrApp = (GetInheritedFrameType() != FRAME_TYPE_REGULAR);
*aIsInMozBrowser = (GetInheritedFrameType() == FRAME_TYPE_BROWSER);
return NS_OK;
}
@ -14311,25 +14289,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)
@ -14426,23 +14385,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)
{

Просмотреть файл

@ -779,8 +779,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:

Просмотреть файл

@ -792,34 +792,28 @@ 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.
* <xul:browser> is not considered to be a mozbrowser element.
* <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;
@ -828,69 +822,45 @@ interface nsIDocShell : nsIDocShellTreeItem
* 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.
* <xul:browser> is not considered to be a mozbrowser element. <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
* this process until we hit an <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

Просмотреть файл

@ -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;

Просмотреть файл

@ -106,19 +106,13 @@ interface nsILoadContext : nsISupports
/**
* 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.
* element. <xul:browser> is not considered to be a mozbrowser element.
* <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.

Просмотреть файл

@ -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,

Просмотреть файл

@ -68,7 +68,6 @@
#include "DeviceStorage.h"
#include "nsStreamUtils.h"
#include "nsIAppsService.h"
#include "mozIApplication.h"
#include "WidgetUtils.h"
#include "nsIPresentationService.h"

Просмотреть файл

@ -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.

Просмотреть файл

@ -6400,7 +6400,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();

Просмотреть файл

@ -13,7 +13,6 @@
#include "prenv.h"
#include "mozIApplication.h"
#include "nsDocShell.h"
#include "nsIAppsService.h"
#include "nsIDOMHTMLIFrameElement.h"
@ -89,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"
@ -1066,8 +1064,7 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
}
if (mRemoteBrowser->IsIsolatedMozBrowserElement() !=
aOther->mRemoteBrowser->IsIsolatedMozBrowserElement() ||
mRemoteBrowser->HasOwnApp() != aOther->mRemoteBrowser->HasOwnApp()) {
aOther->mRemoteBrowser->IsIsolatedMozBrowserElement()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -1139,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();
}
@ -1314,12 +1311,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) {
@ -1465,8 +1462,7 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
}
if (ourDocshell->GetIsIsolatedMozBrowserElement() !=
otherDocshell->GetIsIsolatedMozBrowserElement() ||
ourDocshell->GetIsApp() != otherDocshell->GetIsApp()) {
otherDocshell->GetIsIsolatedMozBrowserElement()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -1516,10 +1512,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();
}
@ -1878,33 +1874,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()
{
@ -1925,55 +1908,6 @@ nsFrameLoader::OwnerIsIsolatedMozBrowserFrame()
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()
{
@ -1997,7 +1931,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);
@ -2005,7 +1939,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,
@ -2183,13 +2117,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,33 +2146,8 @@ nsFrameLoader::MaybeCreateDocShell()
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.mAppId = nsIScriptSecurityManager::NO_APP_ID;
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
}
@ -2270,7 +2179,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)) {
@ -2669,7 +2578,7 @@ nsFrameLoader::TryRemoteBrowser()
}
// <iframe mozbrowser> gets to skip these checks.
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
if (parentDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
return false;
}
@ -2710,8 +2619,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;
}
@ -2974,7 +2883,7 @@ nsFrameLoader::EnsureMessageManager()
}
if (!mIsTopLevelContent &&
!OwnerIsMozBrowserOrAppFrame() &&
!OwnerIsMozBrowserFrame() &&
!IsRemoteFrame() &&
!(mOwnerContent->IsXULElement() &&
mOwnerContent->AttrValueIs(kNameSpaceID_None,
@ -3289,7 +3198,7 @@ nsFrameLoader::GetLoadContext(nsILoadContext** aLoadContext)
void
nsFrameLoader::InitializeBrowserAPI()
{
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
return;
}
if (!IsRemoteFrame()) {
@ -3313,7 +3222,7 @@ nsFrameLoader::InitializeBrowserAPI()
void
nsFrameLoader::DestroyBrowserFrameScripts()
{
if (!OwnerIsMozBrowserOrAppFrame()) {
if (!OwnerIsMozBrowserFrame()) {
return;
}
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
@ -3394,24 +3303,11 @@ 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;
// set the userContextId on the attrs before we pass them into
// the tab context
@ -3446,8 +3342,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
bool tabContextUpdated =
aTabContext->SetTabContext(OwnerIsMozBrowserFrame(),
mIsPrerendered,
ownApp,
containingApp,
showAccelerators,
showFocusRings,
attrs,

Просмотреть файл

@ -36,7 +36,6 @@ class AutoResetInFrameSwap;
class nsITabParent;
class nsIDocShellTreeItem;
class nsIDocShellTreeOwner;
class mozIApplication;
namespace mozilla {
@ -242,20 +241,6 @@ 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.
@ -277,18 +262,6 @@ private:
*/
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.

Просмотреть файл

@ -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")
@ -992,7 +991,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")

Просмотреть файл

@ -4200,7 +4200,7 @@ nsGlobalWindow::GetParentOuter()
}
nsCOMPtr<nsPIDOMWindowOuter> parent;
if (mDocShell->GetIsMozBrowserOrApp()) {
if (mDocShell->GetIsMozBrowser()) {
parent = AsOuter();
} else {
parent = GetParent();
@ -4258,7 +4258,7 @@ nsGlobalWindow::GetParent()
}
nsCOMPtr<nsIDocShell> parent;
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsPIDOMWindowOuter> win = parent->GetWindow();
@ -4377,9 +4377,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();
}
@ -7700,7 +7700,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
@ -7750,7 +7750,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;
@ -8719,7 +8719,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.
@ -8740,14 +8740,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);
@ -9195,7 +9194,7 @@ nsGlobalWindow::GetFrameElementOuter(nsIPrincipal& aSubjectPrincipal)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
if (!mDocShell || mDocShell->GetIsMozBrowserOrApp()) {
if (!mDocShell || mDocShell->GetIsMozBrowser()) {
return nullptr;
}
@ -9230,7 +9229,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

Просмотреть файл

@ -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.
*/

Просмотреть файл

@ -96,14 +96,14 @@ nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
SetIsNotDOMBinding();
mozilla::HoldJSObjects(this);
// If owner corresponds to an <iframe mozbrowser> or <iframe mozapp>, we'll
// have to tweak our PreHandleEvent implementation.
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
// PreHandleEvent implementation.
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwner);
if (browserFrame) {
mIsBrowserOrAppFrame = browserFrame->GetReallyIsBrowserOrApp();
mIsBrowserFrame = browserFrame->GetReallyIsBrowser();
}
else {
mIsBrowserOrAppFrame = false;
mIsBrowserFrame = false;
}
}
@ -274,7 +274,7 @@ nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor)
return NS_OK;
}
if (mIsBrowserOrAppFrame &&
if (mIsBrowserFrame &&
(!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
if (mOwner) {
if (nsPIDOMWindowInner* innerWindow = mOwner->OwnerDoc()->GetInnerWindow()) {

Просмотреть файл

@ -166,10 +166,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
// PreHandleEvent.
bool mIsBrowserOrAppFrame;
// Is this the message manager for an in-process <iframe mozbrowser>? This
// affects where events get sent, so it affects PreHandleEvent.
bool mIsBrowserFrame;
bool mPreventEventsEscaping;
// We keep a strong reference to the frameloader after we've started

Просмотреть файл

@ -1243,17 +1243,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)
{

Просмотреть файл

@ -306,7 +306,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
continue;
}
BorrowedAttrInfo info = aContent->GetAttrInfoAt(index);
mozilla::dom::BorrowedAttrInfo info = aContent->GetAttrInfoAt(index);
const nsAttrName* name = info.mName;
int32_t namespaceID = name->NamespaceID();

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -113,7 +113,7 @@ var CopyPasteAssistent = {
let targetDocShell = currentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
if(targetDocShell.isMozBrowserOrApp) {
if(targetDocShell.isMozBrowser) {
break;
}
}

Просмотреть файл

@ -55,23 +55,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);
@ -89,19 +65,11 @@ function setPermissions() {
context: {
url: SimpleTest.getTestFileURL('/file_empty.html'),
originAttributes: {
appId: currentAppId,
inIsolatedMozBrowser: true
}
}
}];
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");

Просмотреть файл

@ -197,48 +197,6 @@ var gData = [
test: TestGet
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestGet
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestGet
},
{
type: 'music',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestGet
},
{
type: 'sdcard',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestGet
},
// Add
@ -315,52 +273,6 @@ var gData = [
test: TestAdd
},
// Certified application with permision granted
{
type: 'pictures',
mimeType: 'image/png',
fileExtension: '.png',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestAdd
},
{
type: 'videos',
mimeType: 'video/ogv',
fileExtension: '.ogv',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestAdd
},
{
type: 'music',
mimeType: 'audio/ogg',
fileExtension: '.ogg',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestAdd
},
{
type: 'sdcard',
mimeType: 'text/plain',
fileExtension: '.txt',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestAdd
},
// Delete
@ -428,48 +340,6 @@ var gData = [
test: TestDelete
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestDelete
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestDelete
},
{
type: 'music',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestDelete
},
{
type: 'sdcard',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestDelete
},
// Enumeration
// Web applications with no permissions
@ -536,48 +406,6 @@ var gData = [
test: TestEnumerate
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestEnumerate
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestEnumerate
},
{
type: 'music',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestEnumerate
},
{
type: 'sdcard',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestEnumerate
},
];
function setupTest(iframe,data) {
@ -610,9 +438,6 @@ function runTest() {
var data = gData.pop();
iframe.setAttribute('mozbrowser', '');
if (data.app) {
iframe.setAttribute('mozapp', data.app);
}
iframe.src = gTestUri;

Просмотреть файл

@ -262,68 +262,6 @@ let gData = [
test: TestGet
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestGet
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestGet
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestGet
},
{
type: 'music',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestGet
},
{
type: 'music',
shouldPass: false,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestGet
},
{
type: 'sdcard',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestGet
},
// Directory#createDirectory
// Web applications with no permissions
@ -382,44 +320,6 @@ let gData = [
test: TestCreateDirectory
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestCreateDirectory
},
{
type: 'videos',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestCreateDirectory
},
{
type: 'music',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestCreateDirectory
},
{
type: 'sdcard',
shouldPass: true,
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestCreateDirectory
},
// Directory#createFile
// Web applications with no permissions
@ -528,74 +428,6 @@ let gData = [
test: TestCreateFile
},
// Certified application with permision granted
{
type: 'pictures',
mimeType: 'image/png',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestCreateFile
},
{
type: 'videos',
mimeType: 'video/ogv',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestCreateFile
},
{
type: 'videos',
mimeType: 'video/ogg',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestCreateFile
},
{
type: 'music',
mimeType: 'audio/ogg',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestCreateFile
},
{
type: 'music',
mimeType: 'audio/ogg',
shouldPass: false,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestCreateFile
},
{
type: 'sdcard',
mimeType: 'text/plain',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestCreateFile
},
// Directory#remove
// Web applications with no permissions
@ -692,68 +524,6 @@ let gData = [
test: TestRemove
},
// Certified application with permision granted
{
type: 'pictures',
shouldPass: true,
fileExtension: '.png',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:pictures"],
test: TestRemove
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogv',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestRemove
},
{
type: 'videos',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:videos"],
test: TestRemove
},
{
type: 'music',
shouldPass: true,
fileExtension: '.ogg',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestRemove
},
{
type: 'music',
shouldPass: false,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:music"],
test: TestRemove
},
{
type: 'sdcard',
shouldPass: true,
fileExtension: '.txt',
app: "https://example.com/manifest_cert.webapp",
permissions: ["device-storage:sdcard"],
test: TestRemove
}
];
function setupTest(iframe,data) {
@ -786,9 +556,6 @@ function runTest() {
let data = gData.shift();
iframe.setAttribute('mozbrowser', '');
if (data.app) {
iframe.setAttribute('mozapp', data.app);
}
iframe.src = gTestUri;

Просмотреть файл

@ -1260,9 +1260,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);
}

Просмотреть файл

@ -16,7 +16,6 @@
#include "AudioChannelService.h"
#include "mozIApplication.h"
#include "nsComponentManagerUtils.h"
#include "nsFrameLoader.h"
#include "nsIAppsService.h"
@ -43,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;
}
@ -494,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;
}

Просмотреть файл

@ -124,7 +124,6 @@ public:
protected:
NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
NS_IMETHOD GetParentApplication(mozIApplication** aApplication) = 0;
void InitBrowserElementAPI();
void DestroyBrowserElementFrameScripts();

Просмотреть файл

@ -12,10 +12,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)
{
@ -496,12 +469,12 @@ 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 = false;
@ -528,34 +501,6 @@ nsGenericHTMLFrameElement::GetReallyIsBrowserOrApp(bool *aOut)
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)
{
@ -570,91 +515,6 @@ nsGenericHTMLFrameElement::GetIsolated(bool *aOut)
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,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>

Просмотреть файл

@ -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);

Просмотреть файл

@ -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
@ -123,12 +121,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>

Просмотреть файл

@ -190,8 +190,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);

Просмотреть файл

@ -13,22 +13,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;
[infallible] readonly attribute boolean reallyIsBrowser;
/**
* Gets whether this frame is an isolated frame.
@ -44,14 +35,6 @@ interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame
*/
[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;
/**
* Normally, a frame tries to create its frame loader when its src is
* modified, or its contentWindow is accessed.

Просмотреть файл

@ -78,7 +78,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,
@ -86,7 +85,6 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -131,14 +129,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);
}
@ -154,7 +150,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
if (!ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
@ -162,7 +157,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser)) {
return IPC_FAIL_NO_REASON(this);
}

Просмотреть файл

@ -43,7 +43,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual mozilla::ipc::PFileDescriptorSetChild*
@ -61,7 +60,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 mozilla::ipc::IPCResult RecvPBrowserConstructor(PBrowserChild* aCctor,
@ -69,7 +67,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;

Просмотреть файл

@ -103,7 +103,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,
@ -111,7 +110,6 @@ ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -144,14 +142,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);
}

Просмотреть файл

@ -43,7 +43,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
@ -54,10 +53,6 @@ public:
{
return mChildID;
}
virtual bool IsForApp() const override
{
return mIsForApp;
}
virtual bool IsForBrowser() const override
{
return mIsForBrowser;
@ -76,11 +71,6 @@ protected:
mChildID = aId;
}
void SetIsForApp(bool aIsForApp)
{
mIsForApp = aIsForApp;
}
void SetIsForBrowser(bool aIsForBrowser)
{
mIsForBrowser = aIsForBrowser;
@ -115,7 +105,6 @@ protected:
const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserParent(PBrowserParent*) override;
@ -141,7 +130,6 @@ protected: // members
RefPtr<ContentBridgeParent> mSelfRef;
Transport* mTransport; // owned
ContentParentId mChildID;
bool mIsForApp;
bool mIsForBrowser;
private:

Просмотреть файл

@ -591,7 +591,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
XRE_GetProcessType());
#endif
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
SendGetProcessAttributes(&mID, &mIsForBrowser);
InitProcessAttributes();
#ifdef NS_PRINTING
@ -607,10 +607,10 @@ void
ContentChild::InitProcessAttributes()
{
#ifdef MOZ_WIDGET_GONK
if (mIsForApp && !mIsForBrowser) {
SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
} else {
if (mIsForBrowser) {
SetProcessName(NS_LITERAL_STRING("Browser"), false);
} else {
SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
}
#else
SetProcessName(NS_LITERAL_STRING("Web Content"), true);
@ -723,7 +723,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);
@ -1518,14 +1518,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);
}
@ -1535,7 +1533,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentChild::SendPBrowserConstructor(aActor,
@ -1543,7 +1540,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
@ -1553,7 +1549,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
// This runs after AllocPBrowserChild() returns and the IPC machinery for this
@ -1578,7 +1573,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
mID = aCpID;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
InitProcessAttributes();
}
@ -2438,7 +2432,7 @@ ContentChild::RecvAppInit()
// 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) {
if (mIsForBrowser) {
PreloadSlowThings();
}

Просмотреть файл

@ -193,7 +193,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual bool DeallocPBrowserChild(PBrowserChild*) override;
@ -542,7 +541,6 @@ public:
uint32_t GetMsaaID() const { return mMsaaID; }
#endif
bool IsForApp() const { return mIsForApp; }
bool IsForBrowser() const { return mIsForBrowser; }
virtual PBlobChild*
@ -563,7 +561,6 @@ public:
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
virtual mozilla::ipc::IPCResult RecvPBrowserConstructor(PBrowserChild* aCctor,
@ -571,7 +568,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) override;
FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)
@ -677,7 +673,6 @@ private:
AppInfo mAppInfo;
bool mIsForApp;
bool mIsForBrowser;
bool mCanOverrideProcessName;
bool mIsAlive;

Просмотреть файл

@ -33,7 +33,6 @@
#include "HandlerServiceParent.h"
#include "IHistory.h"
#include "imgIContainer.h"
#include "mozIApplication.h"
#if defined(XP_WIN) && defined(ACCESSIBILITY)
#include "mozilla/a11y/AccessibleWrap.h"
#include "mozilla/WindowsVersion.h"
@ -505,8 +504,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;
@ -525,11 +523,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",
@ -567,8 +560,7 @@ static const char* sObserverTopics[] = {
ContentParent::PreallocateAppProcess()
{
RefPtr<ContentParent> process =
new ContentParent(/* app = */ nullptr,
/* aOpener = */ nullptr,
new ContentParent(/* aOpener = */ nullptr,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ true);
@ -580,57 +572,6 @@ ContentParent::PreallocateAppProcess()
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()
{
@ -752,10 +693,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);
}
@ -771,7 +712,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 sBrowserContentParents?");
if (p->mOpener == aOpener) {
return p.forget();
}
@ -785,8 +726,7 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
p->TransformPreallocatedIntoBrowser(aOpener);
} else {
// Failed in using the preallocated process: fork from the chrome process.
p = new ContentParent(/* app = */ nullptr,
aOpener,
p = new ContentParent(aOpener,
aForBrowserElement,
/* isForPreallocated = */ false);
@ -862,7 +802,6 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId)
{
@ -880,24 +819,16 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
return IPC_FAIL_NO_REASON(this);
}
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 IPC_OK();
}
*aCpId = cp->ChildID();
*aIsForApp = cp->IsForApp();
*aIsForBrowser = cp->IsForBrowser();
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
@ -1046,10 +977,10 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
}
/*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);
@ -1072,222 +1003,75 @@ 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 {
if (aOpenerContentParent) {
constructorSender = aOpenerContentParent;
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
initialPriority, nullptr, aFreshProcess);
if (!constructorSender) {
return nullptr;
}
}
// 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");
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
}
if (constructorSender) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner) {
return nullptr;
}
RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
if (!wbc) {
return nullptr;
}
uint32_t chromeFlags = 0;
wbc->GetChromeFlags(&chromeFlags);
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<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
if (docShell->GetAffectPrivateSessionLifetime()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
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;
}
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();
}
reused = !!p;
if (!p) {
p = GetNewOrPreallocatedAppProcess(ownApp, initialPriority, nullptr,
&tookPreallocated);
MOZ_ASSERT(p);
sAppContentParents->Put(manifestURL, p);
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
return constructedTabParent;
}
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 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);
}
// Otherwise just give up.
return nullptr;
}
return TabParent::GetFrom(browser);
return nullptr;
}
/*static*/ ContentBridgeParent*
@ -1300,13 +1084,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;
@ -1319,7 +1101,6 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
}
ContentBridgeParent* parent = child->GetLastBridge();
parent->SetChildID(cpId);
parent->SetIsForApp(isForApp);
parent->SetIsForBrowser(isForBrowser);
return parent;
}
@ -1482,48 +1263,12 @@ 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.
// Reset mIsForBrowser and mOSPrivileges for browser.
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL.Truncate();
mIsForBrowser = true;
}
@ -1610,29 +1355,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;
}
}
@ -1870,17 +1605,6 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
CrashReporterParent* crashReporter =
static_cast<CrashReporterParent*>(p);
// If we're an app process, always stomp the latest URI
// loaded in the child process with our manifest URL. We
// would rather associate the crashes with apps than
// random child windows loaded in them.
//
// XXX would be nice if we could get both ...
if (!mAppManifestURL.IsEmpty()) {
crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("URL"),
NS_ConvertUTF16toUTF8(mAppManifestURL));
}
// if mCreatedPairedMinidumps is true, we've already generated
// parent/child dumps for dekstop crashes.
if (!mCreatedPairedMinidumps) {
@ -1972,7 +1696,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;
@ -2029,7 +1753,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;
@ -2118,20 +1842,20 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
return true;
}
ContentParent::ContentParent(mozIApplication* aApp,
ContentParent* aOpener,
ContentParent::ContentParent(ContentParent* aOpener,
bool aIsForBrowser,
bool aIsForPreallocated)
: nsIContentParent()
, mOpener(aOpener)
, mIsForBrowser(aIsForBrowser)
, mIsPreallocated(aIsForPreallocated)
, mLargeAllocationProcess(false)
{
InitializeMembers(); // Perform common initialization.
// No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
// No more than one of aIsForBrowser and aIsForPreallocated should be
// true.
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
MOZ_ASSERT(aIsForBrowser + aIsForPreallocated <= 1);
mMetamorphosed = true;
@ -2141,13 +1865,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");
@ -2174,19 +1891,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
@ -2356,12 +2064,6 @@ ContentParent::IsAlive() const
return mIsAlive;
}
bool
ContentParent::IsForApp() const
{
return !mAppManifestURL.IsEmpty();
}
int32_t
ContentParent::Pid() const
{
@ -2891,10 +2593,9 @@ ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
mozilla::ipc::IPCResult
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp, bool* aIsForBrowser)
bool* aIsForBrowser)
{
*aCpId = mChildID;
*aIsForApp = IsForApp();
*aIsForBrowser = mIsForBrowser;
return IPC_OK();
@ -2986,14 +2687,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);
}
@ -3143,7 +2842,7 @@ ContentParent::KillHard(const char* aReason)
bool
ContentParent::IsPreallocated() const
{
return mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL;
return mIsPreallocated;
}
void
@ -3156,11 +2855,6 @@ ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
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("???");
}
@ -4118,7 +3812,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,
@ -4126,7 +3819,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
aContext,
aChromeFlags,
aCpId,
aIsForApp,
aIsForBrowser);
}
@ -4271,12 +3963,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",
@ -4731,7 +4420,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
thisTabParent = TabParent::GetFrom(aThisTab);
}
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowserOrApp())) {
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowser())) {
return IPC_FAIL_NO_REASON(this);
}

Просмотреть файл

@ -32,7 +32,6 @@
#define CHILD_PROCESS_SHUTDOWN_MESSAGE NS_LITERAL_STRING("child-process-shutdown")
class mozIApplication;
class nsConsoleService;
class nsICycleCollectorLogSink;
class nsIDumpGCAndCCLogsCallback;
@ -149,10 +148,10 @@ public:
* 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);
@ -240,7 +239,6 @@ public:
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId) override;
@ -329,8 +327,6 @@ public:
bool IsAlive() const;
virtual bool IsForApp() const override;
virtual bool IsForBrowser() const override
{
return mIsForBrowser;
@ -363,8 +359,6 @@ public:
ContentParentId ChildID() const override { return mChildID; }
const nsString& AppManifestURL() const { return mAppManifestURL; }
bool IsPreallocated() const;
/**
@ -561,8 +555,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;
@ -570,15 +563,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,
@ -594,16 +578,14 @@ 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
// No more than one of aIsForBrowser, and aIsForPreallocated may be
// true.
ContentParent(mozIApplication* aApp,
ContentParent* aOpener,
ContentParent(ContentParent* aOpener,
bool aIsForBrowser,
bool aIsForPreallocated);
@ -625,7 +607,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
@ -634,11 +616,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);
@ -701,7 +678,6 @@ private:
ProcessId aOtherProcess) override;
virtual mozilla::ipc::IPCResult RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser) override;
virtual mozilla::ipc::IPCResult
@ -724,7 +700,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;
@ -1102,17 +1077,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
@ -1128,12 +1094,13 @@ 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;
bool mSendPermissionUpdates;
bool mIsForBrowser;
bool mIsPreallocated;
// These variables track whether we've called Close() and KillHard() on our
// channel.

Просмотреть файл

@ -354,19 +354,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

Просмотреть файл

@ -143,15 +143,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;

Просмотреть файл

@ -391,27 +391,20 @@ both:
// The child creates the PBrowser as part of
// TabChild::BrowserFrameProvideWindow (which happens when the child's
// content calls window.open()), and the parent creates the PBrowser as part
// of ContentParent::CreateBrowserOrApp.
// of ContentParent::CreateBrowser.
//
// When the parent constructs a PBrowser, the child trusts the app token and
// other attributes it receives from the parent. In that case, the
// context should be FrameIPCTabContext.
// When the parent constructs a PBrowser, the child trusts the attributes it
// receives from the parent. In that case, the context should be
// FrameIPCTabContext.
//
// When the child constructs a PBrowser, the parent doesn't trust the app
// token it receives from the child. In this case, context must have type
// PopupIPCTabContext. The browser created using a PopupIPCTabContext has
// the opener PBrowser's app-id and containing-app-id. The parent checks
// that if the opener is a browser element, the context is also for a
// browser element.
//
// This allows the parent to prevent a malicious child from escalating its
// privileges by requesting a PBrowser corresponding to a highly-privileged
// app; the child can only request privileges for an app which the child has
// access to (in the form of a TabChild).
// When the child constructs a PBrowser, the parent doesn't trust the
// attributes it receives from the child. In this case, context must have
// type PopupIPCTabContext. The parent checks that if the opener is a
// browser element, the context is also for a browser element.
//
// Keep the last 3 attributes in sync with GetProcessAttributes!
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
ContentParentId cpId, bool isForApp, bool isForBrowser);
ContentParentId cpId, bool isForBrowser);
async PBlob(BlobConstructorParams params);
@ -678,15 +671,13 @@ parent:
* startup. (The message is sync to allow the content process to
* control when it receives the information.)
*
* |id| is a unique ID among all subprocesses. When |isForApp &&
* isForBrowser|, we're loading <browser> for an app. When
* |isForBrowser|, we're loading <browser>. When |!isForApp &&
* !isForBrowser|, we're probably loading <xul:browser remote>.
* |id| is a unique ID among all subprocesses. When
* |isForBrowser|, we're loading <browser> or <xul:browser remote>.
*
* Keep the return values in sync with PBrowser()!
*/
sync GetProcessAttributes()
returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
returns (ContentParentId cpId, bool isForBrowser);
sync GetXPCOMProcessAttributes()
returns (bool isOffline, bool isConnected, bool isLangRTL,
bool haveBidiKeyboards, nsString[] dictionaries,
@ -697,7 +688,7 @@ parent:
sync CreateChildProcess(IPCTabContext context,
ProcessPriority priority,
TabId openerTabId)
returns (ContentParentId cpId, bool isForApp, bool isForBrowser, TabId tabId);
returns (ContentParentId cpId, bool isForBrowser, TabId tabId);
sync BridgeToChildProcess(ContentParentId cpId);
async CreateGMPService();

Просмотреть файл

@ -55,7 +55,7 @@ both:
// Both the parent and the child can construct the PBrowser.
// See the comment in PContent::PBrowser().
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
ContentParentId cpId, bool isForApp, bool isForBrowser);
ContentParentId cpId, bool isForBrowser);
async PBlob(BlobConstructorParams params);

Просмотреть файл

@ -39,9 +39,6 @@ struct FrameIPCTabContext
// The originAttributes dictionary.
DocShellOriginAttributes originAttributes;
// The ID of the app containing this app/browser frame, if applicable.
uint32_t frameOwnerAppId;
// Whether this is a mozbrowser frame. <iframe mozbrowser mozapp> and
// <xul:browser> are not considered to be mozbrowser frames.
bool isMozBrowserElement;

Просмотреть файл

@ -861,10 +861,10 @@ ParticularProcessPriorityManager::OnRemoteBrowserFrameShown(nsISupports* aSubjec
return;
}
// Ignore notifications that aren't from a BrowserOrApp
bool isMozBrowserOrApp;
fl->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
if (isMozBrowserOrApp) {
// Ignore notifications that aren't from a Browser
bool isMozBrowser;
fl->GetOwnerIsMozBrowserFrame(&isMozBrowser);
if (isMozBrowser) {
ResetPriority();
}

Просмотреть файл

@ -417,7 +417,7 @@ TabChild::Create(nsIContentChild* aManager,
{
if (sPreallocatedTab &&
sPreallocatedTab->mChromeFlags == aChromeFlags &&
aContext.IsMozBrowserOrApp()) {
aContext.IsMozBrowser()) {
RefPtr<TabChild> child = sPreallocatedTab.get();
sPreallocatedTab = nullptr;
@ -792,8 +792,7 @@ TabChild::UpdateFrameType()
// TODO: Bug 1252794 - remove frameType from nsIDocShell.idl
docShell->SetFrameType(IsMozBrowserElement() ? nsIDocShell::FRAME_TYPE_BROWSER :
HasOwnApp() ? nsIDocShell::FRAME_TYPE_APP :
nsIDocShell::FRAME_TYPE_REGULAR);
nsIDocShell::FRAME_TYPE_REGULAR);
}
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChild)
@ -1103,11 +1102,11 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
{
*aReturn = nullptr;
// If aParent is inside an <iframe mozbrowser> or <iframe mozapp> and this
// isn't a request to open a modal-type window, we're going to create a new
// <iframe mozbrowser/mozapp> and return its window here.
// If aParent is inside an <iframe mozbrowser> and this isn't a request to
// open a modal-type window, we're going to create a new <iframe mozbrowser>
// and return its window here.
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
bool iframeMoz = (docshell && docshell->GetIsInMozBrowserOrApp() &&
bool iframeMoz = (docshell && docshell->GetIsInMozBrowser() &&
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_OPENAS_CHROME)));
@ -1214,24 +1213,6 @@ TabChild::~TabChild()
}
}
void
TabChild::SetProcessNameToAppName()
{
nsCOMPtr<mozIApplication> app = GetOwnApp();
if (!app) {
return;
}
nsAutoString appName;
nsresult rv = app->GetName(appName);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to retrieve app name");
return;
}
ContentChild::GetSingleton()->SetProcessName(appName, true);
}
mozilla::ipc::IPCResult
TabChild::RecvLoadURL(const nsCString& aURI,
const ShowInfo& aInfo)
@ -1243,8 +1224,6 @@ TabChild::RecvLoadURL(const nsCString& aURI,
}
ApplyShowInfo(aInfo);
SetProcessNameToAppName();
}
nsresult rv =
@ -1289,7 +1268,7 @@ TabChild::ApplyShowInfo(const ShowInfo& aInfo)
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
if (docShell) {
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
if (IsMozBrowserOrApp()) {
if (IsMozBrowser()) {
// B2G allows window.name to be set by changing the name attribute on the
// <iframe mozbrowser> element. window.open calls cause this attribute to
// be set to the correct value. A normal <xul:browser> element has no such
@ -2218,7 +2197,7 @@ TabChild::RecvSwappedWithOtherRemoteLoader(const IPCTabContext& aContext)
// Ignore previous value of mTriedBrowserInit since owner content has changed.
mTriedBrowserInit = true;
// Initialize the child side of the browser element machinery, if appropriate.
if (IsMozBrowserOrApp()) {
if (IsMozBrowser()) {
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
}
@ -2578,7 +2557,7 @@ TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
mTriedBrowserInit = true;
// Initialize the child side of the browser element machinery,
// if appropriate.
if (IsMozBrowserOrApp()) {
if (IsMozBrowser()) {
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
}
}

Просмотреть файл

@ -734,8 +734,6 @@ private:
void DestroyWindow();
void SetProcessNameToAppName();
void ApplyShowInfo(const ShowInfo& aInfo);
bool HasValidInnerSize();

Просмотреть файл

@ -8,7 +8,6 @@
#include "mozilla/dom/PTabContext.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/dom/TabChild.h"
#include "nsIAppsService.h"
#include "nsIScriptSecurityManager.h"
#include "nsServiceManagerUtils.h"
@ -24,7 +23,7 @@ TabContext::TabContext()
: mIsPrerendered(false)
, mInitialized(false)
, mIsMozBrowserElement(false)
, mContainingAppId(NO_APP_ID)
, mOriginAttributes()
, mShowAccelerators(UIStateChangeType_NoChange)
, mShowFocusRings(UIStateChangeType_NoChange)
{
@ -43,111 +42,9 @@ TabContext::IsIsolatedMozBrowserElement() const
}
bool
TabContext::IsMozBrowserOrApp() const
TabContext::IsMozBrowser() const
{
return HasOwnApp() || IsMozBrowserElement();
}
uint32_t
TabContext::OwnAppId() const
{
return mOriginAttributes.mAppId;
}
already_AddRefed<mozIApplication>
TabContext::GetOwnApp() const
{
nsCOMPtr<mozIApplication> ownApp = mOwnApp;
return ownApp.forget();
}
bool
TabContext::HasOwnApp() const
{
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
return !!ownApp;
}
uint32_t
TabContext::BrowserOwnerAppId() const
{
if (IsMozBrowserElement()) {
return mContainingAppId;
}
return NO_APP_ID;
}
already_AddRefed<mozIApplication>
TabContext::GetBrowserOwnerApp() const
{
nsCOMPtr<mozIApplication> ownerApp;
if (IsMozBrowserElement()) {
ownerApp = mContainingApp;
}
return ownerApp.forget();
}
bool
TabContext::HasBrowserOwnerApp() const
{
nsCOMPtr<mozIApplication> ownerApp = GetBrowserOwnerApp();
return !!ownerApp;
}
uint32_t
TabContext::AppOwnerAppId() const
{
if (HasOwnApp()) {
return mContainingAppId;
}
return NO_APP_ID;
}
already_AddRefed<mozIApplication>
TabContext::GetAppOwnerApp() const
{
nsCOMPtr<mozIApplication> ownerApp;
if (HasOwnApp()) {
ownerApp = mContainingApp;
}
return ownerApp.forget();
}
bool
TabContext::HasAppOwnerApp() const
{
nsCOMPtr<mozIApplication> ownerApp = GetAppOwnerApp();
return !!ownerApp;
}
uint32_t
TabContext::OwnOrContainingAppId() const
{
if (HasOwnApp()) {
return mOriginAttributes.mAppId;
}
return mContainingAppId;
}
already_AddRefed<mozIApplication>
TabContext::GetOwnOrContainingApp() const
{
nsCOMPtr<mozIApplication> ownOrContainingApp;
if (HasOwnApp()) {
ownOrContainingApp = mOwnApp;
} else {
ownOrContainingApp = mContainingApp;
}
return ownOrContainingApp.forget();
}
bool
TabContext::HasOwnOrContainingApp() const
{
nsCOMPtr<mozIApplication> ownOrContainingApp = GetOwnOrContainingApp();
return !!ownOrContainingApp;
return IsMozBrowserElement();
}
bool
@ -175,9 +72,7 @@ TabContext::UpdateTabContextAfterSwap(const TabContext& aContext)
// The only permissable change is to `mIsMozBrowserElement`. All other fields
// must match for the change to be accepted.
if (aContext.OwnAppId() != OwnAppId() ||
aContext.mContainingAppId != mContainingAppId ||
aContext.mOriginAttributes != mOriginAttributes) {
if (aContext.mOriginAttributes != mOriginAttributes) {
return false;
}
@ -212,8 +107,6 @@ TabContext::ShowFocusRings() const
bool
TabContext::SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered,
mozIApplication* aOwnApp,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
@ -221,34 +114,13 @@ TabContext::SetTabContext(bool aIsMozBrowserElement,
{
NS_ENSURE_FALSE(mInitialized, false);
// Get ids for both apps and only write to our member variables after we've
// verified that this worked.
uint32_t ownAppId = NO_APP_ID;
if (aOwnApp) {
nsresult rv = aOwnApp->GetLocalId(&ownAppId);
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(ownAppId != NO_APP_ID, false);
}
uint32_t containingAppId = NO_APP_ID;
if (aAppFrameOwnerApp) {
nsresult rv = aAppFrameOwnerApp->GetLocalId(&containingAppId);
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(containingAppId != NO_APP_ID, false);
}
// Veryify that app id matches mAppId passed in originAttributes
MOZ_RELEASE_ASSERT((aOwnApp && aOriginAttributes.mAppId == ownAppId) ||
(aAppFrameOwnerApp && aOriginAttributes.mAppId == containingAppId) ||
aOriginAttributes.mAppId == NO_APP_ID);
MOZ_RELEASE_ASSERT(aOriginAttributes.mAppId == NO_APP_ID);
mInitialized = true;
mIsMozBrowserElement = aIsMozBrowserElement;
mIsPrerendered = aIsPrerendered;
mOriginAttributes = aOriginAttributes;
mContainingAppId = containingAppId;
mOwnApp = aOwnApp;
mContainingApp = aAppFrameOwnerApp;
mPresentationURL = aPresentationURL;
mShowAccelerators = aShowAccelerators;
mShowFocusRings = aShowFocusRings;
@ -259,7 +131,6 @@ IPCTabContext
TabContext::AsIPCTabContext() const
{
return IPCTabContext(FrameIPCTabContext(mOriginAttributes,
mContainingAppId,
mIsMozBrowserElement,
mIsPrerendered,
mPresentationURL,
@ -267,24 +138,11 @@ TabContext::AsIPCTabContext() const
mShowFocusRings));
}
static already_AddRefed<mozIApplication>
GetAppForId(uint32_t aAppId)
{
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(appsService, nullptr);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByLocalId(aAppId, getter_AddRefs(app));
return app.forget();
}
MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
: mInvalidReason(nullptr)
{
bool isMozBrowserElement = false;
bool isPrerendered = false;
uint32_t containingAppId = NO_APP_ID;
DocShellOriginAttributes originAttributes;
nsAutoString presentationURL;
UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
@ -335,11 +193,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
// opener app.
isMozBrowserElement = ipcContext.isMozBrowserElement();
originAttributes = context->mOriginAttributes;
if (isMozBrowserElement) {
containingAppId = context->OwnOrContainingAppId();
} else {
containingAppId = context->mContainingAppId;
}
break;
}
case IPCTabContext::TFrameIPCTabContext: {
@ -348,7 +201,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
isMozBrowserElement = ipcContext.isMozBrowserElement();
isPrerendered = ipcContext.isPrerendered();
containingAppId = ipcContext.frameOwnerAppId();
presentationURL = ipcContext.presentationURL();
showAccelerators = ipcContext.showAccelerators();
showFocusRings = ipcContext.showFocusRings();
@ -369,7 +221,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
return;
}
containingAppId = NO_APP_ID;
break;
}
default: {
@ -377,28 +228,9 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
}
}
nsCOMPtr<mozIApplication> ownApp;
if (!isMozBrowserElement) {
// mAppId corresponds to OwnOrContainingAppId; if isMozBrowserElement is
// false then it's ownApp otherwise it's containingApp
ownApp = GetAppForId(originAttributes.mAppId);
if ((ownApp == nullptr) != (originAttributes.mAppId == NO_APP_ID)) {
mInvalidReason = "Got an ownAppId that didn't correspond to an app.";
return;
}
}
nsCOMPtr<mozIApplication> containingApp = GetAppForId(containingAppId);
if ((containingApp == nullptr) != (containingAppId == NO_APP_ID)) {
mInvalidReason = "Got a containingAppId that didn't correspond to an app.";
return;
}
bool rv;
rv = mTabContext.SetTabContext(isMozBrowserElement,
isPrerendered,
ownApp,
containingApp,
showAccelerators,
showFocusRings,
originAttributes,

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef mozilla_dom_TabContext_h
#define mozilla_dom_TabContext_h
#include "mozIApplication.h"
#include "nsCOMPtr.h"
#include "mozilla/BasePrincipal.h"
#include "nsPIDOMWindow.h"
@ -19,9 +18,7 @@ namespace dom {
class IPCTabContext;
/**
* TabContext encapsulates information about an iframe that may be a mozbrowser
* or mozapp. You can ask whether a TabContext corresponds to a mozbrowser or
* mozapp, get the app that contains the browser, and so on.
* TabContext encapsulates information about an iframe that may be a mozbrowser.
*
* TabParent and TabChild both inherit from TabContext, and you can also have
* standalone TabContext objects.
@ -38,91 +35,38 @@ public:
/* (The implicit copy-constructor and operator= are fine.) */
/**
* Generates IPCTabContext of type BrowserFrameIPCTabContext or
* AppFrameIPCTabContext from this TabContext's information.
* Generates IPCTabContext of type BrowserFrameIPCTabContext from this
* TabContext's information.
*/
IPCTabContext AsIPCTabContext() const;
/**
* Does this TabContext correspond to a mozbrowser?
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements.
*
* If IsMozBrowserElement() is true, HasOwnApp() and HasAppOwnerApp() are
* guaranteed to be false.
*
* If IsMozBrowserElement() is false, HasBrowserOwnerApp() is guaranteed to be
* false.
* <iframe mozbrowser> is a mozbrowser element, but <xul:browser> is not.
*/
bool IsMozBrowserElement() const;
/**
* Does this TabContext correspond to an isolated 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 by
* chrome pages.
* <iframe mozbrowser> is a mozbrowser element, but <xul:browser> is not.
* <iframe mozbrowser noisolation> does not count as isolated since isolation
* is disabled. Isolation can only be disabled by chrome pages.
*/
bool IsIsolatedMozBrowserElement() const;
/**
* Does this TabContext correspond to a mozbrowser or mozapp? This is
* equivalent to IsMozBrowserElement() || HasOwnApp(). Returns false for
* <xul:browser>, which is neither a mozbrowser nor a mozapp.
* Does this TabContext correspond to a mozbrowser? This is equivalent to
* IsMozBrowserElement(). Returns false for <xul:browser>, which isn't a
* mozbrowser.
*/
bool IsMozBrowserOrApp() const;
/**
* OwnAppId() returns the id of the app which directly corresponds to this
* context's frame. GetOwnApp() returns the corresponding app object, and
* HasOwnApp() returns true iff GetOwnApp() would return a non-null value.
*
* If HasOwnApp() is true, IsMozBrowserElement() is guaranteed to be
* false.
*/
uint32_t OwnAppId() const;
already_AddRefed<mozIApplication> GetOwnApp() const;
bool HasOwnApp() const;
/**
* BrowserOwnerAppId() gets the ID of the app which contains this browser
* frame. If this is not a mozbrowser frame (if !IsMozBrowserElement()), then
* BrowserOwnerAppId() is guaranteed to return NO_APP_ID.
*
* Even if we are a browser frame, BrowserOwnerAppId() may still return
* NO_APP_ID, if this browser frame is not contained inside an app.
*/
uint32_t BrowserOwnerAppId() const;
already_AddRefed<mozIApplication> GetBrowserOwnerApp() const;
bool HasBrowserOwnerApp() const;
/**
* AppOwnerAppId() gets the ID of the app which contains this app frame. If
* this is not an app frame (i.e., if !HasOwnApp()), then AppOwnerAppId() is
* guaranteed to return NO_APP_ID.
*
* Even if we are an app frame, AppOwnerAppId() may still return NO_APP_ID, if
* this app frame is not contained inside an app.
*/
uint32_t AppOwnerAppId() const;
already_AddRefed<mozIApplication> GetAppOwnerApp() const;
bool HasAppOwnerApp() const;
/**
* OwnOrContainingAppId() gets the ID of this frame, if HasOwnApp(). If this
* frame does not have its own app, it gets the ID of the app which contains
* this frame (i.e., the result of {Browser,App}OwnerAppId(), as applicable).
*/
uint32_t OwnOrContainingAppId() const;
already_AddRefed<mozIApplication> GetOwnOrContainingApp() const;
bool HasOwnOrContainingApp() const;
bool IsMozBrowser() const;
/**
* OriginAttributesRef() returns the DocShellOriginAttributes of this frame to
* the caller. This is used to store any attribute associated with the frame's
* docshell, such as the AppId.
* docshell.
*/
const DocShellOriginAttributes& OriginAttributesRef() const;
@ -157,17 +101,8 @@ protected:
*/
void SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing);
/**
* Set the TabContext for this frame. This can either be:
* - an app frame (with the given own app) inside the given owner app. Either
* apps can be null.
* - a browser frame inside the given owner app (which may be null).
* - a non-browser, non-app frame. Both own app and owner app should be null.
*/
bool SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered,
mozIApplication* aOwnApp,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
@ -198,29 +133,11 @@ private:
/**
* Whether this TabContext corresponds to a mozbrowser.
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* <iframe mozbrowser> and <xul:browser> are not considered to be
* mozbrowser elements.
*/
bool mIsMozBrowserElement;
/**
* This TabContext's own app. If this is non-null, then this
* TabContext corresponds to an app, and mIsMozBrowserElement must be false.
*/
nsCOMPtr<mozIApplication> mOwnApp;
/**
* This TabContext's containing app. If mIsMozBrowserElement, this
* corresponds to the app which contains the browser frame; otherwise, this
* corresponds to the app which contains the app frame.
*/
nsCOMPtr<mozIApplication> mContainingApp;
/*
* Cache of mContainingApp->GetLocalId().
*/
uint32_t mContainingAppId;
/**
* DocShellOriginAttributes of the top level tab docShell
*/
@ -254,8 +171,6 @@ public:
bool
SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered,
mozIApplication* aOwnApp,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
@ -263,8 +178,6 @@ public:
{
return TabContext::SetTabContext(aIsMozBrowserElement,
aIsPrerendered,
aOwnApp,
aAppFrameOwnerApp,
aShowAccelerators,
aShowFocusRings,
aOriginAttributes,
@ -276,10 +189,9 @@ public:
* MaybeInvalidTabContext is a simple class that lets you transform an
* IPCTabContext into a TabContext.
*
* The issue is that an IPCTabContext is not necessarily valid; for example, it
* might specify an app-id which doesn't exist. So to convert an IPCTabContext
* into a TabContext, you construct a MaybeInvalidTabContext, check whether it's
* valid, and, if so, read out your TabContext.
* The issue is that an IPCTabContext is not necessarily valid. So to convert
* an IPCTabContext into a TabContext, you construct a MaybeInvalidTabContext,
* check whether it's valid, and, if so, read out your TabContext.
*
* Example usage:
*

Просмотреть файл

@ -10,7 +10,6 @@
#include "AudioChannelService.h"
#include "AppProcessChecker.h"
#include "mozIApplication.h"
#ifdef ACCESSIBILITY
#include "mozilla/a11y/DocAccessibleParent.h"
#include "nsAccessibilityService.h"
@ -2991,7 +2990,6 @@ public:
NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL
NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL
NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool*) NO_IMPL
NS_IMETHOD GetAppId(uint32_t*) NO_IMPL
NS_IMETHOD GetOriginAttributes(JS::MutableHandleValue) NO_IMPL
NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL
NS_IMETHOD SetRemoteTabs(bool) NO_IMPL

Просмотреть файл

@ -44,7 +44,6 @@ nsIContentChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
// We'll happily accept any kind of IPCTabContext here; we don't need to

Просмотреть файл

@ -69,7 +69,6 @@ public:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser) = 0;
virtual mozilla::ipc::PFileDescriptorSetChild*
@ -86,7 +85,6 @@ protected:
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);

Просмотреть файл

@ -122,11 +122,9 @@ nsIContentParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
Unused << aCpId;
Unused << aIsForApp;
Unused << aIsForBrowser;
if (!CanOpenBrowser(aContext)) {

Просмотреть файл

@ -61,7 +61,6 @@ public:
BlobParent* GetOrCreateActorForBlobImpl(BlobImpl* aImpl);
virtual ContentParentId ChildID() const = 0;
virtual bool IsForApp() const = 0;
virtual bool IsForBrowser() const = 0;
MOZ_MUST_USE virtual PBlobParent*
@ -74,7 +73,6 @@ public:
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser) = 0;
virtual bool IsContentParent() const { return false; }
@ -100,7 +98,6 @@ protected: // IPDL methods
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserParent(PBrowserParent* frame);

Просмотреть файл

@ -1906,29 +1906,15 @@ MediaManager::NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow,
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
bool isApp = false;
nsString requestURL;
nsCString pageURL;
nsCOMPtr<nsIURI> docURI = aWindow->GetDocumentURI();
NS_ENSURE_TRUE(docURI, NS_ERROR_FAILURE);
if (nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell()) {
isApp = docShell->GetIsApp();
if (isApp) {
nsresult rv = docShell->GetAppManifestURL(requestURL);
NS_ENSURE_SUCCESS(rv, rv);
}
}
nsresult rv = docURI->GetSpec(pageURL);
NS_ENSURE_SUCCESS(rv, rv);
if (!isApp) {
nsCString pageURL;
nsCOMPtr<nsIURI> docURI = aWindow->GetDocumentURI();
NS_ENSURE_TRUE(docURI, NS_ERROR_FAILURE);
NS_ConvertUTF8toUTF16 requestURL(pageURL);
nsresult rv = docURI->GetSpec(pageURL);
NS_ENSURE_SUCCESS(rv, rv);
requestURL = NS_ConvertUTF8toUTF16(pageURL);
}
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), isApp);
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
obs->NotifyObservers(static_cast<nsIPropertyBag2*>(props),

Просмотреть файл

@ -65,13 +65,7 @@ TCPServerSocketParent::Init()
uint32_t
TCPServerSocketParent::GetAppId()
{
const PContentParent *content = Manager()->Manager();
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
TabParent *tab = TabParent::GetFrom(browser);
return tab->OwnAppId();
} else {
return nsIScriptSecurityManager::UNKNOWN_APP_ID;
}
return nsIScriptSecurityManager::UNKNOWN_APP_ID;
}
bool

Просмотреть файл

@ -73,13 +73,7 @@ TCPSocketParentBase::~TCPSocketParentBase()
uint32_t
TCPSocketParent::GetAppId()
{
const PContentParent *content = Manager()->Manager();
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
TabParent *tab = TabParent::GetFrom(browser);
return tab->OwnAppId();
} else {
return nsIScriptSecurityManager::UNKNOWN_APP_ID;
}
return nsIScriptSecurityManager::UNKNOWN_APP_ID;
};
bool
@ -211,20 +205,15 @@ TCPSocketParent::RecvOpenBind(const nsCString& aRemoteHost,
}
}
// Obtain App ID
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
bool inIsolatedMozBrowser = false;
const PContentParent *content = Manager()->Manager();
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
// appId's are for B2G only currently, where managees.Count() == 1
// This is not guaranteed currently in Desktop, so skip this there.
TabParent *tab = TabParent::GetFrom(browser);
appId = tab->OwnAppId();
inIsolatedMozBrowser = tab->IsIsolatedMozBrowserElement();
}
mSocket = new TCPSocket(nullptr, NS_ConvertUTF8toUTF16(aRemoteHost), aRemotePort, aUseSSL, aUseArrayBuffers);
mSocket->SetAppIdAndBrowser(appId, inIsolatedMozBrowser);
mSocket->SetAppIdAndBrowser(nsIScriptSecurityManager::NO_APP_ID, inIsolatedMozBrowser);
mSocket->SetSocketBridgeParent(this);
rv = mSocket->InitWithUnconnectedTransport(socketTransport);
NS_ENSURE_SUCCESS(rv, IPC_OK());

Просмотреть файл

@ -23,11 +23,11 @@ interface nsINetworkStatsServiceProxy : nsISupports
* An interface used to record per-app traffic data.
* @param aAppId app id
* @param aIsInIsolatedMozBrowser
* true if the frame is 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.
* true if the frame is an isolated mozbrowser element. <xul:browser>
* is 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.
* @param aNetworkInterface network
* @param aTimeStamp time stamp
* @param aRxBytes received data amount

Просмотреть файл

@ -1,61 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=815105
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 815105 </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=815105">Mozilla Bug 815105 </a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript;version=1.8" src="file_framework.js"></script>
<script type="application/javascript;version=1.8">
/*
* embed-apps allows us to create app iframes,
* creator must also have the browser permission
*/
function verifier(success, failure) {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', '');
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
iframe.src = "http://example.org/";
iframe.addEventListener('load', function() {
var appStatus = SpecialPowers.wrap(iframe)
.contentDocument.nodePrincipal.appStatus;
if (appStatus != SpecialPowers.Ci
.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
success("Got mozapp");
} else {
failure("Didn't get mozapp") ;
}
});
document.getElementById('content').appendChild(iframe);
}
var gData = [
{
perm: ["embed-apps", "browser"],
/*
* Android doesn't have working apps
* Mobile is for B2G which has a weird testing setup
* the app iframe gets embed in the test-container iframe
* which returns APP_STATUS_NOT_INSTALLED
*/
skip: ["Android", "Mobile"],
settings: [["dom.mozBrowserFramesEnabled", true]],
verifier: verifier.toSource(),
}
]
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -132,7 +132,7 @@ Presentation::HasReceiverSupport() const
}
if (!Preferences::GetBool("dom.presentation.testing.simulate-receiver") &&
!docShell->GetIsInMozBrowserOrApp() &&
!docShell->GetIsInMozBrowser() &&
!docShell->GetIsTopLevelContentDocShell()) {
return false;
}

Просмотреть файл

@ -60,11 +60,5 @@ partial interface HTMLIFrameElement {
attribute boolean mozbrowser;
};
partial interface HTMLIFrameElement {
// nsIMozBrowserFrame
[ChromeOnly]
readonly attribute DOMString appManifestURL;
};
HTMLIFrameElement implements MozFrameLoaderOwner;
HTMLIFrameElement implements BrowserElement;

Просмотреть файл

@ -20,7 +20,7 @@ dictionary NetworkStatsGetOptions
* If it is set as true, only the browsing traffic, which is generated from
* the mozbrowser iframe element within an app, is returned in result.
* If it is set as false or not set, the total traffic, which is generated
* from both the mozapp and mozbrowser iframe elements, is returned.
* from mozbrowser iframe elements, is returned.
*/
boolean browsingTrafficOnly = false;
};

Просмотреть файл

@ -1632,17 +1632,6 @@ nsXULElement::GetFrameLoader()
return already_AddRefed<nsFrameLoader>(static_cast<nsFrameLoader*>(loader.forget().take()));
}
nsresult
nsXULElement::GetParentApplication(mozIApplication** aApplication)
{
if (!aApplication) {
return NS_ERROR_FAILURE;
}
*aApplication = nullptr;
return NS_OK;
}
void
nsXULElement::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, ErrorResult& aRv)
{

Просмотреть файл

@ -411,7 +411,6 @@ public:
virtual mozilla::EventStates IntrinsicState() const override;
nsresult GetFrameLoaderXPCOM(nsIFrameLoader** aFrameLoader);
nsresult GetParentApplication(mozIApplication** aApplication);
void PresetOpenerWindow(mozIDOMWindowProxy* aWindow, ErrorResult& aRv);
nsresult SetIsPrerendered();

Просмотреть файл

@ -1987,7 +1987,7 @@ nsWindowWatcher::CalculateChromeFlagsForParent(mozIDOMWindowProxy* aParent,
// Disable CHROME_OPENAS_DIALOG if the window is inside <iframe mozbrowser>.
// It's up to the embedder to interpret what dialog=1 means.
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
if (docshell && docshell->GetIsInMozBrowserOrApp()) {
if (docshell && docshell->GetIsInMozBrowser()) {
chromeFlags &= ~nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
}

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsContentUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIAppsService.h"
#include "mozIApplication.h"
#include "nsIEffectiveTLDService.h"
#include "nsPIDOMWindow.h"
#include "nsIDocument.h"

Просмотреть файл

@ -6996,20 +6996,6 @@ CheckPermissionForBeforeAfterKeyboardEvent(Element* aElement)
if (permission == nsIPermissionManager::ALLOW_ACTION) {
return true;
}
// Check "embed-apps" permission for later use.
permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromPrincipal(principal, "embed-apps", &permission);
}
// An element can handle before events and after events if the following
// conditions are met:
// 1) <iframe mozbrowser mozapp>
// 2) it has "embed-apps" permission.
nsCOMPtr<nsIMozBrowserFrame> browserFrame(do_QueryInterface(aElement));
if ((permission == nsIPermissionManager::ALLOW_ACTION) &&
browserFrame && browserFrame->GetReallyIsApp()) {
return true;
}
return false;

Просмотреть файл

@ -86,7 +86,7 @@ ShouldInTopLayerForFullscreen(Element* aElement)
return false;
}
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aElement);
if (browserFrame && browserFrame->GetReallyIsBrowserOrApp()) {
if (browserFrame && browserFrame->GetReallyIsBrowser()) {
return false;
}
return true;

Просмотреть файл

@ -2075,7 +2075,7 @@ static bool SelectorMatches(Element* aElement,
nsCOMPtr<nsIMozBrowserFrame>
browserFrame = do_QueryInterface(aElement);
if (!browserFrame ||
!browserFrame->GetReallyIsBrowserOrApp()) {
!browserFrame->GetReallyIsBrowser()) {
return false;
}
}

Просмотреть файл

@ -309,7 +309,6 @@ this.OnRefTestLoad = function OnRefTestLoad(win)
if (gBrowserIsIframe) {
gBrowser = gContainingWindow.document.createElementNS(XHTML_NS, "iframe");
gBrowser.setAttribute("mozbrowser", "");
gBrowser.setAttribute("mozapp", prefs.getCharPref("b2g.system_manifest_url"));
} else {
gBrowser = gContainingWindow.document.createElementNS(XUL_NS, "xul:browser");
}

Просмотреть файл

@ -3416,15 +3416,6 @@ Tab.prototype = {
BrowserApp.deck.selectedPanel = selectedPanel;
let attrs = {};
if (BrowserApp.manifestUrl) {
let appsService = Cc["@mozilla.org/AppsService;1"].getService(Ci.nsIAppsService);
let manifest = appsService.getAppByManifestURL(BrowserApp.manifestUrl);
if (manifest) {
let app = manifest.QueryInterface(Ci.mozIApplication);
this.browser.docShell.frameType = Ci.nsIDocShell.FRAME_TYPE_APP;
attrs['appId'] = app.localId;
}
}
// Must be called after appendChild so the docShell has been created.
this.setActive(false);

Просмотреть файл

@ -963,8 +963,6 @@ pref("devtools.debugger.force-local", true);
pref("devtools.debugger.prompt-connection", true);
// Block tools from seeing / interacting with certified apps
pref("devtools.debugger.forbid-certified-apps", true);
// List of permissions that a sideloaded app can't ask for
pref("devtools.apps.forbidden-permissions", "embed-apps");
// DevTools default color unit
pref("devtools.defaultColorUnit", "authored");

Просмотреть файл

@ -568,15 +568,12 @@ NS_LoadGroupMatchesPrincipal(nsILoadGroup *aLoadGroup,
getter_AddRefs(loadContext));
NS_ENSURE_TRUE(loadContext, false);
// Verify load context appId and browser flag match the principal
uint32_t contextAppId;
// Verify load context browser flag match the principal
bool contextInIsolatedBrowser;
nsresult rv = loadContext->GetAppId(&contextAppId);
NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInIsolatedMozBrowserElement(&contextInIsolatedBrowser);
nsresult rv = loadContext->GetIsInIsolatedMozBrowserElement(&contextInIsolatedBrowser);
NS_ENSURE_SUCCESS(rv, false);
return contextAppId == aPrincipal->GetAppId() &&
return nsIScriptSecurityManager::NO_APP_ID == aPrincipal->GetAppId() &&
contextInIsolatedBrowser == aPrincipal->GetIsInIsolatedMozBrowserElement();
}
@ -2394,14 +2391,8 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
return NS_OK;
}
uint32_t loadContextAppId = 0;
nsresult rv = loadContext->GetAppId(&loadContextAppId);
if (NS_FAILED(rv)) {
return NS_ERROR_UNEXPECTED;
}
bool loadContextIsInBE = false;
rv = loadContext->GetIsInIsolatedMozBrowserElement(&loadContextIsInBE);
nsresult rv = loadContext->GetIsInIsolatedMozBrowserElement(&loadContextIsInBE);
if (NS_FAILED(rv)) {
return NS_ERROR_UNEXPECTED;
}
@ -2411,17 +2402,13 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
loadContext->GetOriginAttributes(originAttrsLoadContext);
LOG(("NS_CompareLoadInfoAndLoadContext - loadInfo: %d, %d, %d, %d; "
"loadContext: %d %d, %d, %d. [channel=%p]",
"loadContext: %d %d, %d. [channel=%p]",
originAttrsLoadInfo.mAppId, originAttrsLoadInfo.mInIsolatedMozBrowser,
originAttrsLoadInfo.mUserContextId, originAttrsLoadInfo.mPrivateBrowsingId,
loadContextAppId, loadContextIsInBE,
loadContextIsInBE,
originAttrsLoadContext.mUserContextId, originAttrsLoadContext.mPrivateBrowsingId,
aChannel));
MOZ_ASSERT(originAttrsLoadInfo.mAppId == loadContextAppId,
"AppId in the loadContext and in the loadInfo are not the "
"same!");
MOZ_ASSERT(originAttrsLoadInfo.mInIsolatedMozBrowser ==
loadContextIsInBE,
"The value of InIsolatedMozBrowser in the loadContext and in "

Просмотреть файл

@ -51,7 +51,6 @@
#include "mozilla/FileUtils.h"
#include "mozilla/Telemetry.h"
#include "nsIAppsService.h"
#include "mozIApplication.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsIConsoleService.h"
#include "nsVariant.h"

Просмотреть файл

@ -177,20 +177,8 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
nsAutoCString debugString;
for (uint32_t i = 0; i < contextArray.Length(); i++) {
TabContext tabContext = contextArray[i];
uint32_t appId = tabContext.OwnOrContainingAppId();
bool inBrowserElement = aSerialized.mOriginAttributes.mInIsolatedMozBrowser;
if (appId == NECKO_UNKNOWN_APP_ID) {
debugString.Append("u,");
continue;
}
// We may get appID=NO_APP if child frame is neither a browser nor an app
if (appId == NECKO_NO_APP_ID && tabContext.HasOwnApp()) {
// NECKO_NO_APP_ID but also is an app? Weird, skip.
debugString.Append("h,");
continue;
}
if (aSerialized.mOriginAttributes.mUserContextId != tabContext.OriginAttributesRef().mUserContextId) {
debugString.Append("(");
debugString.AppendInt(aSerialized.mOriginAttributes.mUserContextId);
@ -200,7 +188,7 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
continue;
}
aAttrs = DocShellOriginAttributes();
aAttrs.mAppId = appId;
aAttrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
aAttrs.mInIsolatedMozBrowser = inBrowserElement;
aAttrs.mUserContextId = aSerialized.mOriginAttributes.mUserContextId;
aAttrs.mPrivateBrowsingId = aSerialized.mOriginAttributes.mPrivateBrowsingId;

Просмотреть файл

@ -1,43 +0,0 @@
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function is_app_offline(appId) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
return ioservice.isAppOffline(appId);
}
var events_observed_no = 0;
// Holds the last observed app-offline event
var info = null;
function observer(aSubject, aTopic, aData) {
events_observed_no++;
info = aSubject.QueryInterface(Ci.nsIAppOfflineInfo);
dump("ChildObserver - subject: {" + aSubject.appId + ", " + aSubject.mode + "} ");
}
// Add observer for the app-offline notification
function run_test() {
Services.obs.addObserver(observer, "network:app-offline-status-changed", false);
}
// Chech that the app has the proper offline status
function check_status(appId, status)
{
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Check that the app has the proper offline status
// and that the correct notification has been received
function check_notification_and_status(appId, status) {
do_check_eq(info.appId, appId);
do_check_eq(info.mode, status);
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Remove the observer from the child process
function finished() {
Services.obs.removeObserver(observer, "network:app-offline-status-changed");
do_check_eq(events_observed_no, 2);
}

Просмотреть файл

@ -24,7 +24,6 @@
"desktop-notification":{},
"idle":{},
"network-events":{},
"embed-apps":{},
"audio-channel-content":{},
"audio-channel-alarm":{},
"before-after-keyboard-event":{}

Просмотреть файл

@ -263,13 +263,6 @@ OfflineCacheUpdateParent::GetIsInIsolatedMozBrowserElement(bool *aIsInIsolatedMo
return mLoadingPrincipal->GetIsInIsolatedMozBrowserElement(aIsInIsolatedMozBrowserElement);
}
NS_IMETHODIMP
OfflineCacheUpdateParent::GetAppId(uint32_t *aAppId)
{
NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED);
return mLoadingPrincipal->GetAppId(aAppId);
}
NS_IMETHODIMP
OfflineCacheUpdateParent::GetOriginAttributes(JS::MutableHandleValue aAttrs)
{

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше