<!DOCTYPE html><metacharset="utf-8"><title>Test Background Video Displays Video Frame via drawImage When Suspended</title><scriptsrc="/tests/SimpleTest/SimpleTest.js"></script><scriptsrc="manifest.js"></script><scriptsrc="background_video.js"></script><linkrel="stylesheet"href="/tests/SimpleTest/test.css"/><style>video,canvas{border:1pxsolidblack;}</style><scripttype="text/javascript">"use strict";varmanager=newMediaTestManager;functiondrawVideoToCanvas(v){console.log('drawVideoToCanvas');letc=document.createElement('canvas');c.width=4;c.height=4;c.style.width=64;c.style.height=64;document.body.appendChild(c);letgfx=c.getContext('2d');if(!gfx){throwError("Unable to obtain context '2d' from canvas");}gfx.drawImage(v,0,0,4,4);letimageData=gfx.getImageData(0,0,4,4);letpixels=imageData.data;// Check that pixels aren't all the same colour.// Implements by checking against rgb of the first pixel.letrr=pixels[0],gg=pixels[1],bb=pixels[2],allSame=true;for(leti=0;i<4*4;i++){letr=pixels[4*i+0];letg=pixels[4*i+1];letb=pixels[4*i+2];if(r!=rr||g!=gg||b!=bb){allSame=false;break;}}ok(!allSame,"Pixels aren't all the same color");}startTest({desc:'Test Background Video Displays Video Frame via drawImage When Suspended',prefs:[["media.test.video-suspend",true],["media.suspend-background-video.enabled",true],["media.suspend-background-video.delay-ms",500]],tests:gDecodeSuspendTests,runTest:(test,token)=>{letv=appendVideoToDoc(test.name,token);manager.started(token);waitUntilPlaying(v).then(()=>testVideoSuspendsWhenHidden(v)).then(()=>{drawVideoToCanvas(v);manager.finished(token);});}});</script>