PageRenderTime 2883ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/wpt/web-platform-tests/html/browsers/the-window-object/window-properties.html

https://gitlab.com/0072016/0072016-SDK-js-sdk-framework-
HTML | 322 lines | 307 code | 15 blank | 0 comment | 0 complexity | 3a74577f5232e74d5b6f2f1b364efd47 MD5 | raw file
  1. <!doctype html>
  2. <meta charset=utf-8>
  3. <title>Properties of the window object</title>
  4. <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
  5. <link rel="help" href="http://ecma-international.org/ecma-262/5.1/#sec-15.1">
  6. <link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object">
  7. <link rel="help" href="https://heycam.github.io/webidl/#es-attributes">
  8. <link rel="help" href="https://heycam.github.io/webidl/#es-operations">
  9. <link rel="help" href="https://dom.spec.whatwg.org/#eventtarget">
  10. <link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
  11. <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowtimers">
  12. <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowbase64">
  13. <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstorage">
  14. <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorage">
  15. <link rel="help" href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-window-getselection">
  16. <link rel="help" href="http://dev.w3.org/csswg/cssom/#widl-def-Window">
  17. <link rel="help" href="http://dev.w3.org/csswg/cssom-view/#widl-def-Window">
  18. <script src="/resources/testharness.js"></script>
  19. <script src="/resources/testharnessreport.js"></script>
  20. <div id=log></div>
  21. <script>
  22. function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
  23. assert_equals(typeof pd, "object");
  24. assert_equals(pd.writable, Writable);
  25. assert_equals(pd.enumerable, Enumerable);
  26. assert_equals(pd.configurable, Configurable);
  27. }
  28. function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) {
  29. assert_equals(typeof pd, "object");
  30. assert_equals(typeof pd.get, "function");
  31. assert_true("set" in pd,
  32. "Should always have a setter property on the property descriptor");
  33. assert_equals(typeof pd.set, hasSetter ? "function" : "undefined");
  34. assert_equals(pd.enumerable, Enumerable);
  35. assert_equals(pd.configurable, Configurable);
  36. }
  37. var unforgeableAttributes = [
  38. "window",
  39. "document",
  40. "location",
  41. "top"
  42. ];
  43. var replaceableAttributes = [
  44. "self",
  45. "locationbar",
  46. "menubar",
  47. "personalbar",
  48. "scrollbars",
  49. "statusbar",
  50. "toolbar",
  51. "frames",
  52. "parent",
  53. "external",
  54. "length",
  55. // CSSOM-View
  56. "screen",
  57. "scrollX",
  58. "scrollY",
  59. "pageXOffset",
  60. "pageYOffset",
  61. "innerWidth",
  62. "innerHeight",
  63. "screenX",
  64. "screenY",
  65. "outerWidth",
  66. "outerHeight",
  67. "devicePixelRatio",
  68. ];
  69. var methods = [
  70. "close",
  71. "stop",
  72. "focus",
  73. "blur",
  74. "open",
  75. "alert",
  76. "confirm",
  77. "prompt",
  78. "print",
  79. // See below: "showModalDialog",
  80. "postMessage",
  81. // WindowBase64
  82. "btoa",
  83. "atob",
  84. // WindowTimers
  85. "setTimeout",
  86. "clearTimeout",
  87. "setInterval",
  88. "clearInterval",
  89. // HTML Editing APIs
  90. "getSelection",
  91. // CSSOM
  92. "getComputedStyle",
  93. // CSSOM-View
  94. "matchMedia",
  95. "scroll",
  96. "scrollTo",
  97. "scrollBy"
  98. ];
  99. // We would like to remove showModalDialog from the platform,
  100. // see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=26437>.
  101. if ("showModalDialog" in window) {
  102. methods.push("showModalDialog");
  103. }
  104. var readonlyAttributes = [
  105. "history",
  106. "frameElement",
  107. "navigator",
  108. "applicationCache",
  109. // WindowSessionStorage
  110. "sessionStorage",
  111. // WindowLocalStorage
  112. "localStorage",
  113. ];
  114. var writableAttributes = [
  115. "name",
  116. "status",
  117. "opener",
  118. "onabort",
  119. "onafterprint",
  120. "onbeforeprint",
  121. "onbeforeunload",
  122. "onblur",
  123. "oncancel",
  124. "oncanplay",
  125. "oncanplaythrough",
  126. "onchange",
  127. "onclick",
  128. "onclose",
  129. "oncontextmenu",
  130. "oncuechange",
  131. "ondblclick",
  132. "ondrag",
  133. "ondragend",
  134. "ondragenter",
  135. "ondragleave",
  136. "ondragover",
  137. "ondragstart",
  138. "ondrop",
  139. "ondurationchange",
  140. "onemptied",
  141. "onended",
  142. "onerror",
  143. "onfocus",
  144. "onhashchange",
  145. "oninput",
  146. "oninvalid",
  147. "onkeydown",
  148. "onkeypress",
  149. "onkeyup",
  150. "onload",
  151. "onloadeddata",
  152. "onloadedmetadata",
  153. "onloadstart",
  154. "onmessage",
  155. "onmousedown",
  156. "onmousemove",
  157. "onmouseout",
  158. "onmouseover",
  159. "onmouseup",
  160. "onmousewheel",
  161. "onoffline",
  162. "ononline",
  163. "onpause",
  164. "onplay",
  165. "onplaying",
  166. "onpagehide",
  167. "onpageshow",
  168. "onpopstate",
  169. "onprogress",
  170. "onratechange",
  171. "onreset",
  172. "onresize",
  173. "onscroll",
  174. "onseeked",
  175. "onseeking",
  176. "onselect",
  177. "onshow",
  178. "onstalled",
  179. "onstorage",
  180. "onsubmit",
  181. "onsuspend",
  182. "ontimeupdate",
  183. "onunload",
  184. "onvolumechange",
  185. "onwaiting"
  186. ];
  187. test(function() {
  188. // 15.1.1 Value Properties of the Global Object
  189. ["NaN", "Infinity", "undefined"].forEach(function(id) {
  190. test(function() {
  191. assert_true(id in window, id + " in window");
  192. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  193. false, false, false);
  194. }, "Value Property: " + id);
  195. });
  196. }, "Value Properties of the Global Object");
  197. test(function() {
  198. // 15.1.2 Function Properties of the Global Object
  199. ["eval", "parseInt", "parseFloat", "isNaN", "isFinite"].forEach(function(id) {
  200. test(function() {
  201. assert_true(id in window, id + " in window");
  202. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  203. true, false, true);
  204. }, "Function Property: " + id);
  205. });
  206. }, "Function Properties of the Global Object");
  207. test(function() {
  208. // 15.1.3 URI Handling Function Properties
  209. ["decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent"].forEach(function(id) {
  210. test(function() {
  211. assert_true(id in window, id + " in window");
  212. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  213. true, false, true);
  214. }, "URI Handling Function Property: " + id);
  215. });
  216. }, "URI Handling Function Properties");
  217. test(function() {
  218. // 15.1.4 Constructor Properties of the Global Object
  219. ["Object", "Function", "Array", "String", "Boolean", "Number", "Date",
  220. "RegExp", "Error", "EvalError", "RangeError", "ReferenceError",
  221. "SyntaxError", "TypeError", "URIError"].forEach(function(id) {
  222. test(function() {
  223. assert_true(id in window, id + " in window");
  224. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  225. true, false, true);
  226. }, "Constructor Property: " + id);
  227. });
  228. }, "Constructor Properties of the Global Object");
  229. test(function() {
  230. // 15.1.5 Other Properties of the Global Object
  231. ["Math", "JSON"].forEach(function(id) {
  232. test(function() {
  233. assert_true(id in window, id + " in window");
  234. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  235. true, false, true);
  236. }, "Other Property: " + id);
  237. });
  238. }, "Other Properties of the Global Object");
  239. test(function() {
  240. // EventTarget interface
  241. ["addEventListener", "removeEventListener", "dispatchEvent"].forEach(function(id) {
  242. test(function() {
  243. var EventTargetProto = EventTarget.prototype;
  244. assert_true(id in window, id + " in window");
  245. assert_equals(window[id], EventTargetProto[id]);
  246. assert_data_propdesc(Object.getOwnPropertyDescriptor(EventTargetProto, id),
  247. true, true, true);
  248. assert_equals(Object.getOwnPropertyDescriptor(window, id), undefined);
  249. }, "EventTarget method: " + id);
  250. });
  251. }, "EventTarget interface");
  252. test(function() {
  253. // Window interface
  254. methods.forEach(function(id) {
  255. test(function() {
  256. var WindowProto = Window.prototype;
  257. assert_true(id in window, id + " in window");
  258. assert_false(id in WindowProto, id + " in Window.prototype");
  259. assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
  260. true, true, true);
  261. }, "Window method: " + id);
  262. });
  263. readonlyAttributes.forEach(function(id) {
  264. test(function() {
  265. var WindowProto = Window.prototype;
  266. assert_true(id in window, id + " in window");
  267. assert_false(id in WindowProto, id + " in Window.prototype");
  268. assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
  269. false, true, true);
  270. }, "Window readonly attribute: " + id);
  271. });
  272. writableAttributes.forEach(function(id) {
  273. test(function() {
  274. var WindowProto = Window.prototype;
  275. assert_true(id in window, id + " in window");
  276. assert_false(id in WindowProto, id + " in Window.prototype");
  277. assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
  278. true, true, true);
  279. }, "Window attribute: " + id);
  280. });
  281. unforgeableAttributes.forEach(function(id) {
  282. test(function() {
  283. var WindowProto = Window.prototype;
  284. assert_true(id in window, id + " in window");
  285. assert_false(id in WindowProto, id + " in Window.prototype");
  286. // location has a [PutForwards] extended attribute.
  287. assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
  288. id === "location", true, false);
  289. }, "Window unforgeable attribute: " + id);
  290. });
  291. replaceableAttributes.forEach(function(id) {
  292. test(function() {
  293. var WindowProto = Window.prototype;
  294. assert_true(id in window, id + " in window");
  295. assert_false(id in WindowProto, id + " in Window.prototype");
  296. assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
  297. true, true, true);
  298. }, "Window replaceable attribute: " + id);
  299. });
  300. }, "Window interface");
  301. test(function() {
  302. assert_equals(window.constructor, Window);
  303. assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
  304. assert_data_propdesc(Object.getOwnPropertyDescriptor(Window.prototype, "constructor"),
  305. true, false, true);
  306. }, "constructor");
  307. </script>