| <!DOCTYPE html> |
| <title>Test harness for forced suspend browser tests.</title> |
| <video></video> |
| <script> |
| var QueryString = function() { |
| // Allows access to query parameters on the URL; e.g., given a URL like: |
| // http://<server>/my.html?test=123&bob=123 |
| // Parameters can then be accessed via QueryString.test or QueryString.bob. |
| var params = {}; |
| // RegEx to split out values by &. |
| var r = /([^&=]+)=?([^&]*)/g; |
| // Lambda function for decoding extracted match values. Replaces '+' with |
| // space so decodeURIComponent functions properly. |
| function d(s) { return decodeURIComponent(s.replace(/\+/g, ' ')); } |
| var match; |
| while (match = r.exec(window.location.search.substring(1))) |
| params[d(match[1])] = d(match[2]); |
| return params; |
| }(); |
| |
| var video = document.querySelector('video'); |
| |
| function pollSuspendState() { |
| if (!window.internals.isMediaElementSuspended(video)) { |
| window.requestAnimationFrame(pollSuspendState); |
| return; |
| } |
| |
| // Wait for the resume. |
| window.requestAnimationFrame(pollCurrentTime); |
| |
| document.title = 'SUSPENDED'; |
| } |
| |
| function pollCurrentTime() { |
| if (video.currentTime > 0) { |
| document.title = 'ENDED'; |
| } else { |
| window.requestAnimationFrame(pollCurrentTime); |
| } |
| } |
| |
| video.addEventListener(QueryString.event, function(e) { |
| window.requestAnimationFrame(pollSuspendState); |
| document.title = 'LOADED'; |
| }, false); |
| |
| video.addEventListener("error", function(e) { |
| document.title = 'ERROR'; |
| }, false); |
| |
| video.src = 'bear.webm' |
| |
| </script> |