Title: [149420] trunk/Source/_javascript_Core
- Revision
- 149420
- Author
- [email protected]
- Date
- 2013-04-30 19:38:19 -0700 (Tue, 30 Apr 2013)
Log Message
JSContextGroupSetExecutionTimeLimit() should not pass a callback to the
VM watchdog if its client did not pass one in.
https://bugs.webkit.org/show_bug.cgi?id=115461.
Reviewed by Geoffrey Garen.
* API/JSContextRef.cpp:
(internalScriptTimeoutCallback):
(JSContextGroupSetExecutionTimeLimit):
* API/tests/testapi.c:
(main):
- Added test case when the time limit callback is 0.
- Also updated a check to verify that a TerminatedExecutionException is
thrown when the time out is cancelled.
- Also fixed some cosmetic typos.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSContextRef.cpp (149419 => 149420)
--- trunk/Source/_javascript_Core/API/JSContextRef.cpp 2013-05-01 02:29:33 UTC (rev 149419)
+++ trunk/Source/_javascript_Core/API/JSContextRef.cpp 2013-05-01 02:38:19 UTC (rev 149420)
@@ -83,6 +83,7 @@
{
JSShouldTerminateCallback callback = reinterpret_cast<JSShouldTerminateCallback>(callbackPtr);
JSContextRef contextRef = toRef(exec);
+ ASSERT(callback);
return callback(contextRef, callbackData);
}
@@ -91,8 +92,11 @@
VM& vm = *toJS(group);
APIEntryShim entryShim(&vm);
Watchdog& watchdog = vm.watchdog;
- void* callbackPtr = reinterpret_cast<void*>(callback);
- watchdog.setTimeLimit(vm, limit, internalScriptTimeoutCallback, callbackPtr, callbackData);
+ if (callback) {
+ void* callbackPtr = reinterpret_cast<void*>(callback);
+ watchdog.setTimeLimit(vm, limit, internalScriptTimeoutCallback, callbackPtr, callbackData);
+ } else
+ watchdog.setTimeLimit(vm, limit);
}
void JSContextGroupClearExecutionTimeLimit(JSContextGroupRef group)
Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (149419 => 149420)
--- trunk/Source/_javascript_Core/API/tests/testapi.c 2013-05-01 02:29:33 UTC (rev 149419)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c 2013-05-01 02:38:19 UTC (rev 149420)
@@ -1790,12 +1790,12 @@
}
if (!exception) {
- printf("FAIL: TerminationExecutionException was not thrown.\n");
+ printf("FAIL: TerminatedExecutionException was not thrown.\n");
failed = true;
}
}
- /* Test the script timeout's TerminationExecutionException should NOT be catchable: */
+ /* Test the script timeout's TerminatedExecutionException should NOT be catchable: */
JSContextGroupSetExecutionTimeLimit(contextGroup, 0.10f, shouldTerminateCallback, 0);
{
const char* loopForeverScript = "var startTime = currentCPUTime(); try { while (true) { if (currentCPUTime() - startTime > .150) break; } } catch(e) { }";
@@ -1817,13 +1817,39 @@
}
if (exception)
- printf("PASS: TerminationExecutionException was not catchable as expected.\n");
+ printf("PASS: TerminatedExecutionException was not catchable as expected.\n");
else {
- printf("FAIL: TerminationExecutionException was caught.\n");
+ printf("FAIL: TerminatedExecutionException was caught.\n");
failed = true;
}
}
+ /* Test script timeout with no callback: */
+ JSContextGroupSetExecutionTimeLimit(contextGroup, .10f, 0, 0);
+ {
+ const char* loopForeverScript = "var startTime = currentCPUTime(); while (true) { if (currentCPUTime() - startTime > .150) break; } ";
+ JSStringRef script = JSStringCreateWithUTF8CString(loopForeverScript);
+ double startTime;
+ double endTime;
+ exception = NULL;
+ startTime = currentCPUTime();
+ v = JSEvaluateScript(context, script, NULL, NULL, 1, &exception);
+ endTime = currentCPUTime();
+
+ if (((endTime - startTime) < .150f) && shouldTerminateCallbackWasCalled)
+ printf("PASS: script timed out as expected when no callback is specified.\n");
+ else {
+ if (!((endTime - startTime) < .150f))
+ printf("FAIL: script did not timed out as expected when no callback is specified.\n");
+ failed = true;
+ }
+
+ if (!exception) {
+ printf("FAIL: TerminatedExecutionException was not thrown.\n");
+ failed = true;
+ }
+ }
+
/* Test script timeout cancellation: */
JSContextGroupSetExecutionTimeLimit(contextGroup, 0.10f, cancelTerminateCallback, 0);
{
@@ -1845,6 +1871,11 @@
printf("FAIL: script timeout callback was not called.\n");
failed = true;
}
+
+ if (exception) {
+ printf("FAIL: Unexpected TerminatedExecutionException thrown.\n");
+ failed = true;
+ }
}
/* Test script timeout extension: */
@@ -1875,7 +1906,7 @@
printf("FAIL: script timeout callback was not called after timeout extension.\n");
if (!exception)
- printf("FAIL: TerminationExecutionException was not thrown during timeout extension test.\n");
+ printf("FAIL: TerminatedExecutionException was not thrown during timeout extension test.\n");
failed = true;
}
Modified: trunk/Source/_javascript_Core/ChangeLog (149419 => 149420)
--- trunk/Source/_javascript_Core/ChangeLog 2013-05-01 02:29:33 UTC (rev 149419)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-05-01 02:38:19 UTC (rev 149420)
@@ -1,3 +1,21 @@
+2013-04-30 Mark Lam <[email protected]>
+
+ JSContextGroupSetExecutionTimeLimit() should not pass a callback to the
+ VM watchdog if its client did not pass one in.
+ https://bugs.webkit.org/show_bug.cgi?id=115461.
+
+ Reviewed by Geoffrey Garen.
+
+ * API/JSContextRef.cpp:
+ (internalScriptTimeoutCallback):
+ (JSContextGroupSetExecutionTimeLimit):
+ * API/tests/testapi.c:
+ (main):
+ - Added test case when the time limit callback is 0.
+ - Also updated a check to verify that a TerminatedExecutionException is
+ thrown when the time out is cancelled.
+ - Also fixed some cosmetic typos.
+
2013-04-30 Geoffrey Garen <[email protected]>
Removed op_ensure_property_exists
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes