browser_webconsole_autocomplete-properties-with-non-alphanumeric-names.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. "use strict";
  5. // Test that properties starting with underscores or dollars can be
  6. // autocompleted (bug 967468).
  7. add_task(function* () {
  8. const TEST_URI = "data:text/html;charset=utf8,test autocompletion with " +
  9. "$ or _";
  10. yield loadTab(TEST_URI);
  11. function* autocomplete(term) {
  12. let deferred = promise.defer();
  13. jsterm.setInputValue(term);
  14. jsterm.complete(jsterm.COMPLETE_HINT_ONLY, deferred.resolve);
  15. yield deferred.promise;
  16. ok(popup.itemCount > 0,
  17. "There's " + popup.itemCount + " suggestions for '" + term + "'");
  18. }
  19. let { jsterm } = yield openConsole();
  20. let popup = jsterm.autocompletePopup;
  21. yield jsterm.execute("var testObject = {$$aaab: '', $$aaac: ''}");
  22. // Should work with bug 967468.
  23. yield autocomplete("Object.__d");
  24. yield autocomplete("testObject.$$a");
  25. // Here's when things go wrong in bug 967468.
  26. yield autocomplete("Object.__de");
  27. yield autocomplete("testObject.$$aa");
  28. // Should work with bug 1207868.
  29. yield jsterm.execute("let foobar = {a: ''}; const blargh = {a: 1};");
  30. yield autocomplete("foobar");
  31. yield autocomplete("blargh");
  32. yield autocomplete("foobar.a");
  33. yield autocomplete("blargh.a");
  34. });