зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730426 - Fix testSlowScript JSAPI test. r=jandem
This test was missing from moz.build so it has not been running for long enough that the JavaScript in it is no longer even legal JS. Differential Revision: https://phabricator.services.mozilla.com/D125356
This commit is contained in:
Родитель
e2017793c4
Коммит
7387eebf60
|
@ -107,6 +107,7 @@ UNIFIED_SOURCES += [
|
|||
"testSetPropertyIgnoringNamedGetter.cpp",
|
||||
"testSharedImmutableStringsCache.cpp",
|
||||
"testSliceBudget.cpp",
|
||||
"testSlowScript.cpp",
|
||||
"testSourcePolicy.cpp",
|
||||
"testSparseBitmap.cpp",
|
||||
"testStencil.cpp",
|
||||
|
|
|
@ -9,7 +9,8 @@ static bool InterruptCallback(JSContext* cx) { return false; }
|
|||
|
||||
static unsigned sRemain;
|
||||
|
||||
static bool RequestInterruptCallback(JSContext* cx, unsigned argc, jsval* vp) {
|
||||
static bool RequestInterruptCallback(JSContext* cx, unsigned argc,
|
||||
JS::Value* vp) {
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (!sRemain--) {
|
||||
JS_RequestInterruptCallback(cx);
|
||||
|
@ -23,65 +24,48 @@ BEGIN_TEST(testSlowScript) {
|
|||
JS_DefineFunction(cx, global, "requestInterruptCallback",
|
||||
RequestInterruptCallback, 0, 0);
|
||||
|
||||
test(
|
||||
"while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" requestInterruptCallback();");
|
||||
CHECK(
|
||||
test("while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" requestInterruptCallback();"));
|
||||
|
||||
test(
|
||||
"while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" for (j in [0,0,0,0])"
|
||||
" requestInterruptCallback();");
|
||||
CHECK(
|
||||
test("while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" for (j in [0,0,0,0])"
|
||||
" requestInterruptCallback();"));
|
||||
|
||||
test(
|
||||
"while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" for (j in [0,0,0,0])"
|
||||
" for (k in [0,0,0,0])"
|
||||
" requestInterruptCallback();");
|
||||
CHECK(
|
||||
test("while (true)"
|
||||
" for (i in [0,0,0,0])"
|
||||
" for (j in [0,0,0,0])"
|
||||
" for (k in [0,0,0,0])"
|
||||
" requestInterruptCallback();"));
|
||||
|
||||
test(
|
||||
"function f() { while (true) yield requestInterruptCallback() }"
|
||||
"for (i in f()) ;");
|
||||
CHECK(
|
||||
test("function* f() { while (true) yield requestInterruptCallback() }"
|
||||
"for (i of f()) ;"));
|
||||
|
||||
test(
|
||||
"function f() { while (true) yield 1 }"
|
||||
"for (i in f())"
|
||||
" requestInterruptCallback();");
|
||||
|
||||
test(
|
||||
"(function() {"
|
||||
" while (true)"
|
||||
" let (x = 1) { eval('requestInterruptCallback()'); }"
|
||||
"})()");
|
||||
CHECK(
|
||||
test("function* f() { while (true) yield 1 }"
|
||||
"for (i of f())"
|
||||
" requestInterruptCallback();"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test(const char* bytes) {
|
||||
jsval v;
|
||||
|
||||
JS_SetOptions(cx, JS_GetOptions(cx) &
|
||||
~(JSOPTION_METHODJIT | JSOPTION_METHODJIT_ALWAYS));
|
||||
sRemain = 0;
|
||||
CHECK(!evaluate(bytes, __FILE__, __LINE__, &v));
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
|
||||
sRemain = 1000;
|
||||
CHECK(!evaluate(bytes, __FILE__, __LINE__, &v));
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
|
||||
JS_SetOptions(
|
||||
cx, JS_GetOptions(cx) | JSOPTION_METHODJIT | JSOPTION_METHODJIT_ALWAYS);
|
||||
JS::RootedValue v(cx);
|
||||
|
||||
sRemain = 0;
|
||||
CHECK(!evaluate(bytes, __FILE__, __LINE__, &v));
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
sRemain = 1000;
|
||||
CHECK(!evaluate(bytes, __FILE__, __LINE__, &v));
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче