Bug 1059662 - Disallow OOP app to embed in-proc apps. r=fabrice

Some mochitest that use embed-apps in an oop context is disabled.

--HG--
extra : rebase_source : 72de2cdae86eb8d55e642529cd4aae0af97e4e96
This commit is contained in:
Kan-Ru Chen (陳侃如) 2014-11-11 10:25:36 +08:00
Родитель b0f3436ee5
Коммит c57dcf090e
11 изменённых файлов: 103 добавлений и 1 удалений

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

@ -26,6 +26,7 @@ support-files =
[test_app_enabled.html]
[test_app_update.html]
skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
[test_bug_795164.html]
[test_import_export.html]
[test_install_multiple_apps_origin.html]
@ -42,3 +43,4 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
[test_theme_role.html]
[test_web_app_install.html]
[test_widget.html]
skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app

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

@ -0,0 +1,42 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 1059662 - Only allow a app to embed others apps when it runs
// in-process.
//
// The "inproc" version of this test should successfully embed the
// app, and the "oop" version of this test should fail to embed the
// app.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
SpecialPowers.setAllAppsLaunchable(true);
function runTest() {
var canEmbedApp = !browserElementTestHelpers.getOOPByDefaultPref();
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
is(e.detail.message == 'app', canEmbedApp, e.detail.message);
SimpleTest.finish();
});
document.body.appendChild(iframe);
var context = { 'url': 'http://example.org',
'appId': SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
'isInBrowserElement': true };
SpecialPowers.pushPermissions([
{'type': 'browser', 'allow': 1, 'context': context},
{'type': 'embed-apps', 'allow': 1, 'context': context}
], function() {
iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_DisallowEmbedAppsInOOP.html';
});
}
addEventListener('testready', runTest);

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

@ -0,0 +1,19 @@
<html>
<head>
<script type="text/javascript">
addEventListener('load', function(e) {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.setAttribute('remote', 'false');
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
alert(e.detail.message);
});
document.body.appendChild(iframe);
iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html';
});
</script>
</head>
<body>
</body>
</html>

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

@ -31,6 +31,7 @@ skip-if = (toolkit == 'gonk' && !debug)
[test_browserElement_oop_CopyPaste.html]
[test_browserElement_oop_DOMRequestError.html]
[test_browserElement_oop_DataURI.html]
[test_browserElement_oop_DisallowEmbedAppsInOOP.html]
[test_browserElement_oop_DocumentFirstPaint.html]
[test_browserElement_oop_Download.html]
disabled = bug 1022281

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

@ -22,6 +22,7 @@ support-files =
browserElement_CopyPaste.js
browserElement_DOMRequestError.js
browserElement_DataURI.js
browserElement_DisallowEmbedAppsInOOP.js
browserElement_DocumentFirstPaint.js
browserElement_Download.js
browserElement_ErrorSecurity.js
@ -77,6 +78,7 @@ support-files =
file_browserElement_CloseApp.html
file_browserElement_CloseFromOpener.html
file_browserElement_CookiesNotThirdParty.html
file_browserElement_DisallowEmbedAppsInOOP.html
file_browserElement_ForwardName.html
file_browserElement_FrameWrongURI.html
file_browserElement_LoadEvents.html
@ -143,6 +145,8 @@ skip-if = buildapp == 'b2g'
[test_browserElement_inproc_CopyPaste.html]
[test_browserElement_inproc_DOMRequestError.html]
[test_browserElement_inproc_DataURI.html]
[test_browserElement_inproc_DisallowEmbedAppsInOOP.html]
skip-if = os == "android" || toolkit == 'gonk' # embed-apps doesn't work in the mochitest app
[test_browserElement_inproc_DocumentFirstPaint.html]
[test_browserElement_inproc_Download.html]
disabled = bug 1022281

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

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 1059662</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_DisallowEmbedAppsInOOP.js">
</script>
</body>
</html>

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

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 1059662</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_DisallowEmbedAppsInOOP.js">
</script>
</body>
</html>

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

@ -34,6 +34,7 @@ support-files =
file_notify_system_message.html
[test_app_install.html]
skip-if = toolkit == 'gonk' # embed-apps doesn't work in the mochitest app
[test_readonly.html]
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 936226
[test_basic.html]

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

@ -7,6 +7,7 @@
#include "nsGenericHTMLFrameElement.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Preferences.h"
#include "mozilla/ErrorResult.h"
#include "GeckoProfiler.h"
@ -437,6 +438,11 @@ nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut)
return NS_OK;
}
if (XRE_GetProcessType() != GeckoProcessType_Default) {
NS_WARNING("Can't embed-apps. Embed-apps is restricted to in-proc apps, see bug 1059662");
return NS_OK;
}
nsAutoString appManifestURL;
nsAutoString widgetManifestURL;

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

@ -17,7 +17,7 @@ support-files =
localStorageCommon.js
[test_appIsolation.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 793211 # b2g(needs https to work) b2g-debug(needs https to work) b2g-desktop(needs https to work)
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 793211 # b2g(needs https to work) b2g-debug(needs https to work) b2g-desktop(needs https to work)
[test_brokenUTF-16.html]
[test_bug600307-DBOps.html]
[test_bug746272-1.html]

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

@ -1,5 +1,6 @@
[DEFAULT]
skip-if = os == "linux" && e10s && debug # bug 1091322 - wallpaper over an e10s crash
skip-if = os == "android" || toolkit == "gonk" || e10s
support-files =
file_app.sjs
file_app.template.webapp