browser_dbg_variables-view-frame-parameters-02.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. /**
  5. * Make sure that the variables view displays the right variables and
  6. * properties when debugger is paused.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
  9. var gTab, gPanel, gDebugger;
  10. var gVariables;
  11. function test() {
  12. // Debug test slaves are a bit slow at this test.
  13. requestLongerTimeout(2);
  14. let options = {
  15. source: TAB_URL,
  16. line: 1
  17. };
  18. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  19. gTab = aTab;
  20. gPanel = aPanel;
  21. gDebugger = gPanel.panelWin;
  22. gVariables = gDebugger.DebuggerView.Variables;
  23. waitForCaretAndScopes(gPanel, 24)
  24. .then(testScopeVariables)
  25. .then(testArgumentsProperties)
  26. .then(testSimpleObject)
  27. .then(testComplexObject)
  28. .then(testArgumentObject)
  29. .then(testInnerArgumentObject)
  30. .then(testGetterSetterObject)
  31. .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
  32. .then(null, aError => {
  33. ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
  34. });
  35. generateMouseClickInTab(gTab, "content.document.querySelector('button')");
  36. });
  37. }
  38. function testScopeVariables() {
  39. let localScope = gVariables.getScopeAtIndex(0);
  40. is(localScope.expanded, true,
  41. "The local scope should be expanded by default.");
  42. let localEnums = localScope.target.querySelector(".variables-view-element-details.enum").childNodes;
  43. let localNonEnums = localScope.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  44. is(localEnums.length, 12,
  45. "The local scope should contain all the created enumerable elements.");
  46. is(localNonEnums.length, 0,
  47. "The local scope should contain all the created non-enumerable elements.");
  48. is(localEnums[0].querySelector(".name").getAttribute("value"), "this",
  49. "Should have the right property name for 'this'.");
  50. is(localEnums[0].querySelector(".value").getAttribute("value"),
  51. "Window \u2192 doc_frame-parameters.html",
  52. "Should have the right property value for 'this'.");
  53. ok(localEnums[0].querySelector(".value").className.includes("token-other"),
  54. "Should have the right token class for 'this'.");
  55. is(localEnums[1].querySelector(".name").getAttribute("value"), "aArg",
  56. "Should have the right property name for 'aArg'.");
  57. is(localEnums[1].querySelector(".value").getAttribute("value"), "Object",
  58. "Should have the right property value for 'aArg'.");
  59. ok(localEnums[1].querySelector(".value").className.includes("token-other"),
  60. "Should have the right token class for 'aArg'.");
  61. is(localEnums[2].querySelector(".name").getAttribute("value"), "bArg",
  62. "Should have the right property name for 'bArg'.");
  63. is(localEnums[2].querySelector(".value").getAttribute("value"), "\"beta\"",
  64. "Should have the right property value for 'bArg'.");
  65. ok(localEnums[2].querySelector(".value").className.includes("token-string"),
  66. "Should have the right token class for 'bArg'.");
  67. is(localEnums[3].querySelector(".name").getAttribute("value"), "cArg",
  68. "Should have the right property name for 'cArg'.");
  69. is(localEnums[3].querySelector(".value").getAttribute("value"), "3",
  70. "Should have the right property value for 'cArg'.");
  71. ok(localEnums[3].querySelector(".value").className.includes("token-number"),
  72. "Should have the right token class for 'cArg'.");
  73. is(localEnums[4].querySelector(".name").getAttribute("value"), "dArg",
  74. "Should have the right property name for 'dArg'.");
  75. is(localEnums[4].querySelector(".value").getAttribute("value"), "false",
  76. "Should have the right property value for 'dArg'.");
  77. ok(localEnums[4].querySelector(".value").className.includes("token-boolean"),
  78. "Should have the right token class for 'dArg'.");
  79. is(localEnums[5].querySelector(".name").getAttribute("value"), "eArg",
  80. "Should have the right property name for 'eArg'.");
  81. is(localEnums[5].querySelector(".value").getAttribute("value"), "null",
  82. "Should have the right property value for 'eArg'.");
  83. ok(localEnums[5].querySelector(".value").className.includes("token-null"),
  84. "Should have the right token class for 'eArg'.");
  85. is(localEnums[6].querySelector(".name").getAttribute("value"), "fArg",
  86. "Should have the right property name for 'fArg'.");
  87. is(localEnums[6].querySelector(".value").getAttribute("value"), "undefined",
  88. "Should have the right property value for 'fArg'.");
  89. ok(localEnums[6].querySelector(".value").className.includes("token-undefined"),
  90. "Should have the right token class for 'fArg'.");
  91. is(localEnums[7].querySelector(".name").getAttribute("value"), "a",
  92. "Should have the right property name for 'a'.");
  93. is(localEnums[7].querySelector(".value").getAttribute("value"), "1",
  94. "Should have the right property value for 'a'.");
  95. ok(localEnums[7].querySelector(".value").className.includes("token-number"),
  96. "Should have the right token class for 'a'.");
  97. is(localEnums[8].querySelector(".name").getAttribute("value"), "arguments",
  98. "Should have the right property name for 'arguments'.");
  99. is(localEnums[8].querySelector(".value").getAttribute("value"), "Arguments",
  100. "Should have the right property value for 'arguments'.");
  101. ok(localEnums[8].querySelector(".value").className.includes("token-other"),
  102. "Should have the right token class for 'arguments'.");
  103. is(localEnums[9].querySelector(".name").getAttribute("value"), "b",
  104. "Should have the right property name for 'b'.");
  105. is(localEnums[9].querySelector(".value").getAttribute("value"), "Object",
  106. "Should have the right property value for 'b'.");
  107. ok(localEnums[9].querySelector(".value").className.includes("token-other"),
  108. "Should have the right token class for 'b'.");
  109. is(localEnums[10].querySelector(".name").getAttribute("value"), "c",
  110. "Should have the right property name for 'c'.");
  111. is(localEnums[10].querySelector(".value").getAttribute("value"), "Object",
  112. "Should have the right property value for 'c'.");
  113. ok(localEnums[10].querySelector(".value").className.includes("token-other"),
  114. "Should have the right token class for 'c'.");
  115. is(localEnums[11].querySelector(".name").getAttribute("value"), "myVar",
  116. "Should have the right property name for 'myVar'.");
  117. is(localEnums[11].querySelector(".value").getAttribute("value"), "Object",
  118. "Should have the right property value for 'myVar'.");
  119. ok(localEnums[11].querySelector(".value").className.includes("token-other"),
  120. "Should have the right token class for 'myVar'.");
  121. }
  122. function testArgumentsProperties() {
  123. let deferred = promise.defer();
  124. let argsVar = gVariables.getScopeAtIndex(0).get("arguments");
  125. is(argsVar.expanded, false,
  126. "The 'arguments' variable should not be expanded by default.");
  127. let argsEnums = argsVar.target.querySelector(".variables-view-element-details.enum").childNodes;
  128. let argsNonEnums = argsVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  129. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  130. is(argsEnums.length, 5,
  131. "The 'arguments' variable should contain all the created enumerable elements.");
  132. is(argsNonEnums.length, 3,
  133. "The 'arguments' variable should contain all the created non-enumerable elements.");
  134. is(argsEnums[0].querySelector(".name").getAttribute("value"), "0",
  135. "Should have the right property name for '0'.");
  136. is(argsEnums[0].querySelector(".value").getAttribute("value"), "Object",
  137. "Should have the right property value for '0'.");
  138. ok(argsEnums[0].querySelector(".value").className.includes("token-other"),
  139. "Should have the right token class for '0'.");
  140. is(argsEnums[1].querySelector(".name").getAttribute("value"), "1",
  141. "Should have the right property name for '1'.");
  142. is(argsEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"",
  143. "Should have the right property value for '1'.");
  144. ok(argsEnums[1].querySelector(".value").className.includes("token-string"),
  145. "Should have the right token class for '1'.");
  146. is(argsEnums[2].querySelector(".name").getAttribute("value"), "2",
  147. "Should have the right property name for '2'.");
  148. is(argsEnums[2].querySelector(".value").getAttribute("value"), "3",
  149. "Should have the right property name for '2'.");
  150. ok(argsEnums[2].querySelector(".value").className.includes("token-number"),
  151. "Should have the right token class for '2'.");
  152. is(argsEnums[3].querySelector(".name").getAttribute("value"), "3",
  153. "Should have the right property name for '3'.");
  154. is(argsEnums[3].querySelector(".value").getAttribute("value"), "false",
  155. "Should have the right property value for '3'.");
  156. ok(argsEnums[3].querySelector(".value").className.includes("token-boolean"),
  157. "Should have the right token class for '3'.");
  158. is(argsEnums[4].querySelector(".name").getAttribute("value"), "4",
  159. "Should have the right property name for '4'.");
  160. is(argsEnums[4].querySelector(".value").getAttribute("value"), "null",
  161. "Should have the right property name for '4'.");
  162. ok(argsEnums[4].querySelector(".value").className.includes("token-null"),
  163. "Should have the right token class for '4'.");
  164. is(argsNonEnums[0].querySelector(".name").getAttribute("value"), "callee",
  165. "Should have the right property name for 'callee'.");
  166. is(argsNonEnums[0].querySelector(".value").getAttribute("value"),
  167. "test(aArg,bArg,cArg,dArg,eArg,fArg)",
  168. "Should have the right property name for 'callee'.");
  169. ok(argsNonEnums[0].querySelector(".value").className.includes("token-other"),
  170. "Should have the right token class for 'callee'.");
  171. is(argsNonEnums[1].querySelector(".name").getAttribute("value"), "length",
  172. "Should have the right property name for 'length'.");
  173. is(argsNonEnums[1].querySelector(".value").getAttribute("value"), "5",
  174. "Should have the right property value for 'length'.");
  175. ok(argsNonEnums[1].querySelector(".value").className.includes("token-number"),
  176. "Should have the right token class for 'length'.");
  177. is(argsNonEnums[2].querySelector(".name").getAttribute("value"), "__proto__",
  178. "Should have the right property name for '__proto__'.");
  179. is(argsNonEnums[2].querySelector(".value").getAttribute("value"), "Object",
  180. "Should have the right property value for '__proto__'.");
  181. ok(argsNonEnums[2].querySelector(".value").className.includes("token-other"),
  182. "Should have the right token class for '__proto__'.");
  183. deferred.resolve();
  184. });
  185. argsVar.expand();
  186. return deferred.promise;
  187. }
  188. function testSimpleObject() {
  189. let deferred = promise.defer();
  190. let bVar = gVariables.getScopeAtIndex(0).get("b");
  191. is(bVar.expanded, false,
  192. "The 'b' variable should not be expanded by default.");
  193. let bEnums = bVar.target.querySelector(".variables-view-element-details.enum").childNodes;
  194. let bNonEnums = bVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  195. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  196. is(bEnums.length, 1,
  197. "The 'b' variable should contain all the created enumerable elements.");
  198. is(bNonEnums.length, 1,
  199. "The 'b' variable should contain all the created non-enumerable elements.");
  200. is(bEnums[0].querySelector(".name").getAttribute("value"), "a",
  201. "Should have the right property name for 'a'.");
  202. is(bEnums[0].querySelector(".value").getAttribute("value"), "1",
  203. "Should have the right property value for 'a'.");
  204. ok(bEnums[0].querySelector(".value").className.includes("token-number"),
  205. "Should have the right token class for 'a'.");
  206. is(bNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__",
  207. "Should have the right property name for '__proto__'.");
  208. is(bNonEnums[0].querySelector(".value").getAttribute("value"), "Object",
  209. "Should have the right property value for '__proto__'.");
  210. ok(bNonEnums[0].querySelector(".value").className.includes("token-other"),
  211. "Should have the right token class for '__proto__'.");
  212. deferred.resolve();
  213. });
  214. bVar.expand();
  215. return deferred.promise;
  216. }
  217. function testComplexObject() {
  218. let deferred = promise.defer();
  219. let cVar = gVariables.getScopeAtIndex(0).get("c");
  220. is(cVar.expanded, false,
  221. "The 'c' variable should not be expanded by default.");
  222. let cEnums = cVar.target.querySelector(".variables-view-element-details.enum").childNodes;
  223. let cNonEnums = cVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  224. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  225. is(cEnums.length, 6,
  226. "The 'c' variable should contain all the created enumerable elements.");
  227. is(cNonEnums.length, 1,
  228. "The 'c' variable should contain all the created non-enumerable elements.");
  229. is(cEnums[0].querySelector(".name").getAttribute("value"), "a",
  230. "Should have the right property name for 'a'.");
  231. is(cEnums[0].querySelector(".value").getAttribute("value"), "1",
  232. "Should have the right property value for 'a'.");
  233. ok(cEnums[0].querySelector(".value").className.includes("token-number"),
  234. "Should have the right token class for 'a'.");
  235. is(cEnums[1].querySelector(".name").getAttribute("value"), "b",
  236. "Should have the right property name for 'b'.");
  237. is(cEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"",
  238. "Should have the right property value for 'b'.");
  239. ok(cEnums[1].querySelector(".value").className.includes("token-string"),
  240. "Should have the right token class for 'b'.");
  241. is(cEnums[2].querySelector(".name").getAttribute("value"), "c",
  242. "Should have the right property name for 'c'.");
  243. is(cEnums[2].querySelector(".value").getAttribute("value"), "3",
  244. "Should have the right property value for 'c'.");
  245. ok(cEnums[2].querySelector(".value").className.includes("token-number"),
  246. "Should have the right token class for 'c'.");
  247. is(cEnums[3].querySelector(".name").getAttribute("value"), "d",
  248. "Should have the right property name for 'd'.");
  249. is(cEnums[3].querySelector(".value").getAttribute("value"), "false",
  250. "Should have the right property value for 'd'.");
  251. ok(cEnums[3].querySelector(".value").className.includes("token-boolean"),
  252. "Should have the right token class for 'd'.");
  253. is(cEnums[4].querySelector(".name").getAttribute("value"), "e",
  254. "Should have the right property name for 'e'.");
  255. is(cEnums[4].querySelector(".value").getAttribute("value"), "null",
  256. "Should have the right property value for 'e'.");
  257. ok(cEnums[4].querySelector(".value").className.includes("token-null"),
  258. "Should have the right token class for 'e'.");
  259. is(cEnums[5].querySelector(".name").getAttribute("value"), "f",
  260. "Should have the right property name for 'f'.");
  261. is(cEnums[5].querySelector(".value").getAttribute("value"), "undefined",
  262. "Should have the right property value for 'f'.");
  263. ok(cEnums[5].querySelector(".value").className.includes("token-undefined"),
  264. "Should have the right token class for 'f'.");
  265. is(cNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__",
  266. "Should have the right property name for '__proto__'.");
  267. is(cNonEnums[0].querySelector(".value").getAttribute("value"), "Object",
  268. "Should have the right property value for '__proto__'.");
  269. ok(cNonEnums[0].querySelector(".value").className.includes("token-other"),
  270. "Should have the right token class for '__proto__'.");
  271. deferred.resolve();
  272. });
  273. cVar.expand();
  274. return deferred.promise;
  275. }
  276. function testArgumentObject() {
  277. let deferred = promise.defer();
  278. let argVar = gVariables.getScopeAtIndex(0).get("aArg");
  279. is(argVar.expanded, false,
  280. "The 'aArg' variable should not be expanded by default.");
  281. let argEnums = argVar.target.querySelector(".variables-view-element-details.enum").childNodes;
  282. let argNonEnums = argVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  283. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  284. is(argEnums.length, 6,
  285. "The 'aArg' variable should contain all the created enumerable elements.");
  286. is(argNonEnums.length, 1,
  287. "The 'aArg' variable should contain all the created non-enumerable elements.");
  288. is(argEnums[0].querySelector(".name").getAttribute("value"), "a",
  289. "Should have the right property name for 'a'.");
  290. is(argEnums[0].querySelector(".value").getAttribute("value"), "1",
  291. "Should have the right property value for 'a'.");
  292. ok(argEnums[0].querySelector(".value").className.includes("token-number"),
  293. "Should have the right token class for 'a'.");
  294. is(argEnums[1].querySelector(".name").getAttribute("value"), "b",
  295. "Should have the right property name for 'b'.");
  296. is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"",
  297. "Should have the right property value for 'b'.");
  298. ok(argEnums[1].querySelector(".value").className.includes("token-string"),
  299. "Should have the right token class for 'b'.");
  300. is(argEnums[2].querySelector(".name").getAttribute("value"), "c",
  301. "Should have the right property name for 'c'.");
  302. is(argEnums[2].querySelector(".value").getAttribute("value"), "3",
  303. "Should have the right property value for 'c'.");
  304. ok(argEnums[2].querySelector(".value").className.includes("token-number"),
  305. "Should have the right token class for 'c'.");
  306. is(argEnums[3].querySelector(".name").getAttribute("value"), "d",
  307. "Should have the right property name for 'd'.");
  308. is(argEnums[3].querySelector(".value").getAttribute("value"), "false",
  309. "Should have the right property value for 'd'.");
  310. ok(argEnums[3].querySelector(".value").className.includes("token-boolean"),
  311. "Should have the right token class for 'd'.");
  312. is(argEnums[4].querySelector(".name").getAttribute("value"), "e",
  313. "Should have the right property name for 'e'.");
  314. is(argEnums[4].querySelector(".value").getAttribute("value"), "null",
  315. "Should have the right property value for 'e'.");
  316. ok(argEnums[4].querySelector(".value").className.includes("token-null"),
  317. "Should have the right token class for 'e'.");
  318. is(argEnums[5].querySelector(".name").getAttribute("value"), "f",
  319. "Should have the right property name for 'f'.");
  320. is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined",
  321. "Should have the right property value for 'f'.");
  322. ok(argEnums[5].querySelector(".value").className.includes("token-undefined"),
  323. "Should have the right token class for 'f'.");
  324. is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__",
  325. "Should have the right property name for '__proto__'.");
  326. is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object",
  327. "Should have the right property value for '__proto__'.");
  328. ok(argNonEnums[0].querySelector(".value").className.includes("token-other"),
  329. "Should have the right token class for '__proto__'.");
  330. deferred.resolve();
  331. });
  332. argVar.expand();
  333. return deferred.promise;
  334. }
  335. function testInnerArgumentObject() {
  336. let deferred = promise.defer();
  337. let argProp = gVariables.getScopeAtIndex(0).get("arguments").get("0");
  338. is(argProp.expanded, false,
  339. "The 'arguments[0]' property should not be expanded by default.");
  340. let argEnums = argProp.target.querySelector(".variables-view-element-details.enum").childNodes;
  341. let argNonEnums = argProp.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  342. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  343. is(argEnums.length, 6,
  344. "The 'arguments[0]' property should contain all the created enumerable elements.");
  345. is(argNonEnums.length, 1,
  346. "The 'arguments[0]' property should contain all the created non-enumerable elements.");
  347. is(argEnums[0].querySelector(".name").getAttribute("value"), "a",
  348. "Should have the right property name for 'a'.");
  349. is(argEnums[0].querySelector(".value").getAttribute("value"), "1",
  350. "Should have the right property value for 'a'.");
  351. ok(argEnums[0].querySelector(".value").className.includes("token-number"),
  352. "Should have the right token class for 'a'.");
  353. is(argEnums[1].querySelector(".name").getAttribute("value"), "b",
  354. "Should have the right property name for 'b'.");
  355. is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"",
  356. "Should have the right property value for 'b'.");
  357. ok(argEnums[1].querySelector(".value").className.includes("token-string"),
  358. "Should have the right token class for 'b'.");
  359. is(argEnums[2].querySelector(".name").getAttribute("value"), "c",
  360. "Should have the right property name for 'c'.");
  361. is(argEnums[2].querySelector(".value").getAttribute("value"), "3",
  362. "Should have the right property value for 'c'.");
  363. ok(argEnums[2].querySelector(".value").className.includes("token-number"),
  364. "Should have the right token class for 'c'.");
  365. is(argEnums[3].querySelector(".name").getAttribute("value"), "d",
  366. "Should have the right property name for 'd'.");
  367. is(argEnums[3].querySelector(".value").getAttribute("value"), "false",
  368. "Should have the right property value for 'd'.");
  369. ok(argEnums[3].querySelector(".value").className.includes("token-boolean"),
  370. "Should have the right token class for 'd'.");
  371. is(argEnums[4].querySelector(".name").getAttribute("value"), "e",
  372. "Should have the right property name for 'e'.");
  373. is(argEnums[4].querySelector(".value").getAttribute("value"), "null",
  374. "Should have the right property value for 'e'.");
  375. ok(argEnums[4].querySelector(".value").className.includes("token-null"),
  376. "Should have the right token class for 'e'.");
  377. is(argEnums[5].querySelector(".name").getAttribute("value"), "f",
  378. "Should have the right property name for 'f'.");
  379. is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined",
  380. "Should have the right property value for 'f'.");
  381. ok(argEnums[5].querySelector(".value").className.includes("token-undefined"),
  382. "Should have the right token class for 'f'.");
  383. is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__",
  384. "Should have the right property name for '__proto__'.");
  385. is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object",
  386. "Should have the right property value for '__proto__'.");
  387. ok(argNonEnums[0].querySelector(".value").className.includes("token-other"),
  388. "Should have the right token class for '__proto__'.");
  389. deferred.resolve();
  390. });
  391. argProp.expand();
  392. return deferred.promise;
  393. }
  394. function testGetterSetterObject() {
  395. let deferred = promise.defer();
  396. let myVar = gVariables.getScopeAtIndex(0).get("myVar");
  397. is(myVar.expanded, false,
  398. "The myVar variable should not be expanded by default.");
  399. let myVarEnums = myVar.target.querySelector(".variables-view-element-details.enum").childNodes;
  400. let myVarNonEnums = myVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
  401. gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => {
  402. is(myVarEnums.length, 2,
  403. "The myVar should contain all the created enumerable elements.");
  404. is(myVarNonEnums.length, 1,
  405. "The myVar should contain all the created non-enumerable elements.");
  406. is(myVarEnums[0].querySelector(".name").getAttribute("value"), "_prop",
  407. "Should have the right property name for '_prop'.");
  408. is(myVarEnums[0].querySelector(".value").getAttribute("value"), "42",
  409. "Should have the right property value for '_prop'.");
  410. ok(myVarEnums[0].querySelector(".value").className.includes("token-number"),
  411. "Should have the right token class for '_prop'.");
  412. is(myVarEnums[1].querySelector(".name").getAttribute("value"), "prop",
  413. "Should have the right property name for 'prop'.");
  414. is(myVarEnums[1].querySelector(".value").getAttribute("value"), "",
  415. "Should have the right property value for 'prop'.");
  416. ok(!myVarEnums[1].querySelector(".value").className.includes("token"),
  417. "Should have no token class for 'prop'.");
  418. is(myVarNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__",
  419. "Should have the right property name for '__proto__'.");
  420. is(myVarNonEnums[0].querySelector(".value").getAttribute("value"), "Object",
  421. "Should have the right property value for '__proto__'.");
  422. ok(myVarNonEnums[0].querySelector(".value").className.includes("token-other"),
  423. "Should have the right token class for '__proto__'.");
  424. let propEnums = myVarEnums[1].querySelector(".variables-view-element-details.enum").childNodes;
  425. let propNonEnums = myVarEnums[1].querySelector(".variables-view-element-details.nonenum").childNodes;
  426. is(propEnums.length, 0,
  427. "The propEnums should contain all the created enumerable elements.");
  428. is(propNonEnums.length, 2,
  429. "The propEnums should contain all the created non-enumerable elements.");
  430. is(propNonEnums[0].querySelector(".name").getAttribute("value"), "get",
  431. "Should have the right property name for 'get'.");
  432. is(propNonEnums[0].querySelector(".value").getAttribute("value"),
  433. "get prop()",
  434. "Should have the right property value for 'get'.");
  435. ok(propNonEnums[0].querySelector(".value").className.includes("token-other"),
  436. "Should have the right token class for 'get'.");
  437. is(propNonEnums[1].querySelector(".name").getAttribute("value"), "set",
  438. "Should have the right property name for 'set'.");
  439. is(propNonEnums[1].querySelector(".value").getAttribute("value"),
  440. "set prop(val)",
  441. "Should have the right property value for 'set'.");
  442. ok(propNonEnums[1].querySelector(".value").className.includes("token-other"),
  443. "Should have the right token class for 'set'.");
  444. deferred.resolve();
  445. });
  446. myVar.expand();
  447. return deferred.promise;
  448. }
  449. registerCleanupFunction(function () {
  450. gTab = null;
  451. gPanel = null;
  452. gDebugger = null;
  453. gVariables = null;
  454. });