access.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. /**
  3. Part of Zombie Navigator
  4. Copyright © 2016 Zombie Navigator Developers
  5. @file
  6. @license AGPL-3.0+
  7. */
  8. /*
  9. Zombie script example (= unprivileged)
  10. Do NOT require () this script from the addon code.
  11. */
  12. const consoleType = typeof console;
  13. do {
  14. const {zombie, console} = require('zombie/zombie');
  15. const {openWindow, openPrivateWindow, closeAll} = require('zombie/webbrowser');
  16. const {run, delay} = require('zombie/async');
  17. console.log('console:', consoleType);
  18. run(function* () {
  19. let w = yield openPrivateWindow('about:');
  20. console.log(w);
  21. console.log(w.uri);
  22. yield w.runScript(function () {
  23. location.href = 'about:config';
  24. console.log (typeof window.wrappedObject);
  25. });
  26. yield w.waitForReload();
  27. console.log(w.uri);
  28. // unprivileged URI
  29. w.uri = 'data:,';
  30. yield w.waitForReload();
  31. console.log(w.uri);
  32. yield w.runScript(function () {
  33. location.href = 'about:config'; // denied
  34. });
  35. // this doesn't happen
  36. yield w.waitForReload();
  37. console.log(w.uri);
  38. });
  39. } while (false);
  40. // vim: ts=4 noet ai