var domAutomationController = {};
domAutomationController._frame_count = 0;
domAutomationController._frame_request = 0;
domAutomationController._done = false;
domAutomationController._failure = false;
document.onreadystatechange = function() {
if (document.readyState === 'complete') {
const video = document.querySelector('video');
if (!video) {
console.log('Video element could not be found');
window.close();
return;
}
video.requestVideoFrameCallback(function(now, metadata) {
domAutomationController._frame_count++;
domAutomationController.checkTermination();
});
}
}
domAutomationController.checkTermination = function() {
if (this._frame_request === 0) {
return;
}
if (this._frame_request >= this._frame_count) {
this._done = true;
}
}
domAutomationController.setFrameRequest = function(frame_request) {
this._frame_request = frame_request;
this.checkTermination();
}
window.close = function() {
domAutomationController._failure = true;
domAutomationController._done = true;
};
window.domAutomationController = domAutomationController;