browser/devtools/debugger/test/browser_dbg_variables-view-override-02.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9a048b3a512b
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests that overridden variables in the VariablesView are styled properly.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_scope-variable-2.html";
9
10 function test() {
11 Task.spawn(function() {
12 let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
13 let win = panel.panelWin;
14 let events = win.EVENTS;
15 let variables = win.DebuggerView.Variables;
16
17 // Wait for the hierarchy to be committed by the VariablesViewController.
18 let committedLocalScopeHierarchy = promise.defer();
19 variables.oncommit = committedLocalScopeHierarchy.resolve;
20
21 // Allow this generator function to yield first.
22 executeSoon(() => debuggee.test());
23 yield waitForSourceAndCaretAndScopes(panel, ".html", 23);
24 yield committedLocalScopeHierarchy.promise;
25
26 let firstScope = variables.getScopeAtIndex(0);
27 let secondScope = variables.getScopeAtIndex(1);
28 let thirdScope = variables.getScopeAtIndex(2);
29
30 let someVar1 = firstScope.get("a");
31 let argsVar1 = firstScope.get("arguments");
32
33 is(someVar1.target.hasAttribute("overridden"), false,
34 "The first 'a' variable should not be marked as being overridden.");
35 is(argsVar1.target.hasAttribute("overridden"), false,
36 "The first 'arguments' variable should not be marked as being overridden.");
37
38 // Wait for the hierarchy to be committed by the VariablesViewController.
39 let committedSecondScopeHierarchy = promise.defer();
40 variables.oncommit = committedSecondScopeHierarchy.resolve;
41 secondScope.expand();
42 yield committedSecondScopeHierarchy.promise;
43
44 let someVar2 = secondScope.get("a");
45 let argsVar2 = secondScope.get("arguments");
46
47 is(someVar2.target.hasAttribute("overridden"), true,
48 "The second 'a' variable should be marked as being overridden.");
49 is(argsVar2.target.hasAttribute("overridden"), true,
50 "The second 'arguments' variable should be marked as being overridden.");
51
52 // Wait for the hierarchy to be committed by the VariablesViewController.
53 let committedThirdScopeHierarchy = promise.defer();
54 variables.oncommit = committedThirdScopeHierarchy.resolve;
55 thirdScope.expand();
56 yield committedThirdScopeHierarchy.promise;
57
58 let someVar3 = thirdScope.get("a");
59 let argsVar3 = thirdScope.get("arguments");
60
61 is(someVar3.target.hasAttribute("overridden"), true,
62 "The third 'a' variable should be marked as being overridden.");
63 is(argsVar3.target.hasAttribute("overridden"), true,
64 "The third 'arguments' variable should be marked as being overridden.");
65
66 yield resumeDebuggerThenCloseAndFinish(panel);
67 });
68 }

mercurial