webbrowser.jsdoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**
  2. Zombie Navigator API (ZAPI) documentation
  3. @copyright
  4. Copyright © 2015 Zombie Navigator Developers
  5. <br /><br />
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License as
  8. published by the Free Software Foundation, either version 3 of the
  9. License, or (at your option) any later version.
  10. <br /><br />
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. <br /><br />
  16. You should have received a copy of the GNU Affero General Public License
  17. along with this program. If not, see {@link http://www.gnu.org/licenses/}.
  18. <br /><br />
  19. The latest version of the GNU AGPL should be available here:
  20. {@link https://www.gnu.org/licenses/agpl.html}
  21. @file
  22. @module zombie/webbrowser
  23. @license AGPL-3.0+
  24. */
  25. /*
  26. This is not a script but a JSDoc documentation source.
  27. */
  28. /**
  29. Open a window (tab)
  30. @param {string} uri
  31. @returns {Promise} Resolves to {@link Window}
  32. @public
  33. */
  34. var openWindow = function () {};
  35. /**
  36. Open a private window (tab)
  37. @param {string} uri
  38. @returns {Promise} Resolves to {@link Window}
  39. @public
  40. */
  41. var openPrivateWindow = function () {};
  42. /**
  43. Close all windows opened by the Zombie script
  44. This doesn't close any other windows, so if the user moves a Zombie tab into
  45. another window, that tab is not closed here.
  46. @returns {Promise}
  47. @public
  48. */
  49. var closeAll = function () {};
  50. /**
  51. A browser window, or a tab
  52. @example
  53. require('zombie/webbrowser').openPrivateWindow('about:')
  54. .then(window => {
  55. console.log(window.uri);
  56. })
  57. .catch(e => {
  58. console.exception(e); // failed
  59. });
  60. @class
  61. @protected
  62. */
  63. var Window = function Window () {
  64. /**
  65. Whether this window is private (Private Browsing)
  66. @type {bool}
  67. @public
  68. @readonly
  69. */
  70. this.isPrivate = false;
  71. /**
  72. The URI of the window
  73. @type {string}
  74. @public
  75. @readonly
  76. */
  77. this.uri = false;
  78. /**
  79. Close the window
  80. @returns {Promise}
  81. @public
  82. */
  83. this.close = function () {};
  84. /**
  85. Wait until the tab is reloaded
  86. @returns {Promise}
  87. @public
  88. */
  89. this.waitForReload = function () {};
  90. /**
  91. Run a script inside this tab
  92. @example
  93. let promise = w.runScript(function (arg1, arg2) {
  94. console.log(document.title);
  95. return 'result';
  96. }, 'arg1', 'arg2');
  97. @param {function} callback The script to run
  98. @param {...*} args Passed to the callback
  99. @returns {Promise} Resolves to the result of the callback
  100. @public
  101. */
  102. this.runScript = function () {};
  103. /**
  104. Reload this tab
  105. @returns {Promise}
  106. @public
  107. */
  108. this.reload = function () {};
  109. };
  110. // vim: ts=4 noet ai ft=js