зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f4348b2f5c5f (bug 1223678) for bustage
--HG-- extra : rebase_source : 1e7bf92b54ceff74b6eee2143a2f82434af1e8e3
This commit is contained in:
Родитель
400e056d0d
Коммит
207c64c6c1
|
@ -458,28 +458,8 @@ static void LogChannelRelevantInfo(nsIURI* aURI,
|
|||
LOG("Result principal origin: %s\n", resultPrincipalOrigin.get());
|
||||
}
|
||||
|
||||
// This is similar to nsIScriptSecurityManager.getChannelResultPrincipal
|
||||
// but taking signedPkg into account. The reason we can't rely on channel
|
||||
// loadContext/loadInfo is it's dangerous to mutate them on parent process.
|
||||
static already_AddRefed<nsIPrincipal>
|
||||
GetChannelPrincipalWithSingedPkg(nsIChannel* aChannel, const nsACString& aSignedPkg)
|
||||
{
|
||||
OriginAttributes attrs;
|
||||
NS_GetOriginAttributes(aChannel, attrs);
|
||||
attrs.mSignedPkg = NS_ConvertUTF8toUTF16(aSignedPkg);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
|
||||
return principal.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::ShouldSwitchProcess(nsIChannel* aChannel, const nsACString& aSignedPkg)
|
||||
TabParent::ShouldSwitchProcess(nsIChannel* aChannel)
|
||||
{
|
||||
// If we lack of any information which is required to decide the need of
|
||||
// process switch, consider that we should switch process.
|
||||
|
@ -493,18 +473,19 @@ TabParent::ShouldSwitchProcess(nsIChannel* aChannel, const nsACString& aSignedPk
|
|||
NS_ENSURE_TRUE(loadingPrincipal, true);
|
||||
|
||||
// Prepare the channel result principal.
|
||||
nsCOMPtr<nsIPrincipal> channelPrincipal =
|
||||
GetChannelPrincipalWithSingedPkg(aChannel, aSignedPkg);
|
||||
nsCOMPtr<nsIPrincipal> resultPrincipal;
|
||||
nsContentUtils::GetSecurityManager()->
|
||||
GetChannelResultPrincipal(aChannel, getter_AddRefs(resultPrincipal));
|
||||
|
||||
// Log the debug info which is used to decide the need of proces switch.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetURI(getter_AddRefs(uri));
|
||||
LogChannelRelevantInfo(uri, loadingPrincipal, channelPrincipal,
|
||||
LogChannelRelevantInfo(uri, loadingPrincipal, resultPrincipal,
|
||||
loadInfo->InternalContentPolicyType());
|
||||
|
||||
// Check if the signed package is loaded from the same origin.
|
||||
bool sameOrigin = false;
|
||||
loadingPrincipal->Equals(channelPrincipal, &sameOrigin);
|
||||
loadingPrincipal->Equals(resultPrincipal, &sameOrigin);
|
||||
if (sameOrigin) {
|
||||
LOG("Loading singed package from the same origin. Don't switch process.\n");
|
||||
return false;
|
||||
|
@ -535,7 +516,7 @@ void
|
|||
TabParent::OnStartSignedPackageRequest(nsIChannel* aChannel,
|
||||
const nsACString& aPackageId)
|
||||
{
|
||||
if (!ShouldSwitchProcess(aChannel, aPackageId)) {
|
||||
if (!ShouldSwitchProcess(aChannel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ protected:
|
|||
|
||||
// Decide whether we have to use a new process to reload the URI associated
|
||||
// with the given channel.
|
||||
bool ShouldSwitchProcess(nsIChannel* aChannel, const nsACString& aSignedPkg);
|
||||
bool ShouldSwitchProcess(nsIChannel* aChannel);
|
||||
|
||||
ContentCacheInParent mContentCache;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ support-files =
|
|||
user_agent_update.sjs
|
||||
web_packaged_app.sjs
|
||||
signed_web_packaged_app.sjs
|
||||
signed_web_packaged_app_random.sjs
|
||||
file_loadinfo_redirectchain.sjs
|
||||
redirect_idn.html^headers^
|
||||
redirect_idn.html
|
||||
|
@ -30,8 +29,6 @@ skip-if = e10s
|
|||
skip-if = e10s || buildapp != 'browser'
|
||||
[test_signed_web_packaged_app_origin.html]
|
||||
skip-if = e10s || buildapp != 'browser'
|
||||
[test_signed_to_signed_web_packaged_app.html]
|
||||
skip-if = e10s || buildapp != 'browser'
|
||||
[test_web_packaged_app.html]
|
||||
[test_loadinfo_redirectchain.html]
|
||||
skip-if = buildapp == 'b2g' #no ssl support
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
// Same as signed_web_packaged_app.sjs except this one would return a random
|
||||
// package-identifer.
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
|
||||
var uuid = Cc["@mozilla.org/uuid-generator;1"].
|
||||
getService(Ci.nsIUUIDGenerator).
|
||||
generateUUID().
|
||||
toString().replace(/[{}]/g, "");
|
||||
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
response.setHeader("Content-Type", "application/package", false);
|
||||
response.write(signedPackage);
|
||||
return;
|
||||
}
|
||||
|
||||
// The package content
|
||||
// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format
|
||||
var signedPackage = `manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgECMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MDkxMDA4MDQzNVoXDTM1MDkxMDA4MDQzNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGjAYBgNVBAMTEVRydXN0ZWQgQ29ycCBDZXJ0MIIBIjANBgkqh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QkFMQ8XDTE1MTAyODExMTIwMlowIwYJKoZIhvcNAQkEMRYEFENKTXRUkdej+EPd/oKRhz0Cp13zMA0GCSqGSIb3DQEBAQUABIIBAFCr+i8cwTiwzzCVjzZZI2NAqu8dnYOAJjkhD02tJjBCbvehEhXW6pP/Gk8+oyx2zoV87zbw9xBGcEU9b3ulbggdFR56S3C3w+eTbeOXMcx7A8mn9vvsoMJm+/rkT4DgEUU1iaM7pdwH48CKJOnAZP5FkjRvpRBh8TgfcDbusXveYTwG5LVpDp8856+9FBzvZ7wLz9iWDvlT/EFxfWOnGduAJunQ9qQm+pWu5cvSTwWasCMYmiPRlsuBhU9Fx7LtlXIHtE2nYYQVMTMDE58z/mzT34W0bnneecrghHREhb90UvdlUZJ2q3Jahsa3718WUGPTp7ZYwYaPBy7ryoOoWSA=\r
|
||||
--7IYGY9UDJB\r
|
||||
Content-Location: manifest.webapp\r
|
||||
Content-Type: application/x-web-app-manifest+json\r
|
||||
\r
|
||||
{
|
||||
"moz-package-origin": "http://mochi.test:8888",
|
||||
"name": "My App",
|
||||
"moz-resources": [
|
||||
{
|
||||
"src": "page2.html",
|
||||
"integrity": "JREF3JbXGvZ+I1KHtoz3f46ZkeIPrvXtG4VyFQrJ7II="
|
||||
},
|
||||
{
|
||||
"src": "index.html",
|
||||
"integrity": "IjQ2S/V9qsC7wW5uv/Niq40M1aivvqH5+1GKRwUnyRg="
|
||||
},
|
||||
{
|
||||
"src": "scripts/script.js",
|
||||
"integrity": "6TqtNArQKrrsXEQWu3D9ZD8xvDRIkhyV6zVdTcmsT5Q="
|
||||
},
|
||||
{
|
||||
"src": "scripts/library.js",
|
||||
"integrity": "TN2ByXZiaBiBCvS4MeZ02UyNi44vED+KjdjLInUl4o8="
|
||||
}
|
||||
],
|
||||
"moz-permissions": [
|
||||
{
|
||||
"systemXHR": {
|
||||
"description": "Needed to download stuff"
|
||||
},
|
||||
"devicestorage:pictures": {
|
||||
"description": "Need to load pictures"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
`
|
||||
+ ' "package-identifier": "' + uuid + '",\n\r' +
|
||||
`
|
||||
"description": "A great app!"
|
||||
}\r
|
||||
--7IYGY9UDJB\r
|
||||
Content-Location: page2.html\r
|
||||
Content-Type: text/html\r
|
||||
\r
|
||||
<html>
|
||||
page2.html
|
||||
</html>
|
||||
\r
|
||||
--7IYGY9UDJB\r
|
||||
Content-Location: index.html\r
|
||||
Content-Type: text/html\r
|
||||
\r
|
||||
<html>
|
||||
Last updated: 2015/10/28
|
||||
</html>
|
||||
\r
|
||||
--7IYGY9UDJB\r
|
||||
Content-Location: scripts/script.js\r
|
||||
Content-Type: text/javascript\r
|
||||
\r
|
||||
// script.js
|
||||
\r
|
||||
--7IYGY9UDJB\r
|
||||
Content-Location: scripts/library.js\r
|
||||
Content-Type: text/javascript\r
|
||||
\r
|
||||
// library.js
|
||||
\r
|
||||
--7IYGY9UDJB--`;
|
|
@ -1,83 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title> Web packaged app </title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript;version=1.7">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
var Cu = SpecialPowers.Cu;
|
||||
var Cr = SpecialPowers.Cr;
|
||||
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["network.http.enable-packaged-apps", true],
|
||||
["dom.ipc.processPriorityManager.testMode", true],
|
||||
["network.http.signed-packages.enabled", true],
|
||||
["network.http.signed-packages.trusted-origin", "http://mochi.test:8888"],
|
||||
["dom.ipc.processPriorityManager.enabled", true],
|
||||
["dom.ipc.tabs.disabled", false],
|
||||
["dom.ipc.processCount", 30],
|
||||
["dom.mozBrowserFramesEnabled", true]] },
|
||||
() => SpecialPowers.pushPermissions([
|
||||
{ "type": "browser", "allow": 1, "context": document }
|
||||
], function() {
|
||||
runTest();
|
||||
}));
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Listen for and count process-created event. There should be 3 processes
|
||||
// to be created:
|
||||
// 1) The remote tab
|
||||
// 2) While navigating to http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app_random.sjs!//scripts/app.js
|
||||
// 3) While navigating to http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app_random.sjs!//index.html
|
||||
//
|
||||
// Note that signed_web_packaged_app_random.sjs will return different package identifier
|
||||
// in each request. Therefore, step (3) should trigger process switch.
|
||||
var kProcessCreatedTopic = "process-priority-manager:TEST-ONLY:process-created";
|
||||
var processCreatedCnt = 0;
|
||||
SpecialPowers.addObserver(() => {
|
||||
processCreatedCnt++;
|
||||
if (processCreatedCnt == 3) {
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
ok(true, "We have " + (3 - processCreatedCnt) + " processes to create.");
|
||||
}
|
||||
}, kProcessCreatedTopic, /* weak = */ false);
|
||||
|
||||
function runTest() {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
iframe.setAttribute('remote', 'true');
|
||||
iframe.setAttribute("src", "http://example.org:80");
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
|
||||
iframe.removeEventListener("mozbrowserloadend", loadend);
|
||||
ok(true, "Got mozbrowserloadend 1");
|
||||
iframe.setAttribute("src", "http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app_random.sjs!//scripts/app.js");
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
|
||||
iframe.removeEventListener("mozbrowserloadend", loadend);
|
||||
ok(true, "Got mozbrowserloadend 2");
|
||||
iframe.setAttribute("src", "http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app_random.sjs!//index.html");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче