2014-12-07 15:25:48 +00:00
|
|
|
--TEST--
|
|
|
|
Test V8::setTimeLimit() : Time limit can be prolonged
|
|
|
|
--SKIPIF--
|
|
|
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$JS = <<< EOT
|
|
|
|
var text = "abcdefghijklmnopqrstuvwyxz0123456789";
|
2016-01-06 16:23:22 +00:00
|
|
|
/* Spend 75 * >10ms in the loop, i.e. at least 750ms; hence
|
2014-12-08 22:43:04 +00:00
|
|
|
* it should be killed if prolonging doesn't work. */
|
2014-12-08 22:19:29 +00:00
|
|
|
for (var j = 0; j < 30; ++j) {
|
2014-12-07 15:25:48 +00:00
|
|
|
PHP.prolongTimeLimit();
|
2014-12-08 22:43:04 +00:00
|
|
|
var start = (new Date()).getTime();
|
|
|
|
var encoded = encodeURI(text);
|
|
|
|
|
|
|
|
while ((new Date()).getTime() - start < 10) {
|
|
|
|
/* pass about 10ms in the loop, then prolong */
|
|
|
|
var encoded = encodeURI(text);
|
2014-12-07 15:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
$v8 = new V8Js();
|
2016-01-06 16:23:22 +00:00
|
|
|
$v8->setTimeLimit(300);
|
2014-12-07 15:25:48 +00:00
|
|
|
|
|
|
|
$v8->prolongTimeLimit = function() use ($v8) {
|
2016-01-06 16:23:22 +00:00
|
|
|
$v8->setTimeLimit(300);
|
2014-12-07 15:25:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$v8->executeString($JS);
|
|
|
|
?>
|
|
|
|
===EOF===
|
|
|
|
--EXPECTF--
|
|
|
|
===EOF===
|