webbrowser.jsdoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. Zombie Navigator API (ZAPI) documentation
  3. @copyright
  4. Copyright © 2016 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.6.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. Take a screenshot of the tab content
  110. @since 0.6.0
  111. @example
  112. w.screenshot().then(dataURI => {
  113. w.uri = dataURI;
  114. });
  115. @param {bool} windowSized Whether the screenshot is limited to the browser window boader
  116. @returns {Promise} Resolves to the data URI of the image
  117. @public
  118. */
  119. this.screenshot = function () {};
  120. /**
  121. Reload this tab
  122. @returns {Promise}
  123. @public
  124. */
  125. this.reload = function () {};
  126. };
  127. // vim: ts=4 noet ai ft=js