test_globalObjects_other.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. var testGenerator = testSteps();
  6. function testSteps()
  7. {
  8. let ioService =
  9. Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
  10. function getSpec(filename) {
  11. let file = do_get_file(filename);
  12. let uri = ioService.newFileURI(file);
  13. return uri.spec;
  14. }
  15. // Test for IDBKeyRange and indexedDB availability in JS modules.
  16. Cu.import(getSpec("GlobalObjectsModule.jsm"));
  17. let test = new GlobalObjectsModule();
  18. test.ok = ok;
  19. test.finishTest = continueToNextStep;
  20. test.runTest();
  21. yield undefined;
  22. // Test for IDBKeyRange and indexedDB availability in JS components.
  23. do_load_manifest("GlobalObjectsComponent.manifest");
  24. test = Cc["@mozilla.org/dom/indexeddb/GlobalObjectsComponent;1"].
  25. createInstance(Ci.nsISupports).wrappedJSObject;
  26. test.ok = ok;
  27. test.finishTest = continueToNextStep;
  28. test.runTest();
  29. yield undefined;
  30. // Test for IDBKeyRange and indexedDB availability in JS sandboxes.
  31. let principal = Cc["@mozilla.org/systemprincipal;1"].
  32. createInstance(Ci.nsIPrincipal);
  33. let sandbox = new Cu.Sandbox(principal,
  34. { wantGlobalProperties: ["indexedDB"] });
  35. sandbox.__SCRIPT_URI_SPEC__ = getSpec("GlobalObjectsSandbox.js");
  36. Cu.evalInSandbox(
  37. "Components.classes['@mozilla.org/moz/jssubscript-loader;1'] \
  38. .createInstance(Components.interfaces.mozIJSSubScriptLoader) \
  39. .loadSubScript(__SCRIPT_URI_SPEC__);", sandbox, "1.7");
  40. sandbox.ok = ok;
  41. sandbox.finishTest = continueToNextStep;
  42. Cu.evalInSandbox("runTest();", sandbox);
  43. yield undefined;
  44. finishTest();
  45. yield undefined;
  46. }
  47. this.runTest = function() {
  48. do_get_profile();
  49. do_test_pending();
  50. testGenerator.next();
  51. }