test_isSet.js 899 B

1234567891011121314151617181920212223242526
  1. /* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/ */
  4. // Test ThreadSafeDevToolsUtils.isSet
  5. function run_test() {
  6. const { isSet } = DevToolsUtils;
  7. equal(isSet(new Set()), true);
  8. equal(isSet(new Map()), false);
  9. equal(isSet({}), false);
  10. equal(isSet("I swear I'm a Set"), false);
  11. equal(isSet(5), false);
  12. const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
  13. .createInstance(Ci.nsIPrincipal);
  14. const sandbox = new Cu.Sandbox(systemPrincipal);
  15. equal(isSet(Cu.evalInSandbox("new Set()", sandbox)), true);
  16. equal(isSet(Cu.evalInSandbox("new Map()", sandbox)), false);
  17. equal(isSet(Cu.evalInSandbox("({})", sandbox)), false);
  18. equal(isSet(Cu.evalInSandbox("'I swear I\\'m a Set'", sandbox)), false);
  19. equal(isSet(Cu.evalInSandbox("5", sandbox)), false);
  20. }