4 <title>Media test: promise-based play() method
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
7 <script type=
"text/javascript" src=
"manifest.js"></script>
13 // Name: loadAlgorithmRejectPromisesWhenPausing
14 // Case: step1: create an element with its paused member to be fause and networkState to be NETWORK_NO_SOURCE.
15 // stpe2: invoke load() on the element and the load() rejects the pending promise.
16 // Expected result: reject the pending promise with AbortError DOM exception.
18 let manager
= new MediaTestManager
;
20 function initTest(test
, token
) {
21 manager
.started(token
);
23 let element
= document
.createElement(getMajorMimeType(test
.type
));
24 // Invoke play() -> (1) the promise will be left pending.
25 // (2) invoke load() -> (1) set the networkState to be NETWORK_NO_SOURCE.
26 // (2) queue a task to run resouce selection algorithm.
29 ok(false, `${token} is resolved with ${result}.`);
32 if (error
.name
== "AbortError") {
33 ok(true, `${token} is rejected with ${error.name}.`);
35 ok(false, `${token} is rejected with ${error.name}.`);
38 ).then( () => { manager
.finished(token
); } );
40 ok(element
.networkState
== HTMLMediaElement
.NETWORK_NO_SOURCE
);
42 // Invoke load() again and since the networkState is NETWORK_NO_SOURCE, the load() rejects the pending promise.
43 element
.src
= test
.name
;
45 // Since the networkState is not NETWORK_EMPTY, the load() sets paused to be true.
46 ok(element
.paused
, `loadAlgorithmRejectPromisesWhenPausing(${token}).paused should be true.`);
49 manager
.runTests(gSmallTests
, initTest
);