index.d.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. declare const createAttributeProxy: (caseInsensitive: boolean) => any;
  2. declare class MockAttributeMap {
  3. caseInsensitive: boolean;
  4. constructor(caseInsensitive?: boolean);
  5. get length(): number;
  6. item(index: number): MockAttr;
  7. setNamedItem(attr: MockAttr): void;
  8. setNamedItemNS(attr: MockAttr): void;
  9. getNamedItem(attrName: string): MockAttr;
  10. getNamedItemNS(namespaceURI: string, attrName: string): MockAttr;
  11. removeNamedItem(attr: MockAttr): void;
  12. removeNamedItemNS(attr: MockAttr): void;
  13. [Symbol.iterator](): {
  14. next: () => {
  15. done: boolean;
  16. value: MockAttr;
  17. };
  18. };
  19. get [Symbol.toStringTag](): string;
  20. }
  21. declare function cloneAttributes(srcAttrs: MockAttributeMap, sortByName?: boolean): MockAttributeMap;
  22. declare class MockAttr {
  23. constructor(attrName: string, attrValue: string, namespaceURI?: string);
  24. get name(): string;
  25. set name(value: string);
  26. get value(): string;
  27. set value(value: string);
  28. get nodeName(): string;
  29. set nodeName(value: string);
  30. get nodeValue(): string;
  31. set nodeValue(value: string);
  32. get namespaceURI(): string;
  33. set namespaceURI(namespaceURI: string);
  34. }
  35. declare class MockClassList {
  36. constructor(elm: HTMLElement);
  37. add(...classNames: string[]): void;
  38. remove(...classNames: string[]): void;
  39. contains(className: string): boolean;
  40. toggle(className: string): void;
  41. get length(): number;
  42. item(index: number): string;
  43. toString(): string;
  44. }
  45. declare class MockComment extends MockNode {
  46. constructor(ownerDocument: any, data: string);
  47. cloneNode(_deep?: boolean): MockComment;
  48. get textContent(): string;
  49. set textContent(text: string);
  50. }
  51. declare function createConsole(): any;
  52. declare const enum NODE_TYPES {
  53. ELEMENT_NODE = 1,
  54. ATTRIBUTE_NODE = 2,
  55. TEXT_NODE = 3,
  56. CDATA_SECTION_NODE = 4,
  57. ENTITY_REFERENCE_NODE = 5,
  58. ENTITY_NODE = 6,
  59. PROCESSING_INSTRUCTION_NODE = 7,
  60. COMMENT_NODE = 8,
  61. DOCUMENT_NODE = 9,
  62. DOCUMENT_TYPE_NODE = 10,
  63. DOCUMENT_FRAGMENT_NODE = 11,
  64. NOTATION_NODE = 12
  65. }
  66. declare const enum NODE_NAMES {
  67. COMMENT_NODE = "#comment",
  68. DOCUMENT_NODE = "#document",
  69. DOCUMENT_FRAGMENT_NODE = "#document-fragment",
  70. TEXT_NODE = "#text"
  71. }
  72. declare class MockCSSStyleDeclaration {
  73. setProperty(prop: string, value: string): void;
  74. getPropertyValue(prop: string): string;
  75. removeProperty(prop: string): void;
  76. get length(): number;
  77. get cssText(): string;
  78. set cssText(cssText: string);
  79. }
  80. declare function createCSSStyleDeclaration(): MockCSSStyleDeclaration;
  81. declare class MockCSSRule {
  82. parentStyleSheet: MockCSSStyleSheet;
  83. cssText: string;
  84. type: number;
  85. constructor(parentStyleSheet: MockCSSStyleSheet);
  86. }
  87. declare class MockCSSStyleSheet {
  88. ownerNode: any;
  89. type: string;
  90. parentStyleSheet: MockCSSStyleSheet;
  91. cssRules: MockCSSRule[];
  92. constructor(ownerNode: MockStyleElement);
  93. get rules(): MockCSSRule[];
  94. set rules(rules: MockCSSRule[]);
  95. deleteRule(index: number): void;
  96. insertRule(rule: string, index?: number): number;
  97. }
  98. declare function getStyleElementText(styleElm: MockStyleElement): string;
  99. declare function setStyleElementText(styleElm: MockStyleElement, text: string): void;
  100. declare class MockCustomElementRegistry implements CustomElementRegistry {
  101. constructor(win: Window);
  102. define(tagName: string, cstr: any, options?: any): void;
  103. get(tagName: string): any;
  104. upgrade(_rootNode: any): void;
  105. clear(): void;
  106. whenDefined(tagName: string): Promise<CustomElementConstructor>;
  107. }
  108. declare function createCustomElement(customElements: MockCustomElementRegistry, ownerDocument: any, tagName: string): any;
  109. declare function connectNode(ownerDocument: any, node: MockNode): void;
  110. declare function disconnectNode(node: MockNode): void;
  111. declare function attributeChanged(node: MockNode, attrName: string, oldValue: string, newValue: string): void;
  112. declare function checkAttributeChanged(node: MockNode): boolean;
  113. declare function dataset(elm: MockElement): any;
  114. declare class MockDocumentFragment extends MockHTMLElement {
  115. constructor(ownerDocument: any);
  116. getElementById(id: string): MockElement;
  117. cloneNode(deep?: boolean): MockDocumentFragment;
  118. }
  119. declare class MockDocumentTypeNode extends MockHTMLElement {
  120. constructor(ownerDocument: any);
  121. }
  122. declare class MockDocument extends MockHTMLElement {
  123. defaultView: any;
  124. cookie: string;
  125. referrer: string;
  126. constructor(html?: string | boolean, win?: any);
  127. get dir(): string;
  128. set dir(value: string);
  129. get location(): Location;
  130. set location(val: Location);
  131. get baseURI(): string;
  132. get URL(): string;
  133. get styleSheets(): Element[];
  134. get scripts(): Element[];
  135. get forms(): Element[];
  136. get images(): Element[];
  137. get scrollingElement(): MockElement;
  138. get documentElement(): MockElement;
  139. set documentElement(documentElement: MockElement);
  140. get head(): MockElement;
  141. set head(head: MockElement);
  142. get body(): MockElement;
  143. set body(body: MockElement);
  144. appendChild(newNode: MockElement): MockElement;
  145. createComment(data: string): MockComment;
  146. createAttribute(attrName: string): MockAttr;
  147. createAttributeNS(namespaceURI: string, attrName: string): MockAttr;
  148. createElement(tagName: string): any;
  149. createElementNS(namespaceURI: string, tagName: string): any;
  150. createTextNode(text: string): MockTextNode;
  151. createDocumentFragment(): MockDocumentFragment;
  152. createDocumentTypeNode(): MockDocumentTypeNode;
  153. getElementById(id: string): MockElement;
  154. getElementsByName(elmName: string): MockElement[];
  155. get title(): string;
  156. set title(value: string);
  157. }
  158. declare function createDocument(html?: string | boolean): Document;
  159. declare function createFragment(html?: string): DocumentFragment;
  160. declare function resetDocument(doc: Document): void;
  161. declare function getElementById(elm: MockElement, id: string): MockElement;
  162. declare function setOwnerDocument(elm: MockElement, ownerDocument: any): void;
  163. declare function createElement(ownerDocument: any, tagName: string): any;
  164. declare function createElementNS(ownerDocument: any, namespaceURI: string, tagName: string): any;
  165. declare class MockAnchorElement extends MockHTMLElement {
  166. constructor(ownerDocument: any);
  167. get href(): string;
  168. set href(value: string);
  169. get pathname(): string;
  170. }
  171. declare class MockButtonElement extends MockHTMLElement {
  172. constructor(ownerDocument: any);
  173. }
  174. declare class MockImageElement extends MockHTMLElement {
  175. constructor(ownerDocument: any);
  176. get draggable(): boolean;
  177. set draggable(value: boolean);
  178. get src(): string;
  179. set src(value: string);
  180. }
  181. declare class MockInputElement extends MockHTMLElement {
  182. constructor(ownerDocument: any);
  183. get list(): HTMLElement;
  184. }
  185. declare class MockFormElement extends MockHTMLElement {
  186. constructor(ownerDocument: any);
  187. }
  188. declare class MockLinkElement extends MockHTMLElement {
  189. constructor(ownerDocument: any);
  190. get href(): string;
  191. set href(value: string);
  192. }
  193. declare class MockMetaElement extends MockHTMLElement {
  194. constructor(ownerDocument: any);
  195. }
  196. declare class MockScriptElement extends MockHTMLElement {
  197. constructor(ownerDocument: any);
  198. get src(): string;
  199. set src(value: string);
  200. }
  201. declare class MockStyleElement extends MockHTMLElement {
  202. sheet: MockCSSStyleSheet;
  203. constructor(ownerDocument: any);
  204. get innerHTML(): string;
  205. set innerHTML(value: string);
  206. get innerText(): string;
  207. set innerText(value: string);
  208. get textContent(): string;
  209. set textContent(value: string);
  210. }
  211. declare class MockSVGElement extends MockElement {
  212. get ownerSVGElement(): SVGSVGElement;
  213. get viewportElement(): SVGElement;
  214. focus(): void;
  215. onunload(): void;
  216. get pathLength(): number;
  217. isPointInFill(_pt: DOMPoint): boolean;
  218. isPointInStroke(_pt: DOMPoint): boolean;
  219. getTotalLength(): number;
  220. }
  221. declare class MockBaseElement extends MockHTMLElement {
  222. constructor(ownerDocument: any);
  223. get href(): string;
  224. set href(value: string);
  225. }
  226. declare class MockTemplateElement extends MockHTMLElement {
  227. content: MockDocumentFragment;
  228. constructor(ownerDocument: any);
  229. get innerHTML(): string;
  230. set innerHTML(html: string);
  231. cloneNode(deep?: boolean): MockTemplateElement;
  232. }
  233. declare class MockTitleElement extends MockHTMLElement {
  234. constructor(ownerDocument: any);
  235. get text(): string;
  236. set text(value: string);
  237. }
  238. declare class MockCanvasElement extends MockHTMLElement {
  239. constructor(ownerDocument: any);
  240. getContext(): {
  241. fillRect(): void;
  242. clearRect(): void;
  243. getImageData: (_: number, __: number, w: number, h: number) => {
  244. data: any[];
  245. };
  246. putImageData(): void;
  247. createImageData: () => any[];
  248. setTransform(): void;
  249. drawImage(): void;
  250. save(): void;
  251. fillText(): void;
  252. restore(): void;
  253. beginPath(): void;
  254. moveTo(): void;
  255. lineTo(): void;
  256. closePath(): void;
  257. stroke(): void;
  258. translate(): void;
  259. scale(): void;
  260. rotate(): void;
  261. arc(): void;
  262. fill(): void;
  263. measureText(): {
  264. width: number;
  265. };
  266. transform(): void;
  267. rect(): void;
  268. clip(): void;
  269. };
  270. }
  271. declare class MockEvent {
  272. bubbles: boolean;
  273. cancelBubble: boolean;
  274. cancelable: boolean;
  275. composed: boolean;
  276. currentTarget: MockElement;
  277. defaultPrevented: boolean;
  278. srcElement: MockElement;
  279. target: MockElement;
  280. timeStamp: number;
  281. type: string;
  282. constructor(type: string, eventInitDict?: EventInit);
  283. preventDefault(): void;
  284. stopPropagation(): void;
  285. stopImmediatePropagation(): void;
  286. composedPath(): MockElement[];
  287. }
  288. declare class MockCustomEvent extends MockEvent {
  289. detail: any;
  290. constructor(type: string, customEventInitDic?: CustomEventInit);
  291. }
  292. declare class MockKeyboardEvent extends MockEvent {
  293. code: string;
  294. key: string;
  295. altKey: boolean;
  296. ctrlKey: boolean;
  297. metaKey: boolean;
  298. shiftKey: boolean;
  299. location: number;
  300. repeat: boolean;
  301. constructor(type: string, keyboardEventInitDic?: KeyboardEventInit);
  302. }
  303. declare class MockMouseEvent extends MockEvent {
  304. screenX: number;
  305. screenY: number;
  306. clientX: number;
  307. clientY: number;
  308. ctrlKey: boolean;
  309. shiftKey: boolean;
  310. altKey: boolean;
  311. metaKey: boolean;
  312. button: number;
  313. buttons: number;
  314. relatedTarget: EventTarget;
  315. constructor(type: string, mouseEventInitDic?: MouseEventInit);
  316. }
  317. declare class MockEventListener {
  318. type: string;
  319. handler: (ev?: any) => void;
  320. constructor(type: string, handler: any);
  321. }
  322. declare function addEventListener(elm: any, type: string, handler: any): void;
  323. declare function removeEventListener(elm: any, type: string, handler: any): void;
  324. declare function resetEventListeners(target: any): void;
  325. declare function dispatchEvent(currentTarget: any, ev: MockEvent): boolean;
  326. interface EventTarget {
  327. }
  328. declare function setupGlobal(gbl: any): any;
  329. declare function teardownGlobal(gbl: any): void;
  330. declare function patchWindow(winToBePatched: any): void;
  331. declare function addGlobalsToWindowPrototype(mockWinPrototype: any): void;
  332. declare class MockHeaders {
  333. constructor(init?: string[][] | Map<string, string> | any);
  334. append(key: string, value: string): void;
  335. delete(key: string): void;
  336. entries(): any;
  337. forEach(cb: (value: string, key: string) => void): void;
  338. get(key: string): string;
  339. has(key: string): boolean;
  340. keys(): {
  341. next(): {
  342. value: string;
  343. done: boolean;
  344. };
  345. [Symbol.iterator](): any;
  346. };
  347. set(key: string, value: string): void;
  348. values(): any;
  349. [Symbol.iterator](): any;
  350. }
  351. declare class MockHistory {
  352. get length(): number;
  353. back(): void;
  354. forward(): void;
  355. go(_value: number): void;
  356. pushState(_state: any, _title: string, _url: string): void;
  357. replaceState(_state: any, _title: string, _url: string): void;
  358. }
  359. declare class MockIntersectionObserver {
  360. constructor();
  361. disconnect(): void;
  362. observe(): void;
  363. takeRecords(): any[];
  364. unobserve(): void;
  365. }
  366. declare class MockLocation implements Location {
  367. ancestorOrigins: any;
  368. protocol: string;
  369. host: string;
  370. hostname: string;
  371. port: string;
  372. pathname: string;
  373. search: string;
  374. hash: string;
  375. username: string;
  376. password: string;
  377. origin: string;
  378. get href(): string;
  379. set href(value: string);
  380. assign(_url: string): void;
  381. reload(_forcedReload?: boolean): void;
  382. replace(_url: string): void;
  383. toString(): string;
  384. }
  385. declare class MockNavigator {
  386. appCodeName: string;
  387. appName: string;
  388. appVersion: string;
  389. platform: string;
  390. userAgent: string;
  391. }
  392. declare class MockNode {
  393. nodeName: string;
  394. nodeType: number;
  395. ownerDocument: any;
  396. parentNode: MockNode;
  397. childNodes: MockNode[];
  398. constructor(ownerDocument: any, nodeType: number, nodeName: string, nodeValue: string);
  399. appendChild(newNode: MockNode): MockNode;
  400. append(...items: (MockNode | string)[]): void;
  401. prepend(...items: (MockNode | string)[]): void;
  402. cloneNode(deep?: boolean): MockNode;
  403. compareDocumentPosition(_other: MockNode): number;
  404. get firstChild(): MockNode | null;
  405. insertBefore(newNode: MockNode, referenceNode: MockNode): MockNode;
  406. get isConnected(): boolean;
  407. isSameNode(node: any): boolean;
  408. get lastChild(): MockNode | null;
  409. get nextSibling(): MockNode | null;
  410. get nodeValue(): string;
  411. set nodeValue(value: string);
  412. get parentElement(): any;
  413. set parentElement(value: any);
  414. get previousSibling(): MockNode | null;
  415. contains(otherNode: MockNode): boolean;
  416. removeChild(childNode: MockNode): MockNode;
  417. remove(): void;
  418. replaceChild(newChild: MockNode, oldChild: MockNode): MockNode;
  419. get textContent(): string;
  420. set textContent(value: string);
  421. static ELEMENT_NODE: number;
  422. static TEXT_NODE: number;
  423. static PROCESSING_INSTRUCTION_NODE: number;
  424. static COMMENT_NODE: number;
  425. static DOCUMENT_NODE: number;
  426. static DOCUMENT_TYPE_NODE: number;
  427. static DOCUMENT_FRAGMENT_NODE: number;
  428. }
  429. declare class MockNodeList {
  430. childNodes: MockNode[];
  431. length: number;
  432. ownerDocument: any;
  433. constructor(ownerDocument: any, childNodes: MockNode[], length: number);
  434. }
  435. declare class MockElement extends MockNode {
  436. namespaceURI: string;
  437. constructor(ownerDocument: any, nodeName: string);
  438. addEventListener(type: string, handler: (ev?: any) => void): void;
  439. attachShadow(_opts: ShadowRootInit): any;
  440. get shadowRoot(): any;
  441. set shadowRoot(shadowRoot: any);
  442. get attributes(): MockAttributeMap;
  443. set attributes(attrs: MockAttributeMap);
  444. get children(): MockElement[];
  445. get childElementCount(): number;
  446. get className(): string;
  447. set className(value: string);
  448. get classList(): MockClassList;
  449. click(): void;
  450. cloneNode(_deep?: boolean): MockElement;
  451. closest(selector: string): this;
  452. get dataset(): any;
  453. get dir(): string;
  454. set dir(value: string);
  455. dispatchEvent(ev: MockEvent): boolean;
  456. get firstElementChild(): MockElement | null;
  457. getAttribute(attrName: string): any;
  458. getAttributeNS(namespaceURI: string, attrName: string): string;
  459. getBoundingClientRect(): {
  460. bottom: number;
  461. height: number;
  462. left: number;
  463. right: number;
  464. top: number;
  465. width: number;
  466. x: number;
  467. y: number;
  468. };
  469. getRootNode(opts?: {
  470. composed?: boolean;
  471. [key: string]: any;
  472. }): Node;
  473. get draggable(): boolean;
  474. set draggable(value: boolean);
  475. hasChildNodes(): boolean;
  476. get id(): string;
  477. set id(value: string);
  478. get innerHTML(): string;
  479. set innerHTML(html: string);
  480. get innerText(): string;
  481. set innerText(value: string);
  482. insertAdjacentElement(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', elm: MockHTMLElement): MockHTMLElement;
  483. insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', html: string): void;
  484. insertAdjacentText(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string): void;
  485. hasAttribute(attrName: string): boolean;
  486. hasAttributeNS(namespaceURI: string, name: string): boolean;
  487. get hidden(): boolean;
  488. set hidden(isHidden: boolean);
  489. get lang(): string;
  490. set lang(value: string);
  491. get lastElementChild(): MockElement | null;
  492. matches(selector: string): boolean;
  493. get nextElementSibling(): any;
  494. get outerHTML(): string;
  495. get previousElementSibling(): any;
  496. getElementsByClassName(classNames: string): MockElement[];
  497. getElementsByTagName(tagName: string): MockElement[];
  498. querySelector(selector: string): Element;
  499. querySelectorAll(selector: string): Element[];
  500. removeAttribute(attrName: string): void;
  501. removeAttributeNS(namespaceURI: string, attrName: string): void;
  502. removeEventListener(type: string, handler: any): void;
  503. setAttribute(attrName: string, value: any): void;
  504. setAttributeNS(namespaceURI: string, attrName: string, value: any): void;
  505. get style(): any;
  506. set style(val: any);
  507. get tabIndex(): number;
  508. set tabIndex(value: number);
  509. get tagName(): string;
  510. set tagName(value: string);
  511. get textContent(): string;
  512. set textContent(value: string);
  513. get title(): string;
  514. set title(value: string);
  515. onanimationstart(): void;
  516. onanimationend(): void;
  517. onanimationiteration(): void;
  518. onabort(): void;
  519. onauxclick(): void;
  520. onbeforecopy(): void;
  521. onbeforecut(): void;
  522. onbeforepaste(): void;
  523. onblur(): void;
  524. oncancel(): void;
  525. oncanplay(): void;
  526. oncanplaythrough(): void;
  527. onchange(): void;
  528. onclick(): void;
  529. onclose(): void;
  530. oncontextmenu(): void;
  531. oncopy(): void;
  532. oncuechange(): void;
  533. oncut(): void;
  534. ondblclick(): void;
  535. ondrag(): void;
  536. ondragend(): void;
  537. ondragenter(): void;
  538. ondragleave(): void;
  539. ondragover(): void;
  540. ondragstart(): void;
  541. ondrop(): void;
  542. ondurationchange(): void;
  543. onemptied(): void;
  544. onended(): void;
  545. onerror(): void;
  546. onfocus(): void;
  547. onfocusin(): void;
  548. onfocusout(): void;
  549. onformdata(): void;
  550. onfullscreenchange(): void;
  551. onfullscreenerror(): void;
  552. ongotpointercapture(): void;
  553. oninput(): void;
  554. oninvalid(): void;
  555. onkeydown(): void;
  556. onkeypress(): void;
  557. onkeyup(): void;
  558. onload(): void;
  559. onloadeddata(): void;
  560. onloadedmetadata(): void;
  561. onloadstart(): void;
  562. onlostpointercapture(): void;
  563. onmousedown(): void;
  564. onmouseenter(): void;
  565. onmouseleave(): void;
  566. onmousemove(): void;
  567. onmouseout(): void;
  568. onmouseover(): void;
  569. onmouseup(): void;
  570. onmousewheel(): void;
  571. onpaste(): void;
  572. onpause(): void;
  573. onplay(): void;
  574. onplaying(): void;
  575. onpointercancel(): void;
  576. onpointerdown(): void;
  577. onpointerenter(): void;
  578. onpointerleave(): void;
  579. onpointermove(): void;
  580. onpointerout(): void;
  581. onpointerover(): void;
  582. onpointerup(): void;
  583. onprogress(): void;
  584. onratechange(): void;
  585. onreset(): void;
  586. onresize(): void;
  587. onscroll(): void;
  588. onsearch(): void;
  589. onseeked(): void;
  590. onseeking(): void;
  591. onselect(): void;
  592. onselectstart(): void;
  593. onstalled(): void;
  594. onsubmit(): void;
  595. onsuspend(): void;
  596. ontimeupdate(): void;
  597. ontoggle(): void;
  598. onvolumechange(): void;
  599. onwaiting(): void;
  600. onwebkitfullscreenchange(): void;
  601. onwebkitfullscreenerror(): void;
  602. onwheel(): void;
  603. toString(opts?: SerializeNodeToHtmlOptions): string;
  604. }
  605. declare function resetElement(elm: MockElement): void;
  606. declare class MockHTMLElement extends MockElement {
  607. namespaceURI: string;
  608. constructor(ownerDocument: any, nodeName: string);
  609. get tagName(): string;
  610. set tagName(value: string);
  611. get attributes(): MockAttributeMap;
  612. set attributes(attrs: MockAttributeMap);
  613. }
  614. declare class MockTextNode extends MockNode {
  615. constructor(ownerDocument: any, text: string);
  616. cloneNode(_deep?: boolean): MockTextNode;
  617. get textContent(): string;
  618. set textContent(text: string);
  619. get data(): string;
  620. set data(text: string);
  621. get wholeText(): string;
  622. }
  623. declare function parseHtmlToDocument(html: string, ownerDocument?: MockDocument): any;
  624. declare function parseHtmlToFragment(html: string, ownerDocument?: MockDocument): any;
  625. declare function parseDocumentUtil(ownerDocument: any, html: string): any;
  626. declare function parseFragmentUtil(ownerDocument: any, html: string): any;
  627. declare type DOMParserSupportedType = 'text/html' | 'text/xml' | 'application/xml' | 'application/xhtml+xml' | 'image/svg+xml';
  628. declare class MockDOMParser {
  629. parseFromString(htmlToParse: string, mimeType: DOMParserSupportedType): MockDocument;
  630. }
  631. /**
  632. * https://developer.mozilla.org/en-US/docs/Web/API/Performance
  633. */
  634. declare class MockPerformance implements Performance {
  635. timeOrigin: number;
  636. constructor();
  637. addEventListener(): void;
  638. clearMarks(): void;
  639. clearMeasures(): void;
  640. clearResourceTimings(): void;
  641. dispatchEvent(): boolean;
  642. getEntries(): any;
  643. getEntriesByName(): any;
  644. getEntriesByType(): any;
  645. mark(): PerformanceMark;
  646. measure(): PerformanceMeasure;
  647. get navigation(): any;
  648. now(): number;
  649. get onresourcetimingbufferfull(): any;
  650. removeEventListener(): void;
  651. setResourceTimingBufferSize(): void;
  652. get timing(): any;
  653. toJSON(): void;
  654. }
  655. declare function resetPerformance(perf: Performance): void;
  656. declare type MockRequestInfo = MockRequest | string;
  657. interface MockRequestInit {
  658. body?: any;
  659. cache?: string;
  660. credentials?: string;
  661. headers?: any;
  662. integrity?: string;
  663. keepalive?: boolean;
  664. method?: string;
  665. mode?: string;
  666. redirect?: string;
  667. referrer?: string;
  668. referrerPolicy?: string;
  669. }
  670. declare class MockRequest {
  671. bodyUsed: boolean;
  672. cache: string;
  673. credentials: string;
  674. headers: MockHeaders;
  675. integrity: string;
  676. keepalive: boolean;
  677. mode: string;
  678. redirect: string;
  679. referrer: string;
  680. referrerPolicy: string;
  681. constructor(input?: any, init?: MockRequestInit);
  682. get url(): string;
  683. set url(value: string);
  684. get method(): string;
  685. set method(value: string);
  686. clone(): MockRequest;
  687. }
  688. interface MockResponseInit {
  689. headers?: any;
  690. ok?: boolean;
  691. status?: number;
  692. statusText?: string;
  693. type?: string;
  694. url?: string;
  695. }
  696. declare class MockResponse {
  697. headers: MockHeaders;
  698. ok: boolean;
  699. status: number;
  700. statusText: string;
  701. type: string;
  702. url: string;
  703. constructor(body?: string, init?: MockResponseInit);
  704. json(): Promise<any>;
  705. text(): Promise<string>;
  706. clone(): MockResponse;
  707. }
  708. declare function matches(selector: string, elm: MockElement): boolean;
  709. declare function selectOne(selector: string, elm: MockElement): Element;
  710. declare function selectAll(selector: string, elm: MockElement): Element[];
  711. declare function serializeNodeToHtml(elm: Node | MockNode, opts?: SerializeNodeToHtmlOptions): string;
  712. declare const NON_ESCAPABLE_CONTENT: Set<string>;
  713. declare const WHITESPACE_SENSITIVE: Set<string>;
  714. interface SerializeNodeToHtmlOptions {
  715. approximateLineWidth?: number;
  716. excludeTagContent?: string[];
  717. excludeTags?: string[];
  718. indentSpaces?: number;
  719. newLines?: boolean;
  720. outerHtml?: boolean;
  721. prettyHtml?: boolean;
  722. removeAttributeQuotes?: boolean;
  723. removeBooleanAttributeQuotes?: boolean;
  724. removeEmptyAttributes?: boolean;
  725. removeHtmlComments?: boolean;
  726. serializeShadowRoot?: boolean;
  727. }
  728. declare class MockStorage {
  729. key(_value: number): void;
  730. getItem(key: string): string;
  731. setItem(key: string, value: string): void;
  732. removeItem(key: string): void;
  733. clear(): void;
  734. }
  735. declare const nativeClearInterval: typeof clearInterval;
  736. declare const nativeClearTimeout: typeof clearTimeout;
  737. declare const nativeSetInterval: typeof setInterval;
  738. declare const nativeSetTimeout: typeof setTimeout;
  739. declare class MockWindow {
  740. URL: typeof URL;
  741. console: Console;
  742. customElements: CustomElementRegistry;
  743. document: Document;
  744. performance: Performance;
  745. devicePixelRatio: number;
  746. innerHeight: number;
  747. innerWidth: number;
  748. pageXOffset: number;
  749. pageYOffset: number;
  750. screen: Screen;
  751. screenLeft: number;
  752. screenTop: number;
  753. screenX: number;
  754. screenY: number;
  755. scrollX: number;
  756. scrollY: number;
  757. constructor(html?: string | boolean);
  758. addEventListener(type: string, handler: (ev?: any) => void): void;
  759. alert(msg: string): void;
  760. blur(): any;
  761. cancelAnimationFrame(id: any): void;
  762. cancelIdleCallback(id: any): void;
  763. get CharacterData(): any;
  764. set CharacterData(charDataCstr: any);
  765. clearInterval(id: any): void;
  766. clearTimeout(id: any): void;
  767. close(): void;
  768. confirm(): boolean;
  769. get CSS(): {
  770. supports: () => boolean;
  771. };
  772. get Document(): any;
  773. set Document(docCstr: any);
  774. get DocumentFragment(): any;
  775. set DocumentFragment(docFragCstr: any);
  776. get DocumentType(): any;
  777. set DocumentType(docTypeCstr: any);
  778. get DOMTokenList(): any;
  779. set DOMTokenList(domTokenListCstr: any);
  780. dispatchEvent(ev: MockEvent): boolean;
  781. get Element(): any;
  782. fetch(input: any, init?: any): any;
  783. focus(): any;
  784. getComputedStyle(_: any): any;
  785. get globalThis(): this;
  786. get history(): any;
  787. set history(hsty: any);
  788. get JSON(): JSON;
  789. get HTMLElement(): any;
  790. set HTMLElement(htmlElementCstr: any);
  791. get IntersectionObserver(): typeof MockIntersectionObserver;
  792. get localStorage(): MockStorage;
  793. set localStorage(locStorage: MockStorage);
  794. get location(): Location;
  795. set location(val: Location);
  796. matchMedia(): {
  797. matches: boolean;
  798. };
  799. get Node(): any;
  800. get NodeList(): any;
  801. get navigator(): any;
  802. set navigator(nav: any);
  803. get parent(): any;
  804. prompt(): string;
  805. open(): any;
  806. get origin(): string;
  807. removeEventListener(type: string, handler: any): void;
  808. requestAnimationFrame(callback: (timestamp: number) => void): number;
  809. requestIdleCallback(callback: (deadline: {
  810. didTimeout: boolean;
  811. timeRemaining: () => number;
  812. }) => void): number;
  813. scroll(_x?: number, _y?: number): void;
  814. scrollBy(_x?: number, _y?: number): void;
  815. scrollTo(_x?: number, _y?: number): void;
  816. get self(): this;
  817. get sessionStorage(): any;
  818. set sessionStorage(locStorage: any);
  819. setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  820. setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  821. get top(): this;
  822. get window(): this;
  823. onanimationstart(): void;
  824. onanimationend(): void;
  825. onanimationiteration(): void;
  826. onabort(): void;
  827. onauxclick(): void;
  828. onbeforecopy(): void;
  829. onbeforecut(): void;
  830. onbeforepaste(): void;
  831. onblur(): void;
  832. oncancel(): void;
  833. oncanplay(): void;
  834. oncanplaythrough(): void;
  835. onchange(): void;
  836. onclick(): void;
  837. onclose(): void;
  838. oncontextmenu(): void;
  839. oncopy(): void;
  840. oncuechange(): void;
  841. oncut(): void;
  842. ondblclick(): void;
  843. ondrag(): void;
  844. ondragend(): void;
  845. ondragenter(): void;
  846. ondragleave(): void;
  847. ondragover(): void;
  848. ondragstart(): void;
  849. ondrop(): void;
  850. ondurationchange(): void;
  851. onemptied(): void;
  852. onended(): void;
  853. onerror(): void;
  854. onfocus(): void;
  855. onfocusin(): void;
  856. onfocusout(): void;
  857. onformdata(): void;
  858. onfullscreenchange(): void;
  859. onfullscreenerror(): void;
  860. ongotpointercapture(): void;
  861. oninput(): void;
  862. oninvalid(): void;
  863. onkeydown(): void;
  864. onkeypress(): void;
  865. onkeyup(): void;
  866. onload(): void;
  867. onloadeddata(): void;
  868. onloadedmetadata(): void;
  869. onloadstart(): void;
  870. onlostpointercapture(): void;
  871. onmousedown(): void;
  872. onmouseenter(): void;
  873. onmouseleave(): void;
  874. onmousemove(): void;
  875. onmouseout(): void;
  876. onmouseover(): void;
  877. onmouseup(): void;
  878. onmousewheel(): void;
  879. onpaste(): void;
  880. onpause(): void;
  881. onplay(): void;
  882. onplaying(): void;
  883. onpointercancel(): void;
  884. onpointerdown(): void;
  885. onpointerenter(): void;
  886. onpointerleave(): void;
  887. onpointermove(): void;
  888. onpointerout(): void;
  889. onpointerover(): void;
  890. onpointerup(): void;
  891. onprogress(): void;
  892. onratechange(): void;
  893. onreset(): void;
  894. onresize(): void;
  895. onscroll(): void;
  896. onsearch(): void;
  897. onseeked(): void;
  898. onseeking(): void;
  899. onselect(): void;
  900. onselectstart(): void;
  901. onstalled(): void;
  902. onsubmit(): void;
  903. onsuspend(): void;
  904. ontimeupdate(): void;
  905. ontoggle(): void;
  906. onvolumechange(): void;
  907. onwaiting(): void;
  908. onwebkitfullscreenchange(): void;
  909. onwebkitfullscreenerror(): void;
  910. onwheel(): void;
  911. }
  912. declare function createWindow(html?: string | boolean): Window;
  913. declare function cloneWindow(srcWin: Window, opts?: {
  914. customElementProxy?: boolean;
  915. }): MockWindow;
  916. declare function cloneDocument(srcDoc: Document): Document;
  917. /**
  918. * Constrain setTimeout() to 1ms, but still async. Also
  919. * only allow setInterval() to fire once, also constrained to 1ms.
  920. */
  921. declare function constrainTimeouts(win: any): void;
  922. export { MockAttr, MockAttributeMap, MockComment, MockCustomEvent, MockDocument, MockElement, MockHTMLElement, MockHeaders, MockKeyboardEvent, MockMouseEvent, MockNode, MockRequest, MockRequestInfo, MockRequestInit, MockResponse, MockResponseInit, MockTextNode, MockWindow, NODE_TYPES, SerializeNodeToHtmlOptions, cloneAttributes, cloneDocument, cloneWindow, constrainTimeouts, createDocument, createFragment, parseHtmlToDocument, parseHtmlToFragment, patchWindow, resetDocument, serializeNodeToHtml, setupGlobal, teardownGlobal }