зеркало из https://github.com/mozilla/gecko-dev.git
Backout of bug 1226551. r=bustage
This commit is contained in:
Родитель
ce990e88c7
Коммит
de3be65932
|
@ -6,31 +6,17 @@
|
|||
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
static int32_t contentGlobalFunctionCallResult = 0;
|
||||
|
||||
static bool
|
||||
IntrinsicFunction(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(42);
|
||||
return true;
|
||||
}
|
||||
static bool contentGlobalFunctionCalled = false;
|
||||
|
||||
static bool
|
||||
ContentGlobalFunction(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 1);
|
||||
contentGlobalFunctionCallResult = args[0].toInt32();
|
||||
contentGlobalFunctionCalled = true;
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static const JSFunctionSpec intrinsic_functions[] = {
|
||||
JS_FN("intrinsicFunction", IntrinsicFunction, 0,0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
BEGIN_TEST(testEvaluateSelfHosted)
|
||||
{
|
||||
CHECK(js::DefineTestingFunctions(cx, global, false, false));
|
||||
|
@ -39,7 +25,7 @@ BEGIN_TEST(testEvaluateSelfHosted)
|
|||
JS::RootedValue v(cx);
|
||||
EVAL("getSelfHostedValue('customSelfHostedFunction')();", &v);
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
CHECK(contentGlobalFunctionCallResult == 42);
|
||||
CHECK(contentGlobalFunctionCalled == true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -48,13 +34,9 @@ virtual JSContext* createContext() override {
|
|||
JSContext* cx = JS_NewContext(rt, 8192);
|
||||
if (!cx)
|
||||
return nullptr;
|
||||
const char *selfHostedCode = "function customSelfHostedFunction() {"
|
||||
"let intrinsicResult = intrinsicFunction();"
|
||||
"callFunction(global.contentGlobalFunction, global,"
|
||||
" intrinsicResult);"
|
||||
"}";
|
||||
if (!JS::AddSelfHostingIntrinsics(rt, intrinsic_functions) ||
|
||||
!JS::EvaluateSelfHosted(rt, selfHostedCode, strlen(selfHostedCode), "testing-sh"))
|
||||
const char *selfHostedCode = "function customSelfHostedFunction()"
|
||||
"{global.contentGlobalFunction()}";
|
||||
if (!JS::EvaluateSelfHosted(rt, selfHostedCode, strlen(selfHostedCode), "testing-sh"))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -4651,12 +4651,6 @@ JS::EvaluateSelfHosted(JSRuntime* rt, const char* filename)
|
|||
return EvaluateSelfHosted(rt, bytes, length, filename);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::AddSelfHostingIntrinsics(JSRuntime* rt, const JSFunctionSpec* intrinsicFunctions)
|
||||
{
|
||||
return rt->addSelfHostingIntrinsics(intrinsicFunctions);
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
JS_NewHelper(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& inputArgs)
|
||||
{
|
||||
|
|
|
@ -4149,16 +4149,6 @@ EvaluateSelfHosted(JSRuntime* rt, const char* bytes, size_t length, const char*
|
|||
extern JS_PUBLIC_API(bool)
|
||||
EvaluateSelfHosted(JSRuntime* rt, const char* filename);
|
||||
|
||||
/**
|
||||
* Add functions available to self-hosted code.
|
||||
*
|
||||
* Must be called before the self-hosted code using it is run with
|
||||
* EvaluateSelfHosted, and thus has the same restrictions regarding when it
|
||||
* can be used.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
AddSelfHostingIntrinsics(JSRuntime* rt, const JSFunctionSpec* intrinsicFunctions);
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
|
|
|
@ -954,7 +954,6 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
|
||||
bool initSelfHosting(JSContext* cx);
|
||||
bool evaluateSelfHosted(const char16_t* chars, size_t length, const char* filename);
|
||||
bool addSelfHostingIntrinsics(const JSFunctionSpec* intrinsicFunctions);
|
||||
void finishSelfHosting();
|
||||
/*
|
||||
* Completes the runtime's initialization by freezing the initial set of
|
||||
|
|
|
@ -1787,21 +1787,6 @@ JSRuntime::evaluateSelfHosted(const char16_t* chars, size_t length, const char*
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
JSRuntime::addSelfHostingIntrinsics(const JSFunctionSpec* intrinsicFunctions)
|
||||
{
|
||||
MOZ_ASSERT(hasContexts());
|
||||
MOZ_ASSERT(selfHostingGlobal_);
|
||||
MOZ_ASSERT(!parentRuntime);
|
||||
MOZ_ASSERT(!hasContentGlobals);
|
||||
|
||||
JSContext* cx = this->contextList.getFirst();
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, selfHostingGlobal_);
|
||||
RootedObject global(cx, selfHostingGlobal_);
|
||||
return JS_DefineFunctions(cx, global, intrinsicFunctions);
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::finishSelfHosting()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче