mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1150045 - De-anonymize Expanded Principals. r=bholley
This commit is contained in:
parent
351257fef3
commit
ace19d48e4
@ -57,7 +57,7 @@ exports['test exceptions'] = function(assert) {
|
||||
} + '();');
|
||||
}
|
||||
catch (error) {
|
||||
assert.equal(error.fileName, '', 'no fileName reported');
|
||||
assert.equal(error.fileName, '[System Principal]', 'No specific fileName reported');
|
||||
assert.equal(error.lineNumber, 3, 'reports correct line number');
|
||||
}
|
||||
|
||||
|
@ -980,8 +980,21 @@ nsExpandedPrincipal::IsOnCSSUnprefixingWhitelist()
|
||||
void
|
||||
nsExpandedPrincipal::GetScriptLocation(nsACString& aStr)
|
||||
{
|
||||
// Is that a good idea to list it's principals?
|
||||
aStr.Assign(EXPANDED_PRINCIPAL_SPEC);
|
||||
aStr.AppendLiteral(" (");
|
||||
|
||||
for (size_t i = 0; i < mPrincipals.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aStr.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
nsAutoCString spec;
|
||||
nsJSPrincipals::get(mPrincipals.ElementAt(i))->GetScriptLocation(spec);
|
||||
|
||||
aStr.Append(spec);
|
||||
|
||||
}
|
||||
aStr.Append(")");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1507,7 +1507,7 @@ xpc::EvalInSandbox(JSContext* cx, HandleObject sandboxArg, const nsAString& sour
|
||||
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoCString filenameBuf;
|
||||
if (!filename.IsVoid()) {
|
||||
if (!filename.IsVoid() && filename.Length() != 0) {
|
||||
filenameBuf.Assign(filename);
|
||||
} else {
|
||||
// Default to the spec of the principal.
|
||||
|
28
js/xpconnect/tests/unit/test_sandbox_name.js
Normal file
28
js/xpconnect/tests/unit/test_sandbox_name.js
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
|
||||
|
||||
/**
|
||||
* Test that the name of a sandbox contains the name of all principals.
|
||||
*/
|
||||
function test_sandbox_name() {
|
||||
let names = [
|
||||
"http://example.com/?" + Math.random(),
|
||||
"http://example.org/?" + Math.random()
|
||||
];
|
||||
let sandbox = Cu.Sandbox(names);
|
||||
let fileName = Cu.evalInSandbox(
|
||||
"(new Error()).fileName",
|
||||
sandbox,
|
||||
"latest" /*js version*/,
|
||||
""/*file name*/
|
||||
);
|
||||
|
||||
for (let name of names) {
|
||||
Assert.ok(fileName.indexOf(name) != -1, `Name ${name} appears in ${fileName}`);
|
||||
}
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
test_sandbox_name();
|
||||
}
|
@ -99,6 +99,7 @@ skip-if = os == "android" # native test components aren't available on Android
|
||||
[test_sandbox_atob.js]
|
||||
[test_isProxy.js]
|
||||
[test_getObjectPrincipal.js]
|
||||
[test_sandbox_name.js]
|
||||
[test_watchdog_enable.js]
|
||||
head = head_watchdog.js
|
||||
[test_watchdog_disable.js]
|
||||
|
Loading…
Reference in New Issue
Block a user