-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathdirect_construct.phpt
60 lines (56 loc) · 1.18 KB
/
direct_construct.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--TEST--
Test V8::executeString() : direct construction is prohibited
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
# these are not allowed
echo "-- NOT ALLOWED --\n";
try {
$a = new V8Object;
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
try {
$a = new V8Function;
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
# but these are allowed
echo "-- ALLOWED --\n";
$v8 = new V8Js();
$o = $v8->executeString("({foo:1})");
var_dump($o);
$f = $v8->executeString("(function() { return 1; })");
var_dump($f);
# but these are not allowed
echo "-- NOT ALLOWED --\n";
try {
$oo = new $o();
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
try {
$ff = new $f;
} catch (V8JsException $e) {
var_dump($e->getMessage());
}
// free memory
$o = null; $f = null; $v8 = null;
?>
===EOF===
--EXPECTF--
-- NOT ALLOWED --
string(36) "Can't directly construct V8 objects!"
string(36) "Can't directly construct V8 objects!"
-- ALLOWED --
object(V8Object)#%d (1) {
["foo"]=>
int(1)
}
object(V8Function)#%d (0) {
}
-- NOT ALLOWED --
string(36) "Can't directly construct V8 objects!"
string(36) "Can't directly construct V8 objects!"
===EOF===