browser_console_native_getters.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // Check that native getters and setters for DOM elements work as expected in
  5. // variables view - bug 870220.
  6. "use strict";
  7. const TEST_URI = "data:text/html;charset=utf8,<title>bug870220</title>\n" +
  8. "<p>hello world\n<p>native getters!";
  9. requestLongerTimeout(2);
  10. add_task(function* () {
  11. yield loadTab(TEST_URI);
  12. let hud = yield openConsole();
  13. let jsterm = hud.jsterm;
  14. jsterm.execute("document");
  15. let [result] = yield waitForMessages({
  16. webconsole: hud,
  17. messages: [{
  18. text: "HTMLDocument \u2192 data:text/html;charset=utf8",
  19. category: CATEGORY_OUTPUT,
  20. objects: true,
  21. }],
  22. });
  23. let clickable = result.clickableElements[0];
  24. ok(clickable, "clickable object found");
  25. executeSoon(() => {
  26. EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
  27. });
  28. let fetchedVar = yield jsterm.once("variablesview-fetched");
  29. let variablesView = fetchedVar._variablesView;
  30. ok(variablesView, "variables view object");
  31. let results = yield findVariableViewProperties(fetchedVar, [
  32. { name: "title", value: "bug870220" },
  33. { name: "bgColor" },
  34. ], { webconsole: hud });
  35. let prop = results[1].matchedProp;
  36. ok(prop, "matched the |bgColor| property in the variables view");
  37. // Check that property value updates work.
  38. let updatedVar = yield updateVariablesViewProperty({
  39. property: prop,
  40. field: "value",
  41. string: "'red'",
  42. webconsole: hud,
  43. });
  44. info("on fetch after background update");
  45. jsterm.clearOutput(true);
  46. jsterm.execute("document.bgColor");
  47. [result] = yield waitForMessages({
  48. webconsole: hud,
  49. messages: [{
  50. text: "red",
  51. category: CATEGORY_OUTPUT,
  52. }],
  53. });
  54. yield findVariableViewProperties(updatedVar, [
  55. { name: "bgColor", value: "red" },
  56. ], { webconsole: hud });
  57. jsterm.execute("$$('p')");
  58. [result] = yield waitForMessages({
  59. webconsole: hud,
  60. messages: [{
  61. text: "Array [",
  62. category: CATEGORY_OUTPUT,
  63. objects: true,
  64. }],
  65. });
  66. clickable = result.clickableElements[0];
  67. ok(clickable, "clickable object found");
  68. executeSoon(() => {
  69. EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
  70. });
  71. fetchedVar = yield jsterm.once("variablesview-fetched");
  72. yield findVariableViewProperties(fetchedVar, [
  73. { name: "0.textContent", value: /hello world/ },
  74. { name: "1.textContent", value: /native getters/ },
  75. ], { webconsole: hud });
  76. });