mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
2c42679c4c
- Bug 1147247 - Use PRErrorCodeSuccess constant instead of literal 0 to represent success in PSM xpcshell tests. r=dkeeler (493559944) - bug 1151512 - only allow whitelisted certificates to be issued by CNNIC root certificates r=jcj r=rbarnes (cd2131810) - bug 1157873 - remove certificates from CNNIC whitelist that aren't in the Pilot Certificate Transparency log r=rbarnes (a1a1a01a8) - Bug 996872 - Reduce calls to getXPCOMStatusFromNSS() in PSM xpcshell tests. r=keeler relanding on a CLOSED TREE (c26cb3a1c) - Bug 1149805 - Switch head_psm.js to Assert.jsm methods and add expected result strings. r=keeler (a97667d2f) - bug 1102436 - remove PublicKeyPinningService::CheckChainAgainstAllNames r=Cykesiopka (2fdfc2694) - Bug 1164409 - Reduce PSM xpcshell script code duplication. r=keeler (eaf339d67) - Bug 1170431 - Pass buildid as input to pycert.py. r=gps (0ad7492ef) - pointer and comment style (f659d45ec) - add missing test of Bug 1138195 - Ensure that the bytecode analysis is consistent with the bindings. r=jandem (a4aa50c3e) - And fix this to actually compile... Still bug 1160311. (f15aef67f) - pointer style (d41e7fda2) - Bug 1194139 - Fix includes order to make the SM style checker happy. (d02e8c839) - pointer style (4ac1a858a) - Bug 1193212 - Ensure properties deleted by setting Array#length are suppressed in active for..in iteration. r=jandem (b5b3b479d) - Bug 1176712 - Cannot have two activities with same name and different filters. r=fabrice (231b5a89d) - Bug 1161537 - Intermittent test_dev_mode_activity.html | Got error: undefined - expected PASS r=me (c1b0c88d0) - Bug 1105766 - Part 1: Extend the GC allocation logic to work on Windows Phone. r=terrence (e17916f5b) - Bug 1105766 - Part 2: A couple of additions to enable compilation on Windows Phone 8. r=terrence r=ehoogeveen (1d3d809fe) - Bug 1189967 - Avoid including <string> from Char16.h. r=nfroyd (695a687bb) - Bug 1345331: Include <intrin.h> at top-level before lz4.c can include it in a namespace. r=Waldo (63216582f) - remove namespace (09dd2830c) - Bug 1145056 - Coverity complains on every use of MutexAutoLock and GuardObjectNotifier. r=froydnj (0f891929d) - Bug 1145056 - Assert that the guard notifier has been initialized. r=froydnj (061895ad3) - spacing (56b8e1fea) - Bug 1113300 - Add a way to use SegmentedVector like a stack. r=froydnj (2fdaf928e) - bug 606080 - add SplayTree::LookupOrAdd r=froydnj (95591b341) - Bug 1177541 - Remove warning if file is not found during deferred open. r=mcmanus (f15650a51) - spaces and style (2b0558951)
200 lines
8.3 KiB
C++
200 lines
8.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "jsapi-tests/tests.h"
|
|
|
|
static TestJSPrincipals system_principals(1);
|
|
|
|
static const JSClass global_class = {
|
|
"global",
|
|
JSCLASS_IS_GLOBAL | JSCLASS_GLOBAL_FLAGS,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
JS_GlobalObjectTraceHook
|
|
};
|
|
|
|
static JS::PersistentRootedObject trusted_glob;
|
|
static JS::PersistentRootedObject trusted_fun;
|
|
|
|
static bool
|
|
CallTrusted(JSContext* cx, unsigned argc, JS::Value* vp)
|
|
{
|
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
|
|
|
if (!JS_SaveFrameChain(cx))
|
|
return false;
|
|
|
|
bool ok = false;
|
|
{
|
|
JSAutoCompartment ac(cx, trusted_glob);
|
|
JS::RootedValue funVal(cx, JS::ObjectValue(*trusted_fun));
|
|
ok = JS_CallFunctionValue(cx, nullptr, funVal, JS::HandleValueArray::empty(), args.rval());
|
|
}
|
|
JS_RestoreFrameChain(cx);
|
|
return ok;
|
|
}
|
|
|
|
BEGIN_TEST(testChromeBuffer)
|
|
{
|
|
JS_SetTrustedPrincipals(rt, &system_principals);
|
|
|
|
trusted_glob.init(cx, JS_NewGlobalObject(cx, &global_class, &system_principals,
|
|
JS::FireOnNewGlobalHook));
|
|
CHECK(trusted_glob);
|
|
|
|
JS::RootedFunction fun(cx);
|
|
|
|
/*
|
|
* Check that, even after untrusted content has exhausted the stack, code
|
|
* compiled with "trusted principals" can run using reserved trusted-only
|
|
* buffer space.
|
|
*/
|
|
{
|
|
// Disable the JIT because if we don't this test fails. See bug 1160414.
|
|
JS::RuntimeOptions oldOptions = JS::RuntimeOptionsRef(rt);
|
|
JS::RuntimeOptionsRef(rt).setIon(false).setBaseline(false);
|
|
{
|
|
JSAutoCompartment ac(cx, trusted_glob);
|
|
const char* paramName = "x";
|
|
const char* bytes = "return x ? 1 + trusted(x-1) : 0";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "trusted",
|
|
1, ¶mName, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, trusted_glob, "trusted", fun, JSPROP_ENUMERATE));
|
|
trusted_fun.init(cx, JS_GetFunctionObject(fun));
|
|
}
|
|
|
|
JS::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
|
|
CHECK(JS_WrapValue(cx, &v));
|
|
|
|
const char* paramName = "trusted";
|
|
const char* bytes = "try { "
|
|
" return untrusted(trusted); "
|
|
"} catch (e) { "
|
|
" try { "
|
|
" return trusted(100); "
|
|
" } catch(e) { "
|
|
" return -1; "
|
|
" } "
|
|
"} ";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "untrusted", 1,
|
|
¶mName, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, global, "untrusted", fun, JSPROP_ENUMERATE));
|
|
|
|
JS::RootedValue rval(cx);
|
|
CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(v), &rval));
|
|
CHECK(rval.toInt32() == 100);
|
|
JS::RuntimeOptionsRef(rt) = oldOptions;
|
|
}
|
|
|
|
/*
|
|
* Check that content called from chrome in the reserved-buffer space
|
|
* immediately ooms.
|
|
*/
|
|
{
|
|
{
|
|
JSAutoCompartment ac(cx, trusted_glob);
|
|
const char* paramName = "untrusted";
|
|
const char* bytes = "try { "
|
|
" untrusted(); "
|
|
"} catch (e) { "
|
|
" /* "
|
|
" * Careful! We must not reenter JS "
|
|
" * that might try to push a frame. "
|
|
" */ "
|
|
" return 'From trusted: ' + "
|
|
" e.name + ': ' + e.message; "
|
|
"} ";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "trusted",
|
|
1, ¶mName, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, trusted_glob, "trusted", fun, JSPROP_ENUMERATE));
|
|
trusted_fun = JS_GetFunctionObject(fun);
|
|
}
|
|
|
|
JS::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
|
|
CHECK(JS_WrapValue(cx, &v));
|
|
|
|
const char* paramName = "trusted";
|
|
const char* bytes = "try { "
|
|
" return untrusted(trusted); "
|
|
"} catch (e) { "
|
|
" return trusted(untrusted); "
|
|
"} ";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "untrusted", 1,
|
|
¶mName, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, global, "untrusted", fun, JSPROP_ENUMERATE));
|
|
|
|
JS::RootedValue rval(cx);
|
|
CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(v), &rval));
|
|
bool match;
|
|
CHECK(JS_StringEqualsAscii(cx, rval.toString(), "From trusted: InternalError: too much recursion", &match));
|
|
CHECK(match);
|
|
}
|
|
|
|
/*
|
|
* Check that JS_SaveFrameChain called on the way from content to chrome
|
|
* (say, as done by XPCJSContextSTack::Push) works.
|
|
*/
|
|
{
|
|
{
|
|
JSAutoCompartment ac(cx, trusted_glob);
|
|
const char* bytes = "return 42";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "trusted",
|
|
0, nullptr, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, trusted_glob, "trusted", fun, JSPROP_ENUMERATE));
|
|
trusted_fun = JS_GetFunctionObject(fun);
|
|
}
|
|
|
|
JS::RootedFunction fun(cx, JS_NewFunction(cx, CallTrusted, 0, 0, "callTrusted"));
|
|
JS::RootedObject callTrusted(cx, JS_GetFunctionObject(fun));
|
|
|
|
const char *paramName = "f";
|
|
const char *bytes = "try { "
|
|
" return untrusted(trusted); "
|
|
"} catch (e) { "
|
|
" return f(); "
|
|
"} ";
|
|
JS::CompileOptions options(cx);
|
|
options.setFileAndLine("", 0);
|
|
JS::AutoObjectVector emptyScopeChain(cx);
|
|
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "untrusted", 1,
|
|
¶mName, bytes, strlen(bytes), &fun));
|
|
CHECK(JS_DefineProperty(cx, global, "untrusted", fun, JSPROP_ENUMERATE));
|
|
|
|
JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
|
|
JS::RootedValue rval(cx);
|
|
CHECK(JS_CallFunction(cx, nullptr, fun, JS::HandleValueArray(arg), &rval));
|
|
CHECK(rval.toInt32() == 42);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
END_TEST(testChromeBuffer)
|