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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that makes sure source mapped variables appear in autocompletion
// on an equal footing with variables from the generated source.
"use strict";
const TEST_URI =
"http://example.com/browser/devtools/client/webconsole/" +
"test/browser/test-autocomplete-mapped.html";
add_task(async function () {
const hud = await openNewTabAndConsole(TEST_URI);
const { jsterm } = hud;
const { autocompletePopup: popup } = jsterm;
const toolbox = await gDevTools.getToolboxForTab(gBrowser.selectedTab);
info("Opening Debugger and enabling map scopes");
await openDebugger();
const dbg = createDebuggerContext(toolbox);
dbg.actions.toggleMapScopes();
info("Waiting for pause");
// This calls firstCall() on the content page and waits for pause. (firstCall
// has a debugger statement)
await pauseDebugger(dbg);
await toolbox.selectTool("webconsole");
await setInputValueForAutocompletion(hud, "valu");
ok(
hasExactPopupLabels(popup, ["value", "valueOf", "values"]),
"Autocomplete popup displays original variable name"
);
await setInputValueForAutocompletion(hud, "temp");
ok(
hasExactPopupLabels(popup, ["temp", "temp2"]),
"Autocomplete popup displays original variable name when entering a complete variable name"
);
await setInputValueForAutocompletion(hud, "t");
ok(
hasPopupLabel(popup, "t"),
"Autocomplete popup displays generated variable name"
);
await setInputValueForAutocompletion(hud, "value.to");
ok(
hasPopupLabel(popup, "toString"),
"Autocomplete popup displays properties of original variable"
);
await setInputValueForAutocompletion(hud, "imported.imp");
ok(
hasPopupLabel(popup, "importResult"),
"Autocomplete popup displays properties of multi-part variable"
);
let tooltip = await setInputValueForGetterConfirmDialog(
toolbox,
hud,
"getter."
);
let labelEl = tooltip.querySelector(".confirm-label");
is(
labelEl.textContent,
"Invoke getter getter to retrieve the property list?",
"Dialog has expected text content"
);
info(
"Check that getter confirmation on a variable that maps to two getters invokes both getters"
);
let onPopUpOpen = popup.once("popup-opened");
EventUtils.synthesizeKey("KEY_Tab");
await onPopUpOpen;
ok(popup.isOpen, "popup is open after Tab");
ok(hasPopupLabel(popup, "getterResult"), "popup has expected items");
info(
"Check that the getter confirmation dialog shows the original variable name"
);
tooltip = await setInputValueForGetterConfirmDialog(
toolbox,
hud,
"localWithGetter.value."
);
labelEl = tooltip.querySelector(".confirm-label");
is(
labelEl.textContent,
"Invoke getter localWithGetter.value to retrieve the property list?",
"Dialog has expected text content"
);
info(
"Check that hitting Tab does invoke the getter and return its properties"
);
onPopUpOpen = popup.once("popup-opened");
EventUtils.synthesizeKey("KEY_Tab");
await onPopUpOpen;
ok(popup.isOpen, "popup is open after Tab");
ok(hasPopupLabel(popup, "then"), "popup has expected items");
info("got popup items: " + JSON.stringify(getAutocompletePopupLabels(popup)));
info(
"Check that authorizing an original getter applies to the generated getter"
);
await setInputValueForAutocompletion(hud, "o.value.");
ok(hasPopupLabel(popup, "then"), "popup has expected items");
await setInputValueForAutocompletion(hud, "(temp + temp2).");
ok(
hasPopupLabel(popup, "toFixed"),
"Autocomplete popup displays properties of eagerly evaluated value"
);
info("got popup items: " + JSON.stringify(getAutocompletePopupLabels(popup)));
info("Disabling map scopes");
dbg.actions.toggleMapScopes();
await setInputValueForAutocompletion(hud, "tem");
const autocompleteLabels = getAutocompletePopupLabels(popup);
ok(
!autocompleteLabels.includes("temp"),
"Autocomplete popup does not display mapped variables when mapping is disabled"
);
await resume(dbg);
});
|