webbrowser.jsdoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. @version 0.4.0
  25. */
  26. /*
  27. This is not a script but a JSDoc documentation source.
  28. */
  29. /**
  30. Open a window (tab)
  31. @param {string} uri
  32. @returns {Promise} Resolves to {@link Window}
  33. @public
  34. */
  35. var openWindow = function () {};
  36. /**
  37. Open a private window (tab)
  38. @param {string} uri
  39. @returns {Promise} Resolves to {@link Window}
  40. @public
  41. */
  42. var openPrivateWindow = function () {};
  43. /**
  44. Close all windows opened by the Zombie script
  45. This doesn't close any other windows, so if the user moves a Zombie tab into
  46. another window, that tab is not closed here.
  47. @returns {Promise}
  48. @public
  49. */
  50. var closeAll = function () {};
  51. /**
  52. A browser window, or a tab
  53. @example
  54. require('zombie/webbrowser').openPrivateWindow('about:')
  55. .then(window => {
  56. console.log(window.uri);
  57. })
  58. .catch(e => {
  59. console.exception(e); // failed
  60. });
  61. @class
  62. @protected
  63. */
  64. var Window = function Window () {
  65. /**
  66. Whether this window is private (Private Browsing)
  67. @type {bool}
  68. @public
  69. @readonly
  70. */
  71. this.isPrivate = false;
  72. /**
  73. The URI of the window
  74. @example
  75. // writable since 0.4.0
  76. window.uri = 'about:';
  77. window.waitForReload()
  78. .then(...)
  79. @type {string}
  80. @public
  81. */
  82. this.uri = false;
  83. /**
  84. Close the window
  85. @returns {Promise}
  86. @public
  87. */
  88. this.close = function () {};
  89. /**
  90. Wait until the tab is reloaded
  91. @returns {Promise}
  92. @public
  93. */
  94. this.waitForReload = function () {};
  95. /**
  96. Run a script inside this tab
  97. @example
  98. let promise = w.runScript(function (arg1, arg2) {
  99. console.log(document.title);
  100. return 'result';
  101. }, 'arg1', 'arg2');
  102. @param {function} callback The script to run
  103. @param {...*} args Passed to the callback
  104. @returns {Promise} Resolves to the result of the callback
  105. @public
  106. */
  107. this.runScript = function () {};
  108. /**
  109. Reload this tab
  110. @returns {Promise}
  111. @public
  112. */
  113. this.reload = function () {};
  114. };
  115. // vim: ts=4 noet ai ft=js