HTMLMediaElement.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  1. "use strict";
  2. const conversions = require("webidl-conversions");
  3. const utils = require("./utils.js");
  4. const TextTrackKind = require("./TextTrackKind.js");
  5. const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
  6. const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
  7. require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
  8. const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
  9. require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
  10. const implSymbol = utils.implSymbol;
  11. const ctorRegistrySymbol = utils.ctorRegistrySymbol;
  12. const HTMLElement = require("./HTMLElement.js");
  13. const interfaceName = "HTMLMediaElement";
  14. exports.is = value => {
  15. return utils.isObject(value) && Object.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
  16. };
  17. exports.isImpl = value => {
  18. return utils.isObject(value) && value instanceof Impl.implementation;
  19. };
  20. exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
  21. if (exports.is(value)) {
  22. return utils.implForWrapper(value);
  23. }
  24. throw new globalObject.TypeError(`${context} is not of type 'HTMLMediaElement'.`);
  25. };
  26. function makeWrapper(globalObject, newTarget) {
  27. let proto;
  28. if (newTarget !== undefined) {
  29. proto = newTarget.prototype;
  30. }
  31. if (!utils.isObject(proto)) {
  32. proto = globalObject[ctorRegistrySymbol]["HTMLMediaElement"].prototype;
  33. }
  34. return Object.create(proto);
  35. }
  36. exports.create = (globalObject, constructorArgs, privateData) => {
  37. const wrapper = makeWrapper(globalObject);
  38. return exports.setup(wrapper, globalObject, constructorArgs, privateData);
  39. };
  40. exports.createImpl = (globalObject, constructorArgs, privateData) => {
  41. const wrapper = exports.create(globalObject, constructorArgs, privateData);
  42. return utils.implForWrapper(wrapper);
  43. };
  44. exports._internalSetup = (wrapper, globalObject) => {
  45. HTMLElement._internalSetup(wrapper, globalObject);
  46. };
  47. exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
  48. privateData.wrapper = wrapper;
  49. exports._internalSetup(wrapper, globalObject);
  50. Object.defineProperty(wrapper, implSymbol, {
  51. value: new Impl.implementation(globalObject, constructorArgs, privateData),
  52. configurable: true
  53. });
  54. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  55. if (Impl.init) {
  56. Impl.init(wrapper[implSymbol]);
  57. }
  58. return wrapper;
  59. };
  60. exports.new = (globalObject, newTarget) => {
  61. const wrapper = makeWrapper(globalObject, newTarget);
  62. exports._internalSetup(wrapper, globalObject);
  63. Object.defineProperty(wrapper, implSymbol, {
  64. value: Object.create(Impl.implementation.prototype),
  65. configurable: true
  66. });
  67. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  68. if (Impl.init) {
  69. Impl.init(wrapper[implSymbol]);
  70. }
  71. return wrapper[implSymbol];
  72. };
  73. const exposed = new Set(["Window"]);
  74. exports.install = (globalObject, globalNames) => {
  75. if (!globalNames.some(globalName => exposed.has(globalName))) {
  76. return;
  77. }
  78. const ctorRegistry = utils.initCtorRegistry(globalObject);
  79. class HTMLMediaElement extends globalObject.HTMLElement {
  80. constructor() {
  81. throw new globalObject.TypeError("Illegal constructor");
  82. }
  83. load() {
  84. const esValue = this !== null && this !== undefined ? this : globalObject;
  85. if (!exports.is(esValue)) {
  86. throw new globalObject.TypeError(
  87. "'load' called on an object that is not a valid instance of HTMLMediaElement."
  88. );
  89. }
  90. return esValue[implSymbol].load();
  91. }
  92. canPlayType(type) {
  93. const esValue = this !== null && this !== undefined ? this : globalObject;
  94. if (!exports.is(esValue)) {
  95. throw new globalObject.TypeError(
  96. "'canPlayType' called on an object that is not a valid instance of HTMLMediaElement."
  97. );
  98. }
  99. if (arguments.length < 1) {
  100. throw new globalObject.TypeError(
  101. `Failed to execute 'canPlayType' on 'HTMLMediaElement': 1 argument required, but only ${arguments.length} present.`
  102. );
  103. }
  104. const args = [];
  105. {
  106. let curArg = arguments[0];
  107. curArg = conversions["DOMString"](curArg, {
  108. context: "Failed to execute 'canPlayType' on 'HTMLMediaElement': parameter 1",
  109. globals: globalObject
  110. });
  111. args.push(curArg);
  112. }
  113. return utils.tryWrapperForImpl(esValue[implSymbol].canPlayType(...args));
  114. }
  115. play() {
  116. try {
  117. const esValue = this !== null && this !== undefined ? this : globalObject;
  118. if (!exports.is(esValue)) {
  119. throw new globalObject.TypeError(
  120. "'play' called on an object that is not a valid instance of HTMLMediaElement."
  121. );
  122. }
  123. return utils.tryWrapperForImpl(esValue[implSymbol].play());
  124. } catch (e) {
  125. return globalObject.Promise.reject(e);
  126. }
  127. }
  128. pause() {
  129. const esValue = this !== null && this !== undefined ? this : globalObject;
  130. if (!exports.is(esValue)) {
  131. throw new globalObject.TypeError(
  132. "'pause' called on an object that is not a valid instance of HTMLMediaElement."
  133. );
  134. }
  135. return esValue[implSymbol].pause();
  136. }
  137. addTextTrack(kind) {
  138. const esValue = this !== null && this !== undefined ? this : globalObject;
  139. if (!exports.is(esValue)) {
  140. throw new globalObject.TypeError(
  141. "'addTextTrack' called on an object that is not a valid instance of HTMLMediaElement."
  142. );
  143. }
  144. if (arguments.length < 1) {
  145. throw new globalObject.TypeError(
  146. `Failed to execute 'addTextTrack' on 'HTMLMediaElement': 1 argument required, but only ${arguments.length} present.`
  147. );
  148. }
  149. const args = [];
  150. {
  151. let curArg = arguments[0];
  152. curArg = TextTrackKind.convert(globalObject, curArg, {
  153. context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 1"
  154. });
  155. args.push(curArg);
  156. }
  157. {
  158. let curArg = arguments[1];
  159. if (curArg !== undefined) {
  160. curArg = conversions["DOMString"](curArg, {
  161. context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 2",
  162. globals: globalObject
  163. });
  164. } else {
  165. curArg = "";
  166. }
  167. args.push(curArg);
  168. }
  169. {
  170. let curArg = arguments[2];
  171. if (curArg !== undefined) {
  172. curArg = conversions["DOMString"](curArg, {
  173. context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 3",
  174. globals: globalObject
  175. });
  176. } else {
  177. curArg = "";
  178. }
  179. args.push(curArg);
  180. }
  181. return utils.tryWrapperForImpl(esValue[implSymbol].addTextTrack(...args));
  182. }
  183. get src() {
  184. const esValue = this !== null && this !== undefined ? this : globalObject;
  185. if (!exports.is(esValue)) {
  186. throw new globalObject.TypeError(
  187. "'get src' called on an object that is not a valid instance of HTMLMediaElement."
  188. );
  189. }
  190. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  191. try {
  192. const impl = esValue[implSymbol];
  193. const value = impl._reflectGetTheContentAttribute("src");
  194. if (value === null) {
  195. return "";
  196. }
  197. const document = impl._ownerDocument;
  198. if (this._srcURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
  199. return this._srcURLCache;
  200. }
  201. this._srcURLCacheKey = value;
  202. this._baseURLCache = document._baseURLCache;
  203. const urlRecord = document.encodingParseAURL(value);
  204. if (urlRecord !== null) {
  205. this._srcURLCache = serializeURLwhatwg_url(urlRecord);
  206. return this._srcURLCache;
  207. }
  208. this._srcURLCache = conversions.USVString(value);
  209. return this._srcURLCache;
  210. } finally {
  211. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  212. }
  213. }
  214. set src(V) {
  215. const esValue = this !== null && this !== undefined ? this : globalObject;
  216. if (!exports.is(esValue)) {
  217. throw new globalObject.TypeError(
  218. "'set src' called on an object that is not a valid instance of HTMLMediaElement."
  219. );
  220. }
  221. V = conversions["USVString"](V, {
  222. context: "Failed to set the 'src' property on 'HTMLMediaElement': The provided value",
  223. globals: globalObject
  224. });
  225. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  226. try {
  227. esValue[implSymbol]._reflectSetTheContentAttribute("src", V);
  228. } finally {
  229. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  230. }
  231. }
  232. get currentSrc() {
  233. const esValue = this !== null && this !== undefined ? this : globalObject;
  234. if (!exports.is(esValue)) {
  235. throw new globalObject.TypeError(
  236. "'get currentSrc' called on an object that is not a valid instance of HTMLMediaElement."
  237. );
  238. }
  239. return esValue[implSymbol]["currentSrc"];
  240. }
  241. get crossOrigin() {
  242. const esValue = this !== null && this !== undefined ? this : globalObject;
  243. if (!exports.is(esValue)) {
  244. throw new globalObject.TypeError(
  245. "'get crossOrigin' called on an object that is not a valid instance of HTMLMediaElement."
  246. );
  247. }
  248. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  249. try {
  250. return esValue[implSymbol]._reflectGetTheContentAttribute("crossorigin");
  251. } finally {
  252. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  253. }
  254. }
  255. set crossOrigin(V) {
  256. const esValue = this !== null && this !== undefined ? this : globalObject;
  257. if (!exports.is(esValue)) {
  258. throw new globalObject.TypeError(
  259. "'set crossOrigin' called on an object that is not a valid instance of HTMLMediaElement."
  260. );
  261. }
  262. if (V === null || V === undefined) {
  263. V = null;
  264. } else {
  265. V = conversions["DOMString"](V, {
  266. context: "Failed to set the 'crossOrigin' property on 'HTMLMediaElement': The provided value",
  267. globals: globalObject
  268. });
  269. }
  270. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  271. try {
  272. if (V === null) {
  273. esValue[implSymbol]._reflectDeleteTheContentAttribute("crossorigin");
  274. } else {
  275. esValue[implSymbol]._reflectSetTheContentAttribute("crossorigin", V);
  276. }
  277. } finally {
  278. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  279. }
  280. }
  281. get networkState() {
  282. const esValue = this !== null && this !== undefined ? this : globalObject;
  283. if (!exports.is(esValue)) {
  284. throw new globalObject.TypeError(
  285. "'get networkState' called on an object that is not a valid instance of HTMLMediaElement."
  286. );
  287. }
  288. return esValue[implSymbol]["networkState"];
  289. }
  290. get preload() {
  291. const esValue = this !== null && this !== undefined ? this : globalObject;
  292. if (!exports.is(esValue)) {
  293. throw new globalObject.TypeError(
  294. "'get preload' called on an object that is not a valid instance of HTMLMediaElement."
  295. );
  296. }
  297. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  298. try {
  299. const value = esValue[implSymbol]._reflectGetTheContentAttribute("preload");
  300. return value === null ? "" : value;
  301. } finally {
  302. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  303. }
  304. }
  305. set preload(V) {
  306. const esValue = this !== null && this !== undefined ? this : globalObject;
  307. if (!exports.is(esValue)) {
  308. throw new globalObject.TypeError(
  309. "'set preload' called on an object that is not a valid instance of HTMLMediaElement."
  310. );
  311. }
  312. V = conversions["DOMString"](V, {
  313. context: "Failed to set the 'preload' property on 'HTMLMediaElement': The provided value",
  314. globals: globalObject
  315. });
  316. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  317. try {
  318. esValue[implSymbol]._reflectSetTheContentAttribute("preload", V);
  319. } finally {
  320. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  321. }
  322. }
  323. get buffered() {
  324. const esValue = this !== null && this !== undefined ? this : globalObject;
  325. if (!exports.is(esValue)) {
  326. throw new globalObject.TypeError(
  327. "'get buffered' called on an object that is not a valid instance of HTMLMediaElement."
  328. );
  329. }
  330. return utils.tryWrapperForImpl(esValue[implSymbol]["buffered"]);
  331. }
  332. get readyState() {
  333. const esValue = this !== null && this !== undefined ? this : globalObject;
  334. if (!exports.is(esValue)) {
  335. throw new globalObject.TypeError(
  336. "'get readyState' called on an object that is not a valid instance of HTMLMediaElement."
  337. );
  338. }
  339. return esValue[implSymbol]["readyState"];
  340. }
  341. get seeking() {
  342. const esValue = this !== null && this !== undefined ? this : globalObject;
  343. if (!exports.is(esValue)) {
  344. throw new globalObject.TypeError(
  345. "'get seeking' called on an object that is not a valid instance of HTMLMediaElement."
  346. );
  347. }
  348. return esValue[implSymbol]["seeking"];
  349. }
  350. get currentTime() {
  351. const esValue = this !== null && this !== undefined ? this : globalObject;
  352. if (!exports.is(esValue)) {
  353. throw new globalObject.TypeError(
  354. "'get currentTime' called on an object that is not a valid instance of HTMLMediaElement."
  355. );
  356. }
  357. return esValue[implSymbol]["currentTime"];
  358. }
  359. set currentTime(V) {
  360. const esValue = this !== null && this !== undefined ? this : globalObject;
  361. if (!exports.is(esValue)) {
  362. throw new globalObject.TypeError(
  363. "'set currentTime' called on an object that is not a valid instance of HTMLMediaElement."
  364. );
  365. }
  366. V = conversions["double"](V, {
  367. context: "Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided value",
  368. globals: globalObject
  369. });
  370. esValue[implSymbol]["currentTime"] = V;
  371. }
  372. get duration() {
  373. const esValue = this !== null && this !== undefined ? this : globalObject;
  374. if (!exports.is(esValue)) {
  375. throw new globalObject.TypeError(
  376. "'get duration' called on an object that is not a valid instance of HTMLMediaElement."
  377. );
  378. }
  379. return esValue[implSymbol]["duration"];
  380. }
  381. get paused() {
  382. const esValue = this !== null && this !== undefined ? this : globalObject;
  383. if (!exports.is(esValue)) {
  384. throw new globalObject.TypeError(
  385. "'get paused' called on an object that is not a valid instance of HTMLMediaElement."
  386. );
  387. }
  388. return esValue[implSymbol]["paused"];
  389. }
  390. get defaultPlaybackRate() {
  391. const esValue = this !== null && this !== undefined ? this : globalObject;
  392. if (!exports.is(esValue)) {
  393. throw new globalObject.TypeError(
  394. "'get defaultPlaybackRate' called on an object that is not a valid instance of HTMLMediaElement."
  395. );
  396. }
  397. return esValue[implSymbol]["defaultPlaybackRate"];
  398. }
  399. set defaultPlaybackRate(V) {
  400. const esValue = this !== null && this !== undefined ? this : globalObject;
  401. if (!exports.is(esValue)) {
  402. throw new globalObject.TypeError(
  403. "'set defaultPlaybackRate' called on an object that is not a valid instance of HTMLMediaElement."
  404. );
  405. }
  406. V = conversions["double"](V, {
  407. context: "Failed to set the 'defaultPlaybackRate' property on 'HTMLMediaElement': The provided value",
  408. globals: globalObject
  409. });
  410. esValue[implSymbol]["defaultPlaybackRate"] = V;
  411. }
  412. get playbackRate() {
  413. const esValue = this !== null && this !== undefined ? this : globalObject;
  414. if (!exports.is(esValue)) {
  415. throw new globalObject.TypeError(
  416. "'get playbackRate' called on an object that is not a valid instance of HTMLMediaElement."
  417. );
  418. }
  419. return esValue[implSymbol]["playbackRate"];
  420. }
  421. set playbackRate(V) {
  422. const esValue = this !== null && this !== undefined ? this : globalObject;
  423. if (!exports.is(esValue)) {
  424. throw new globalObject.TypeError(
  425. "'set playbackRate' called on an object that is not a valid instance of HTMLMediaElement."
  426. );
  427. }
  428. V = conversions["double"](V, {
  429. context: "Failed to set the 'playbackRate' property on 'HTMLMediaElement': The provided value",
  430. globals: globalObject
  431. });
  432. esValue[implSymbol]["playbackRate"] = V;
  433. }
  434. get played() {
  435. const esValue = this !== null && this !== undefined ? this : globalObject;
  436. if (!exports.is(esValue)) {
  437. throw new globalObject.TypeError(
  438. "'get played' called on an object that is not a valid instance of HTMLMediaElement."
  439. );
  440. }
  441. return utils.tryWrapperForImpl(esValue[implSymbol]["played"]);
  442. }
  443. get seekable() {
  444. const esValue = this !== null && this !== undefined ? this : globalObject;
  445. if (!exports.is(esValue)) {
  446. throw new globalObject.TypeError(
  447. "'get seekable' called on an object that is not a valid instance of HTMLMediaElement."
  448. );
  449. }
  450. return utils.tryWrapperForImpl(esValue[implSymbol]["seekable"]);
  451. }
  452. get ended() {
  453. const esValue = this !== null && this !== undefined ? this : globalObject;
  454. if (!exports.is(esValue)) {
  455. throw new globalObject.TypeError(
  456. "'get ended' called on an object that is not a valid instance of HTMLMediaElement."
  457. );
  458. }
  459. return esValue[implSymbol]["ended"];
  460. }
  461. get autoplay() {
  462. const esValue = this !== null && this !== undefined ? this : globalObject;
  463. if (!exports.is(esValue)) {
  464. throw new globalObject.TypeError(
  465. "'get autoplay' called on an object that is not a valid instance of HTMLMediaElement."
  466. );
  467. }
  468. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  469. try {
  470. return esValue[implSymbol]._reflectGetTheContentAttribute("autoplay") !== null;
  471. } finally {
  472. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  473. }
  474. }
  475. set autoplay(V) {
  476. const esValue = this !== null && this !== undefined ? this : globalObject;
  477. if (!exports.is(esValue)) {
  478. throw new globalObject.TypeError(
  479. "'set autoplay' called on an object that is not a valid instance of HTMLMediaElement."
  480. );
  481. }
  482. V = conversions["boolean"](V, {
  483. context: "Failed to set the 'autoplay' property on 'HTMLMediaElement': The provided value",
  484. globals: globalObject
  485. });
  486. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  487. try {
  488. if (V) {
  489. esValue[implSymbol]._reflectSetTheContentAttribute("autoplay", "");
  490. } else {
  491. esValue[implSymbol]._reflectDeleteTheContentAttribute("autoplay");
  492. }
  493. } finally {
  494. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  495. }
  496. }
  497. get loop() {
  498. const esValue = this !== null && this !== undefined ? this : globalObject;
  499. if (!exports.is(esValue)) {
  500. throw new globalObject.TypeError(
  501. "'get loop' called on an object that is not a valid instance of HTMLMediaElement."
  502. );
  503. }
  504. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  505. try {
  506. return esValue[implSymbol]._reflectGetTheContentAttribute("loop") !== null;
  507. } finally {
  508. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  509. }
  510. }
  511. set loop(V) {
  512. const esValue = this !== null && this !== undefined ? this : globalObject;
  513. if (!exports.is(esValue)) {
  514. throw new globalObject.TypeError(
  515. "'set loop' called on an object that is not a valid instance of HTMLMediaElement."
  516. );
  517. }
  518. V = conversions["boolean"](V, {
  519. context: "Failed to set the 'loop' property on 'HTMLMediaElement': The provided value",
  520. globals: globalObject
  521. });
  522. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  523. try {
  524. if (V) {
  525. esValue[implSymbol]._reflectSetTheContentAttribute("loop", "");
  526. } else {
  527. esValue[implSymbol]._reflectDeleteTheContentAttribute("loop");
  528. }
  529. } finally {
  530. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  531. }
  532. }
  533. get controls() {
  534. const esValue = this !== null && this !== undefined ? this : globalObject;
  535. if (!exports.is(esValue)) {
  536. throw new globalObject.TypeError(
  537. "'get controls' called on an object that is not a valid instance of HTMLMediaElement."
  538. );
  539. }
  540. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  541. try {
  542. return esValue[implSymbol]._reflectGetTheContentAttribute("controls") !== null;
  543. } finally {
  544. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  545. }
  546. }
  547. set controls(V) {
  548. const esValue = this !== null && this !== undefined ? this : globalObject;
  549. if (!exports.is(esValue)) {
  550. throw new globalObject.TypeError(
  551. "'set controls' called on an object that is not a valid instance of HTMLMediaElement."
  552. );
  553. }
  554. V = conversions["boolean"](V, {
  555. context: "Failed to set the 'controls' property on 'HTMLMediaElement': The provided value",
  556. globals: globalObject
  557. });
  558. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  559. try {
  560. if (V) {
  561. esValue[implSymbol]._reflectSetTheContentAttribute("controls", "");
  562. } else {
  563. esValue[implSymbol]._reflectDeleteTheContentAttribute("controls");
  564. }
  565. } finally {
  566. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  567. }
  568. }
  569. get volume() {
  570. const esValue = this !== null && this !== undefined ? this : globalObject;
  571. if (!exports.is(esValue)) {
  572. throw new globalObject.TypeError(
  573. "'get volume' called on an object that is not a valid instance of HTMLMediaElement."
  574. );
  575. }
  576. return esValue[implSymbol]["volume"];
  577. }
  578. set volume(V) {
  579. const esValue = this !== null && this !== undefined ? this : globalObject;
  580. if (!exports.is(esValue)) {
  581. throw new globalObject.TypeError(
  582. "'set volume' called on an object that is not a valid instance of HTMLMediaElement."
  583. );
  584. }
  585. V = conversions["double"](V, {
  586. context: "Failed to set the 'volume' property on 'HTMLMediaElement': The provided value",
  587. globals: globalObject
  588. });
  589. esValue[implSymbol]["volume"] = V;
  590. }
  591. get muted() {
  592. const esValue = this !== null && this !== undefined ? this : globalObject;
  593. if (!exports.is(esValue)) {
  594. throw new globalObject.TypeError(
  595. "'get muted' called on an object that is not a valid instance of HTMLMediaElement."
  596. );
  597. }
  598. return esValue[implSymbol]["muted"];
  599. }
  600. set muted(V) {
  601. const esValue = this !== null && this !== undefined ? this : globalObject;
  602. if (!exports.is(esValue)) {
  603. throw new globalObject.TypeError(
  604. "'set muted' called on an object that is not a valid instance of HTMLMediaElement."
  605. );
  606. }
  607. V = conversions["boolean"](V, {
  608. context: "Failed to set the 'muted' property on 'HTMLMediaElement': The provided value",
  609. globals: globalObject
  610. });
  611. esValue[implSymbol]["muted"] = V;
  612. }
  613. get defaultMuted() {
  614. const esValue = this !== null && this !== undefined ? this : globalObject;
  615. if (!exports.is(esValue)) {
  616. throw new globalObject.TypeError(
  617. "'get defaultMuted' called on an object that is not a valid instance of HTMLMediaElement."
  618. );
  619. }
  620. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  621. try {
  622. return esValue[implSymbol]._reflectGetTheContentAttribute("muted") !== null;
  623. } finally {
  624. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  625. }
  626. }
  627. set defaultMuted(V) {
  628. const esValue = this !== null && this !== undefined ? this : globalObject;
  629. if (!exports.is(esValue)) {
  630. throw new globalObject.TypeError(
  631. "'set defaultMuted' called on an object that is not a valid instance of HTMLMediaElement."
  632. );
  633. }
  634. V = conversions["boolean"](V, {
  635. context: "Failed to set the 'defaultMuted' property on 'HTMLMediaElement': The provided value",
  636. globals: globalObject
  637. });
  638. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  639. try {
  640. if (V) {
  641. esValue[implSymbol]._reflectSetTheContentAttribute("muted", "");
  642. } else {
  643. esValue[implSymbol]._reflectDeleteTheContentAttribute("muted");
  644. }
  645. } finally {
  646. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  647. }
  648. }
  649. get audioTracks() {
  650. const esValue = this !== null && this !== undefined ? this : globalObject;
  651. if (!exports.is(esValue)) {
  652. throw new globalObject.TypeError(
  653. "'get audioTracks' called on an object that is not a valid instance of HTMLMediaElement."
  654. );
  655. }
  656. return utils.getSameObject(this, "audioTracks", () => {
  657. return utils.tryWrapperForImpl(esValue[implSymbol]["audioTracks"]);
  658. });
  659. }
  660. get videoTracks() {
  661. const esValue = this !== null && this !== undefined ? this : globalObject;
  662. if (!exports.is(esValue)) {
  663. throw new globalObject.TypeError(
  664. "'get videoTracks' called on an object that is not a valid instance of HTMLMediaElement."
  665. );
  666. }
  667. return utils.getSameObject(this, "videoTracks", () => {
  668. return utils.tryWrapperForImpl(esValue[implSymbol]["videoTracks"]);
  669. });
  670. }
  671. get textTracks() {
  672. const esValue = this !== null && this !== undefined ? this : globalObject;
  673. if (!exports.is(esValue)) {
  674. throw new globalObject.TypeError(
  675. "'get textTracks' called on an object that is not a valid instance of HTMLMediaElement."
  676. );
  677. }
  678. return utils.getSameObject(this, "textTracks", () => {
  679. return utils.tryWrapperForImpl(esValue[implSymbol]["textTracks"]);
  680. });
  681. }
  682. }
  683. Object.defineProperties(HTMLMediaElement.prototype, {
  684. load: { enumerable: true },
  685. canPlayType: { enumerable: true },
  686. play: { enumerable: true },
  687. pause: { enumerable: true },
  688. addTextTrack: { enumerable: true },
  689. src: { enumerable: true },
  690. currentSrc: { enumerable: true },
  691. crossOrigin: { enumerable: true },
  692. networkState: { enumerable: true },
  693. preload: { enumerable: true },
  694. buffered: { enumerable: true },
  695. readyState: { enumerable: true },
  696. seeking: { enumerable: true },
  697. currentTime: { enumerable: true },
  698. duration: { enumerable: true },
  699. paused: { enumerable: true },
  700. defaultPlaybackRate: { enumerable: true },
  701. playbackRate: { enumerable: true },
  702. played: { enumerable: true },
  703. seekable: { enumerable: true },
  704. ended: { enumerable: true },
  705. autoplay: { enumerable: true },
  706. loop: { enumerable: true },
  707. controls: { enumerable: true },
  708. volume: { enumerable: true },
  709. muted: { enumerable: true },
  710. defaultMuted: { enumerable: true },
  711. audioTracks: { enumerable: true },
  712. videoTracks: { enumerable: true },
  713. textTracks: { enumerable: true },
  714. [Symbol.toStringTag]: { value: "HTMLMediaElement", configurable: true },
  715. NETWORK_EMPTY: { value: 0, enumerable: true },
  716. NETWORK_IDLE: { value: 1, enumerable: true },
  717. NETWORK_LOADING: { value: 2, enumerable: true },
  718. NETWORK_NO_SOURCE: { value: 3, enumerable: true },
  719. HAVE_NOTHING: { value: 0, enumerable: true },
  720. HAVE_METADATA: { value: 1, enumerable: true },
  721. HAVE_CURRENT_DATA: { value: 2, enumerable: true },
  722. HAVE_FUTURE_DATA: { value: 3, enumerable: true },
  723. HAVE_ENOUGH_DATA: { value: 4, enumerable: true }
  724. });
  725. Object.defineProperties(HTMLMediaElement, {
  726. NETWORK_EMPTY: { value: 0, enumerable: true },
  727. NETWORK_IDLE: { value: 1, enumerable: true },
  728. NETWORK_LOADING: { value: 2, enumerable: true },
  729. NETWORK_NO_SOURCE: { value: 3, enumerable: true },
  730. HAVE_NOTHING: { value: 0, enumerable: true },
  731. HAVE_METADATA: { value: 1, enumerable: true },
  732. HAVE_CURRENT_DATA: { value: 2, enumerable: true },
  733. HAVE_FUTURE_DATA: { value: 3, enumerable: true },
  734. HAVE_ENOUGH_DATA: { value: 4, enumerable: true }
  735. });
  736. ctorRegistry[interfaceName] = HTMLMediaElement;
  737. Object.defineProperty(globalObject, interfaceName, {
  738. configurable: true,
  739. writable: true,
  740. value: HTMLMediaElement
  741. });
  742. };
  743. const Impl = require("../../jsdom/living/nodes/HTMLMediaElement-impl.js");