2014-12-07 15:25:48 +00:00
|
|
|
--TEST--
|
|
|
|
Test V8::setTimeLimit() : Time limit can be prolonged
|
|
|
|
--SKIPIF--
|
2016-03-26 10:47:58 +00:00
|
|
|
<?php
|
|
|
|
require_once(dirname(__FILE__) . '/skipif.inc');
|
|
|
|
|
|
|
|
if (getenv("SKIP_SLOW_TESTS")) {
|
|
|
|
die("skip slow test");
|
|
|
|
}
|
|
|
|
?>
|
2014-12-07 15:25:48 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$JS = <<< EOT
|
|
|
|
var text = "abcdefghijklmnopqrstuvwyxz0123456789";
|
2014-12-08 22:19:29 +00:00
|
|
|
/* Spend 30 * >10ms in the loop, i.e. at least 300ms; 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();
|
2014-12-08 22:19:29 +00:00
|
|
|
$v8->setTimeLimit(100);
|
2014-12-07 15:25:48 +00:00
|
|
|
|
|
|
|
$v8->prolongTimeLimit = function() use ($v8) {
|
2014-12-08 22:19:29 +00:00
|
|
|
$v8->setTimeLimit(100);
|
2014-12-07 15:25:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$v8->executeString($JS);
|
|
|
|
?>
|
|
|
|
===EOF===
|
|
|
|
--EXPECTF--
|
|
|
|
===EOF===
|