index.d.ts 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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 | null, 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 | null);
  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 | null, newValue: string | null): 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. content: string;
  195. constructor(ownerDocument: any);
  196. }
  197. declare class MockScriptElement extends MockHTMLElement {
  198. constructor(ownerDocument: any);
  199. get src(): string;
  200. set src(value: string);
  201. }
  202. declare class MockDOMMatrix {
  203. static fromMatrix(): MockDOMMatrix;
  204. a: number;
  205. b: number;
  206. c: number;
  207. d: number;
  208. e: number;
  209. f: number;
  210. m11: number;
  211. m12: number;
  212. m13: number;
  213. m14: number;
  214. m21: number;
  215. m22: number;
  216. m23: number;
  217. m24: number;
  218. m31: number;
  219. m32: number;
  220. m33: number;
  221. m34: number;
  222. m41: number;
  223. m42: number;
  224. m43: number;
  225. m44: number;
  226. is2D: boolean;
  227. isIdentity: boolean;
  228. inverse(): MockDOMMatrix;
  229. flipX(): MockDOMMatrix;
  230. flipY(): MockDOMMatrix;
  231. multiply(): MockDOMMatrix;
  232. rotate(): MockDOMMatrix;
  233. rotateAxisAngle(): MockDOMMatrix;
  234. rotateFromVector(): MockDOMMatrix;
  235. scale(): MockDOMMatrix;
  236. scaleNonUniform(): MockDOMMatrix;
  237. skewX(): MockDOMMatrix;
  238. skewY(): MockDOMMatrix;
  239. toJSON(): void;
  240. toString(): void;
  241. transformPoint(): MockDOMPoint;
  242. translate(): MockDOMMatrix;
  243. }
  244. declare class MockDOMPoint {
  245. w: number;
  246. x: number;
  247. y: number;
  248. z: number;
  249. toJSON(): void;
  250. matrixTransform(): MockDOMMatrix;
  251. }
  252. declare class MockSVGRect {
  253. height: number;
  254. width: number;
  255. x: number;
  256. y: number;
  257. }
  258. declare class MockStyleElement extends MockHTMLElement {
  259. sheet: MockCSSStyleSheet;
  260. constructor(ownerDocument: any);
  261. get innerHTML(): string;
  262. set innerHTML(value: string);
  263. get innerText(): string;
  264. set innerText(value: string);
  265. get textContent(): string;
  266. set textContent(value: string);
  267. }
  268. declare class MockSVGElement extends MockElement {
  269. get ownerSVGElement(): SVGSVGElement;
  270. get viewportElement(): SVGElement;
  271. onunload(): void;
  272. get pathLength(): number;
  273. isPointInFill(_pt: DOMPoint): boolean;
  274. isPointInStroke(_pt: DOMPoint): boolean;
  275. getTotalLength(): number;
  276. }
  277. declare class MockSVGGraphicsElement extends MockSVGElement {
  278. getBBox(_options?: {
  279. clipped: boolean;
  280. fill: boolean;
  281. markers: boolean;
  282. stroke: boolean;
  283. }): MockSVGRect;
  284. getCTM(): MockDOMMatrix;
  285. getScreenCTM(): MockDOMMatrix;
  286. }
  287. declare class MockSVGSVGElement extends MockSVGGraphicsElement {
  288. createSVGPoint(): MockDOMPoint;
  289. }
  290. declare class MockSVGTextContentElement extends MockSVGGraphicsElement {
  291. getComputedTextLength(): number;
  292. }
  293. declare class MockBaseElement extends MockHTMLElement {
  294. constructor(ownerDocument: any);
  295. get href(): string;
  296. set href(value: string);
  297. }
  298. declare class MockTemplateElement extends MockHTMLElement {
  299. content: MockDocumentFragment;
  300. constructor(ownerDocument: any);
  301. get innerHTML(): string;
  302. set innerHTML(html: string);
  303. cloneNode(deep?: boolean): MockTemplateElement;
  304. }
  305. declare class MockTitleElement extends MockHTMLElement {
  306. constructor(ownerDocument: any);
  307. get text(): string;
  308. set text(value: string);
  309. }
  310. declare class MockCanvasElement extends MockHTMLElement {
  311. constructor(ownerDocument: any);
  312. getContext(): {
  313. fillRect(): void;
  314. clearRect(): void;
  315. getImageData: (_: number, __: number, w: number, h: number) => {
  316. data: any[];
  317. };
  318. putImageData(): void;
  319. createImageData: () => any[];
  320. setTransform(): void;
  321. drawImage(): void;
  322. save(): void;
  323. fillText(): void;
  324. restore(): void;
  325. beginPath(): void;
  326. moveTo(): void;
  327. lineTo(): void;
  328. closePath(): void;
  329. stroke(): void;
  330. translate(): void;
  331. scale(): void;
  332. rotate(): void;
  333. arc(): void;
  334. fill(): void;
  335. measureText(): {
  336. width: number;
  337. };
  338. transform(): void;
  339. rect(): void;
  340. clip(): void;
  341. };
  342. }
  343. declare class MockEvent {
  344. bubbles: boolean;
  345. cancelBubble: boolean;
  346. cancelable: boolean;
  347. composed: boolean;
  348. currentTarget: MockElement;
  349. defaultPrevented: boolean;
  350. srcElement: MockElement;
  351. target: MockElement;
  352. timeStamp: number;
  353. type: string;
  354. constructor(type: string, eventInitDict?: EventInit);
  355. preventDefault(): void;
  356. stopPropagation(): void;
  357. stopImmediatePropagation(): void;
  358. composedPath(): MockElement[];
  359. }
  360. declare class MockCustomEvent extends MockEvent {
  361. detail: any;
  362. constructor(type: string, customEventInitDic?: CustomEventInit);
  363. }
  364. declare class MockKeyboardEvent extends MockEvent {
  365. code: string;
  366. key: string;
  367. altKey: boolean;
  368. ctrlKey: boolean;
  369. metaKey: boolean;
  370. shiftKey: boolean;
  371. location: number;
  372. repeat: boolean;
  373. constructor(type: string, keyboardEventInitDic?: KeyboardEventInit);
  374. }
  375. declare class MockMouseEvent extends MockEvent {
  376. screenX: number;
  377. screenY: number;
  378. clientX: number;
  379. clientY: number;
  380. ctrlKey: boolean;
  381. shiftKey: boolean;
  382. altKey: boolean;
  383. metaKey: boolean;
  384. button: number;
  385. buttons: number;
  386. relatedTarget: EventTarget;
  387. constructor(type: string, mouseEventInitDic?: MouseEventInit);
  388. }
  389. declare class MockUIEvent extends MockEvent {
  390. detail: number | null;
  391. view: MockWindow | null;
  392. constructor(type: string, uiEventInitDic?: UIEventInit);
  393. }
  394. declare class MockFocusEvent extends MockUIEvent {
  395. relatedTarget: EventTarget | null;
  396. constructor(type: 'blur' | 'focus', focusEventInitDic?: FocusEventInit);
  397. }
  398. declare class MockEventListener {
  399. type: string;
  400. handler: (ev?: any) => void;
  401. constructor(type: string, handler: any);
  402. }
  403. declare function addEventListener(elm: any, type: string, handler: any): void;
  404. declare function removeEventListener(elm: any, type: string, handler: any): void;
  405. declare function resetEventListeners(target: any): void;
  406. declare function dispatchEvent(currentTarget: any, ev: MockEvent): boolean;
  407. interface EventTarget {
  408. }
  409. declare function setupGlobal(gbl: any): any;
  410. declare function teardownGlobal(gbl: any): void;
  411. declare function patchWindow(winToBePatched: any): void;
  412. declare function addGlobalsToWindowPrototype(mockWinPrototype: any): void;
  413. declare class MockHeaders {
  414. constructor(init?: string[][] | Map<string, string> | any);
  415. append(key: string, value: string): void;
  416. delete(key: string): void;
  417. entries(): any;
  418. forEach(cb: (value: string, key: string) => void): void;
  419. get(key: string): string;
  420. has(key: string): boolean;
  421. keys(): {
  422. next(): {
  423. value: string;
  424. done: boolean;
  425. };
  426. [Symbol.iterator](): any;
  427. };
  428. set(key: string, value: string): void;
  429. values(): any;
  430. [Symbol.iterator](): any;
  431. }
  432. declare class MockHistory {
  433. get length(): number;
  434. back(): void;
  435. forward(): void;
  436. go(_value: number): void;
  437. pushState(_state: any, _title: string, _url: string): void;
  438. replaceState(_state: any, _title: string, _url: string): void;
  439. }
  440. declare class MockIntersectionObserver {
  441. constructor();
  442. disconnect(): void;
  443. observe(): void;
  444. takeRecords(): any[];
  445. unobserve(): void;
  446. }
  447. declare class MockLocation implements Location {
  448. ancestorOrigins: any;
  449. protocol: string;
  450. host: string;
  451. hostname: string;
  452. port: string;
  453. pathname: string;
  454. search: string;
  455. hash: string;
  456. username: string;
  457. password: string;
  458. origin: string;
  459. get href(): string;
  460. set href(value: string);
  461. assign(_url: string): void;
  462. reload(_forcedReload?: boolean): void;
  463. replace(_url: string): void;
  464. toString(): string;
  465. }
  466. declare class MockNavigator {
  467. appCodeName: string;
  468. appName: string;
  469. appVersion: string;
  470. platform: string;
  471. userAgent: string;
  472. }
  473. declare class MockNode {
  474. nodeName: string | null;
  475. nodeType: number;
  476. ownerDocument: any;
  477. parentNode: MockNode | null;
  478. childNodes: MockNode[];
  479. constructor(ownerDocument: any, nodeType: number, nodeName: string | null, nodeValue: string | null);
  480. appendChild(newNode: MockNode): MockNode;
  481. append(...items: (MockNode | string)[]): void;
  482. prepend(...items: (MockNode | string)[]): void;
  483. cloneNode(deep?: boolean): MockNode;
  484. compareDocumentPosition(_other: MockNode): number;
  485. get firstChild(): MockNode | null;
  486. insertBefore(newNode: MockNode, referenceNode: MockNode): MockNode;
  487. get isConnected(): boolean;
  488. isSameNode(node: any): boolean;
  489. get lastChild(): MockNode | null;
  490. get nextSibling(): MockNode | null;
  491. get nodeValue(): string;
  492. set nodeValue(value: string);
  493. get parentElement(): any;
  494. set parentElement(value: any);
  495. get previousSibling(): MockNode | null;
  496. contains(otherNode: MockNode): boolean;
  497. removeChild(childNode: MockNode): MockNode;
  498. remove(): void;
  499. replaceChild(newChild: MockNode, oldChild: MockNode): MockNode;
  500. get textContent(): string;
  501. set textContent(value: string);
  502. static ELEMENT_NODE: number;
  503. static TEXT_NODE: number;
  504. static PROCESSING_INSTRUCTION_NODE: number;
  505. static COMMENT_NODE: number;
  506. static DOCUMENT_NODE: number;
  507. static DOCUMENT_TYPE_NODE: number;
  508. static DOCUMENT_FRAGMENT_NODE: number;
  509. }
  510. declare class MockNodeList {
  511. childNodes: MockNode[];
  512. length: number;
  513. ownerDocument: any;
  514. constructor(ownerDocument: any, childNodes: MockNode[], length: number);
  515. }
  516. declare class MockElement extends MockNode {
  517. namespaceURI: string | null;
  518. constructor(ownerDocument: any, nodeName: string | null);
  519. addEventListener(type: string, handler: (ev?: any) => void): void;
  520. attachShadow(_opts: ShadowRootInit): any;
  521. blur(): void;
  522. get shadowRoot(): any;
  523. set shadowRoot(shadowRoot: any);
  524. get attributes(): MockAttributeMap;
  525. set attributes(attrs: MockAttributeMap);
  526. get children(): MockElement[];
  527. get childElementCount(): number;
  528. get className(): string;
  529. set className(value: string);
  530. get classList(): MockClassList;
  531. click(): void;
  532. cloneNode(_deep?: boolean): MockElement;
  533. closest(selector: string): this;
  534. get dataset(): any;
  535. get dir(): string;
  536. set dir(value: string);
  537. dispatchEvent(ev: MockEvent): boolean;
  538. get firstElementChild(): MockElement | null;
  539. focus(_options?: {
  540. preventScroll?: boolean;
  541. }): void;
  542. getAttribute(attrName: string): any;
  543. getAttributeNS(namespaceURI: string | null, attrName: string): string;
  544. getBoundingClientRect(): {
  545. bottom: number;
  546. height: number;
  547. left: number;
  548. right: number;
  549. top: number;
  550. width: number;
  551. x: number;
  552. y: number;
  553. };
  554. getRootNode(opts?: {
  555. composed?: boolean;
  556. [key: string]: any;
  557. }): Node;
  558. get draggable(): boolean;
  559. set draggable(value: boolean);
  560. hasChildNodes(): boolean;
  561. get id(): string;
  562. set id(value: string);
  563. get innerHTML(): string;
  564. set innerHTML(html: string);
  565. get innerText(): string;
  566. set innerText(value: string);
  567. insertAdjacentElement(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', elm: MockHTMLElement): MockHTMLElement;
  568. insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', html: string): void;
  569. insertAdjacentText(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string): void;
  570. hasAttribute(attrName: string): boolean;
  571. hasAttributeNS(namespaceURI: string | null, name: string): boolean;
  572. get hidden(): boolean;
  573. set hidden(isHidden: boolean);
  574. get lang(): string;
  575. set lang(value: string);
  576. get lastElementChild(): MockElement | null;
  577. matches(selector: string): boolean;
  578. get nextElementSibling(): any;
  579. get outerHTML(): string;
  580. get previousElementSibling(): any;
  581. getElementsByClassName(classNames: string): MockElement[];
  582. getElementsByTagName(tagName: string): MockElement[];
  583. querySelector(selector: string): Element;
  584. querySelectorAll(selector: string): Element[];
  585. removeAttribute(attrName: string): void;
  586. removeAttributeNS(namespaceURI: string | null, attrName: string): void;
  587. removeEventListener(type: string, handler: any): void;
  588. setAttribute(attrName: string, value: any): void;
  589. setAttributeNS(namespaceURI: string | null, attrName: string, value: any): void;
  590. get style(): any;
  591. set style(val: any);
  592. get tabIndex(): number;
  593. set tabIndex(value: number);
  594. get tagName(): string;
  595. set tagName(value: string);
  596. get textContent(): string;
  597. set textContent(value: string);
  598. get title(): string;
  599. set title(value: string);
  600. animate(): void;
  601. onanimationstart(): void;
  602. onanimationend(): void;
  603. onanimationiteration(): void;
  604. onabort(): void;
  605. onauxclick(): void;
  606. onbeforecopy(): void;
  607. onbeforecut(): void;
  608. onbeforepaste(): void;
  609. onblur(): void;
  610. oncancel(): void;
  611. oncanplay(): void;
  612. oncanplaythrough(): void;
  613. onchange(): void;
  614. onclick(): void;
  615. onclose(): void;
  616. oncontextmenu(): void;
  617. oncopy(): void;
  618. oncuechange(): void;
  619. oncut(): void;
  620. ondblclick(): void;
  621. ondrag(): void;
  622. ondragend(): void;
  623. ondragenter(): void;
  624. ondragleave(): void;
  625. ondragover(): void;
  626. ondragstart(): void;
  627. ondrop(): void;
  628. ondurationchange(): void;
  629. onemptied(): void;
  630. onended(): void;
  631. onerror(): void;
  632. onfocus(): void;
  633. onfocusin(): void;
  634. onfocusout(): void;
  635. onformdata(): void;
  636. onfullscreenchange(): void;
  637. onfullscreenerror(): void;
  638. ongotpointercapture(): void;
  639. oninput(): void;
  640. oninvalid(): void;
  641. onkeydown(): void;
  642. onkeypress(): void;
  643. onkeyup(): void;
  644. onload(): void;
  645. onloadeddata(): void;
  646. onloadedmetadata(): void;
  647. onloadstart(): void;
  648. onlostpointercapture(): void;
  649. onmousedown(): void;
  650. onmouseenter(): void;
  651. onmouseleave(): void;
  652. onmousemove(): void;
  653. onmouseout(): void;
  654. onmouseover(): void;
  655. onmouseup(): void;
  656. onmousewheel(): void;
  657. onpaste(): void;
  658. onpause(): void;
  659. onplay(): void;
  660. onplaying(): void;
  661. onpointercancel(): void;
  662. onpointerdown(): void;
  663. onpointerenter(): void;
  664. onpointerleave(): void;
  665. onpointermove(): void;
  666. onpointerout(): void;
  667. onpointerover(): void;
  668. onpointerup(): void;
  669. onprogress(): void;
  670. onratechange(): void;
  671. onreset(): void;
  672. onresize(): void;
  673. onscroll(): void;
  674. onsearch(): void;
  675. onseeked(): void;
  676. onseeking(): void;
  677. onselect(): void;
  678. onselectstart(): void;
  679. onstalled(): void;
  680. onsubmit(): void;
  681. onsuspend(): void;
  682. ontimeupdate(): void;
  683. ontoggle(): void;
  684. onvolumechange(): void;
  685. onwaiting(): void;
  686. onwebkitfullscreenchange(): void;
  687. onwebkitfullscreenerror(): void;
  688. onwheel(): void;
  689. requestFullscreen(): void;
  690. scrollBy(): void;
  691. scrollTo(): void;
  692. scrollIntoView(): void;
  693. toString(opts?: SerializeNodeToHtmlOptions): string;
  694. }
  695. declare function resetElement(elm: MockElement): void;
  696. declare class MockHTMLElement extends MockElement {
  697. namespaceURI: string;
  698. constructor(ownerDocument: any, nodeName: string);
  699. get tagName(): string;
  700. set tagName(value: string);
  701. get attributes(): MockAttributeMap;
  702. set attributes(attrs: MockAttributeMap);
  703. }
  704. declare class MockTextNode extends MockNode {
  705. constructor(ownerDocument: any, text: string);
  706. cloneNode(_deep?: boolean): MockTextNode;
  707. get textContent(): string;
  708. set textContent(text: string);
  709. get data(): string;
  710. set data(text: string);
  711. get wholeText(): string;
  712. }
  713. declare function parseHtmlToDocument(html: string, ownerDocument?: MockDocument): any;
  714. declare function parseHtmlToFragment(html: string, ownerDocument?: MockDocument): any;
  715. declare function parseDocumentUtil(ownerDocument: any, html: string): any;
  716. declare function parseFragmentUtil(ownerDocument: any, html: string): any;
  717. declare type DOMParserSupportedType = 'text/html' | 'text/xml' | 'application/xml' | 'application/xhtml+xml' | 'image/svg+xml';
  718. declare class MockDOMParser {
  719. parseFromString(htmlToParse: string, mimeType: DOMParserSupportedType): MockDocument;
  720. }
  721. /**
  722. * https://developer.mozilla.org/en-US/docs/Web/API/Performance
  723. */
  724. declare class MockPerformance implements Performance {
  725. timeOrigin: number;
  726. eventCounts: EventCounts;
  727. constructor();
  728. addEventListener(): void;
  729. clearMarks(): void;
  730. clearMeasures(): void;
  731. clearResourceTimings(): void;
  732. dispatchEvent(): boolean;
  733. getEntries(): any;
  734. getEntriesByName(): any;
  735. getEntriesByType(): any;
  736. mark(): PerformanceMark;
  737. measure(): PerformanceMeasure;
  738. get navigation(): any;
  739. now(): number;
  740. get onresourcetimingbufferfull(): any;
  741. removeEventListener(): void;
  742. setResourceTimingBufferSize(): void;
  743. get timing(): any;
  744. toJSON(): void;
  745. }
  746. declare function resetPerformance(perf: Performance): void;
  747. declare type MockRequestInfo = MockRequest | string;
  748. interface MockRequestInit {
  749. body?: any;
  750. cache?: string;
  751. credentials?: string;
  752. headers?: any;
  753. integrity?: string;
  754. keepalive?: boolean;
  755. method?: string;
  756. mode?: string;
  757. redirect?: string;
  758. referrer?: string;
  759. referrerPolicy?: string;
  760. }
  761. declare class MockRequest {
  762. bodyUsed: boolean;
  763. cache: string;
  764. credentials: string;
  765. headers: MockHeaders;
  766. integrity: string;
  767. keepalive: boolean;
  768. mode: string;
  769. redirect: string;
  770. referrer: string;
  771. referrerPolicy: string;
  772. constructor(input?: any, init?: MockRequestInit);
  773. get url(): string;
  774. set url(value: string);
  775. get method(): string;
  776. set method(value: string);
  777. clone(): MockRequest;
  778. }
  779. interface MockResponseInit {
  780. headers?: any;
  781. ok?: boolean;
  782. status?: number;
  783. statusText?: string;
  784. type?: string;
  785. url?: string;
  786. }
  787. declare class MockResponse {
  788. headers: MockHeaders;
  789. ok: boolean;
  790. status: number;
  791. statusText: string;
  792. type: string;
  793. url: string;
  794. constructor(body?: string, init?: MockResponseInit);
  795. json(): Promise<any>;
  796. text(): Promise<string>;
  797. clone(): MockResponse;
  798. }
  799. declare function matches(selector: string, elm: MockElement): boolean;
  800. declare function selectOne(selector: string, elm: MockElement): Element;
  801. declare function selectAll(selector: string, elm: MockElement): Element[];
  802. declare function serializeNodeToHtml(elm: Node | MockNode, opts?: SerializeNodeToHtmlOptions): string;
  803. declare const NON_ESCAPABLE_CONTENT: Set<string>;
  804. declare const WHITESPACE_SENSITIVE: Set<string>;
  805. interface SerializeNodeToHtmlOptions {
  806. approximateLineWidth?: number;
  807. excludeTagContent?: string[];
  808. excludeTags?: string[];
  809. indentSpaces?: number;
  810. newLines?: boolean;
  811. outerHtml?: boolean;
  812. prettyHtml?: boolean;
  813. removeAttributeQuotes?: boolean;
  814. removeBooleanAttributeQuotes?: boolean;
  815. removeEmptyAttributes?: boolean;
  816. removeHtmlComments?: boolean;
  817. serializeShadowRoot?: boolean;
  818. }
  819. declare class MockStorage {
  820. key(_value: number): void;
  821. getItem(key: string): string;
  822. setItem(key: string, value: string): void;
  823. removeItem(key: string): void;
  824. clear(): void;
  825. }
  826. declare const nativeClearInterval: typeof clearInterval;
  827. declare const nativeClearTimeout: typeof clearTimeout;
  828. declare const nativeSetInterval: typeof setInterval;
  829. declare const nativeSetTimeout: typeof setTimeout;
  830. declare class MockWindow {
  831. URL: typeof URL;
  832. console: Console;
  833. customElements: CustomElementRegistry;
  834. document: Document;
  835. performance: Performance;
  836. devicePixelRatio: number;
  837. innerHeight: number;
  838. innerWidth: number;
  839. pageXOffset: number;
  840. pageYOffset: number;
  841. screen: Screen;
  842. screenLeft: number;
  843. screenTop: number;
  844. screenX: number;
  845. screenY: number;
  846. scrollX: number;
  847. scrollY: number;
  848. CustomEvent: typeof MockCustomEvent;
  849. Event: typeof MockEvent;
  850. Headers: typeof MockHeaders;
  851. FocusEvent: typeof MockFocusEvent;
  852. KeyboardEvent: typeof MockKeyboardEvent;
  853. MouseEvent: typeof MockMouseEvent;
  854. constructor(html?: string | boolean);
  855. addEventListener(type: string, handler: (ev?: any) => void): void;
  856. alert(msg: string): void;
  857. blur(): any;
  858. cancelAnimationFrame(id: any): void;
  859. cancelIdleCallback(id: any): void;
  860. get CharacterData(): any;
  861. set CharacterData(charDataCstr: any);
  862. clearInterval(id: any): void;
  863. clearTimeout(id: any): void;
  864. close(): void;
  865. confirm(): boolean;
  866. get CSS(): {
  867. supports: () => boolean;
  868. };
  869. get Document(): any;
  870. set Document(docCstr: any);
  871. get DocumentFragment(): any;
  872. set DocumentFragment(docFragCstr: any);
  873. get DocumentType(): any;
  874. set DocumentType(docTypeCstr: any);
  875. get DOMTokenList(): any;
  876. set DOMTokenList(domTokenListCstr: any);
  877. dispatchEvent(ev: MockEvent): boolean;
  878. get Element(): any;
  879. fetch(input: any, init?: any): any;
  880. focus(): any;
  881. getComputedStyle(_: any): any;
  882. get globalThis(): this;
  883. get history(): any;
  884. set history(hsty: any);
  885. get JSON(): JSON;
  886. get HTMLElement(): any;
  887. set HTMLElement(htmlElementCstr: any);
  888. get IntersectionObserver(): typeof MockIntersectionObserver;
  889. get localStorage(): MockStorage;
  890. set localStorage(locStorage: MockStorage);
  891. get location(): MockLocation;
  892. set location(val: Location | string);
  893. matchMedia(): {
  894. matches: boolean;
  895. };
  896. get Node(): any;
  897. get NodeList(): any;
  898. get navigator(): any;
  899. set navigator(nav: any);
  900. get parent(): any;
  901. prompt(): string;
  902. open(): any;
  903. get origin(): string;
  904. removeEventListener(type: string, handler: any): void;
  905. requestAnimationFrame(callback: (timestamp: number) => void): number;
  906. requestIdleCallback(callback: (deadline: {
  907. didTimeout: boolean;
  908. timeRemaining: () => number;
  909. }) => void): number;
  910. scroll(_x?: number, _y?: number): void;
  911. scrollBy(_x?: number, _y?: number): void;
  912. scrollTo(_x?: number, _y?: number): void;
  913. get self(): this;
  914. get sessionStorage(): any;
  915. set sessionStorage(locStorage: any);
  916. setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  917. setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  918. get top(): this;
  919. get window(): this;
  920. onanimationstart(): void;
  921. onanimationend(): void;
  922. onanimationiteration(): void;
  923. onabort(): void;
  924. onauxclick(): void;
  925. onbeforecopy(): void;
  926. onbeforecut(): void;
  927. onbeforepaste(): void;
  928. onblur(): void;
  929. oncancel(): void;
  930. oncanplay(): void;
  931. oncanplaythrough(): void;
  932. onchange(): void;
  933. onclick(): void;
  934. onclose(): void;
  935. oncontextmenu(): void;
  936. oncopy(): void;
  937. oncuechange(): void;
  938. oncut(): void;
  939. ondblclick(): void;
  940. ondrag(): void;
  941. ondragend(): void;
  942. ondragenter(): void;
  943. ondragleave(): void;
  944. ondragover(): void;
  945. ondragstart(): void;
  946. ondrop(): void;
  947. ondurationchange(): void;
  948. onemptied(): void;
  949. onended(): void;
  950. onerror(): void;
  951. onfocus(): void;
  952. onfocusin(): void;
  953. onfocusout(): void;
  954. onformdata(): void;
  955. onfullscreenchange(): void;
  956. onfullscreenerror(): void;
  957. ongotpointercapture(): void;
  958. oninput(): void;
  959. oninvalid(): void;
  960. onkeydown(): void;
  961. onkeypress(): void;
  962. onkeyup(): void;
  963. onload(): void;
  964. onloadeddata(): void;
  965. onloadedmetadata(): void;
  966. onloadstart(): void;
  967. onlostpointercapture(): void;
  968. onmousedown(): void;
  969. onmouseenter(): void;
  970. onmouseleave(): void;
  971. onmousemove(): void;
  972. onmouseout(): void;
  973. onmouseover(): void;
  974. onmouseup(): void;
  975. onmousewheel(): void;
  976. onpaste(): void;
  977. onpause(): void;
  978. onplay(): void;
  979. onplaying(): void;
  980. onpointercancel(): void;
  981. onpointerdown(): void;
  982. onpointerenter(): void;
  983. onpointerleave(): void;
  984. onpointermove(): void;
  985. onpointerout(): void;
  986. onpointerover(): void;
  987. onpointerup(): void;
  988. onprogress(): void;
  989. onratechange(): void;
  990. onreset(): void;
  991. onresize(): void;
  992. onscroll(): void;
  993. onsearch(): void;
  994. onseeked(): void;
  995. onseeking(): void;
  996. onselect(): void;
  997. onselectstart(): void;
  998. onstalled(): void;
  999. onsubmit(): void;
  1000. onsuspend(): void;
  1001. ontimeupdate(): void;
  1002. ontoggle(): void;
  1003. onvolumechange(): void;
  1004. onwaiting(): void;
  1005. onwebkitfullscreenchange(): void;
  1006. onwebkitfullscreenerror(): void;
  1007. onwheel(): void;
  1008. }
  1009. declare function createWindow(html?: string | boolean): Window;
  1010. declare function cloneWindow(srcWin: Window, opts?: {
  1011. customElementProxy?: boolean;
  1012. }): MockWindow;
  1013. declare function cloneDocument(srcDoc: Document): Document;
  1014. /**
  1015. * Constrain setTimeout() to 1ms, but still async. Also
  1016. * only allow setInterval() to fire once, also constrained to 1ms.
  1017. * @param win the mock window instance to update
  1018. */
  1019. declare function constrainTimeouts(win: any): void;
  1020. 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 }