| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>Test that calling prompt() before the promise returned by the previous call is resolved throws an exception</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="util.js"></script> |
| </head> |
| <body> |
| <button id="button">Click me</button> |
| <script> |
| // WPT: this test can't be moved to WPT because of its usage of: |
| // - user gesture; |
| // - internals.mediaPlayerRemoteRouteAvailabilityChanged |
| // - internals.runtimeFlags |
| |
| function clickOnElem(e) { |
| eventSender.mouseMoveTo( |
| e.offsetLeft + e.offsetWidth / 2, |
| e.offsetTop + e.offsetHeight / 2); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| } |
| |
| async_test(function(test) |
| { |
| // So that prompt() doesn't throw NotSupportedError. |
| enableRemotePlaybackBackendForTest(test); |
| |
| var v = document.createElement('video'); |
| v.src = '../content/test.ogv'; |
| document.body.appendChild(v); |
| |
| var btn = document.getElementById('button'); |
| btn.onclick = function() { |
| internals.mediaPlayerRemoteRouteAvailabilityChanged(v, true); |
| |
| v.remote.prompt().then( |
| test.step_func(function() {}), |
| test.step_func(function() {})); |
| |
| v.remote.prompt().then( |
| test.unreached_func(), |
| test.step_func_done(function(e) { |
| assert_equals(e.name, 'OperationError'); |
| assert_equals(e.message, 'A prompt is already being shown for this media element.'); |
| })); |
| btn.onclick = null; |
| } |
| |
| clickOnElem(btn); |
| }, 'Test that calling prompt() before the promise returned by the previous call is resolved throws an exception.'); |
| </script> |
| </body> |
| </html> |