browser/devtools/debugger/test/browser_dbg_variables-view-frozen-sealed-nonext.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c04ecee0e871
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * This test checks that we properly set the frozen, sealed, and non-extensbile
6 * attributes on variables so that the F/S/N is shown in the variables view.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
10
11 let gTab, gDebuggee, gPanel, gDebugger;
12
13 function test() {
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19
20 prepareTest();
21 });
22 }
23
24 function prepareTest() {
25 gDebugger.once(gDebugger.EVENTS.FETCHED_SCOPES, runTest);
26
27 gDebuggee.eval("(" + function() {
28 var frozen = Object.freeze({});
29 var sealed = Object.seal({});
30 var nonExtensible = Object.preventExtensions({});
31 var extensible = {};
32 var string = "foo bar baz";
33
34 debugger;
35 } + "())");
36 }
37
38 function runTest() {
39 let hasNoneTester = function(aVariable) {
40 ok(!aVariable.hasAttribute("frozen"),
41 "The variable should not be frozen.");
42 ok(!aVariable.hasAttribute("sealed"),
43 "The variable should not be sealed.");
44 ok(!aVariable.hasAttribute("non-extensible"),
45 "The variable should be extensible.");
46 };
47
48 let testers = {
49 frozen: function (aVariable) {
50 ok(aVariable.hasAttribute("frozen"),
51 "The variable should be frozen.");
52 },
53 sealed: function (aVariable) {
54 ok(aVariable.hasAttribute("sealed"),
55 "The variable should be sealed.");
56 },
57 nonExtensible: function (aVariable) {
58 ok(aVariable.hasAttribute("non-extensible"),
59 "The variable should be non-extensible.");
60 },
61 extensible: hasNoneTester,
62 string: hasNoneTester,
63 arguments: hasNoneTester,
64 this: hasNoneTester
65 };
66
67 let variables = gDebugger.document.querySelectorAll(".variable-or-property");
68
69 for (let variable of variables) {
70 let name = variable.querySelector(".name").getAttribute("value");
71 let tester = testers[name];
72 delete testers[name];
73
74 ok(tester, "We should have a tester for the '" + name + "' variable.");
75 tester(variable);
76 }
77
78 is(Object.keys(testers).length, 0,
79 "We should have run and removed all the testers.");
80
81 resumeDebuggerThenCloseAndFinish(gPanel);
82 }
83
84 registerCleanupFunction(function() {
85 gTab = null;
86 gDebuggee = null;
87 gPanel = null;
88 gDebugger = null;
89 });

mercurial