|
1 <!DOCTYPE HTML> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta charset="utf8"> |
|
5 <title>Test for the native getters in object actors</title> |
|
6 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <script type="text/javascript;version=1.8" src="common.js"></script> |
|
8 <!-- Any copyright is dedicated to the Public Domain. |
|
9 - http://creativecommons.org/publicdomain/zero/1.0/ --> |
|
10 </head> |
|
11 <body> |
|
12 <p>Test for the native getters in object actors</p> |
|
13 |
|
14 <script class="testbody" type="text/javascript;version=1.8"> |
|
15 SimpleTest.waitForExplicitFinish(); |
|
16 |
|
17 let expectedProps = []; |
|
18 let expectedSafeGetters = []; |
|
19 |
|
20 function startTest() |
|
21 { |
|
22 removeEventListener("load", startTest); |
|
23 |
|
24 attachConsole(["ConsoleAPI"], onAttach, true); |
|
25 } |
|
26 |
|
27 function onAttach(aState, aResponse) |
|
28 { |
|
29 onConsoleCall = onConsoleCall.bind(null, aState); |
|
30 aState.dbgClient.addListener("consoleAPICall", onConsoleCall); |
|
31 |
|
32 top.console.log("hello", document); |
|
33 |
|
34 expectedProps = { |
|
35 "location": { |
|
36 get: { |
|
37 type: "object", |
|
38 class: "Function", |
|
39 actor: /[a-z]/, |
|
40 }, |
|
41 }, |
|
42 }; |
|
43 |
|
44 expectedSafeGetters = { |
|
45 "title": { |
|
46 getterValue: /native getters in object actors/, |
|
47 getterPrototypeLevel: 2, |
|
48 }, |
|
49 "styleSheets": { |
|
50 getterValue: "[object Object]", |
|
51 getterPrototypeLevel: 2, |
|
52 }, |
|
53 }; |
|
54 } |
|
55 |
|
56 function onConsoleCall(aState, aType, aPacket) |
|
57 { |
|
58 is(aPacket.from, aState.actor, "console API call actor"); |
|
59 |
|
60 info("checking the console API call packet"); |
|
61 |
|
62 checkConsoleAPICall(aPacket.message, { |
|
63 level: "log", |
|
64 filename: /test_object_actor/, |
|
65 functionName: "onAttach", |
|
66 arguments: ["hello", { |
|
67 type: "object", |
|
68 actor: /[a-z]/, |
|
69 }], |
|
70 }); |
|
71 |
|
72 aState.dbgClient.removeListener("consoleAPICall", onConsoleCall); |
|
73 |
|
74 info("inspecting object properties"); |
|
75 let args = aPacket.message.arguments; |
|
76 onProperties = onProperties.bind(null, aState); |
|
77 |
|
78 let client = new ObjectClient(aState.dbgClient, args[1]); |
|
79 client.getPrototypeAndProperties(onProperties); |
|
80 } |
|
81 |
|
82 function onProperties(aState, aResponse) |
|
83 { |
|
84 let props = aResponse.ownProperties; |
|
85 let keys = Object.keys(props); |
|
86 info(keys.length + " ownProperties: " + keys); |
|
87 |
|
88 ok(keys.length >= Object.keys(expectedProps).length, "number of properties"); |
|
89 |
|
90 info("check ownProperties"); |
|
91 checkObject(props, expectedProps); |
|
92 info("check safeGetterValues"); |
|
93 checkObject(aResponse.safeGetterValues, expectedSafeGetters); |
|
94 |
|
95 expectedProps = []; |
|
96 expectedSafeGetters = []; |
|
97 |
|
98 closeDebugger(aState, function() { |
|
99 SimpleTest.finish(); |
|
100 }); |
|
101 } |
|
102 |
|
103 addEventListener("load", startTest); |
|
104 </script> |
|
105 </body> |
|
106 </html> |