Revert "Bug 1977690 - Remove unused AppRequestInterceptor in androidTests r=aaronmt" for causing fenix-debug failures.
This reverts commit bc9dc5f4296482e17560627acaacd2797e462211.
<!DOCTYPE HTML><html><!--https://bugzilla.mozilla.org/show_bug.cgi?id=478957--><head><title>Test for Bug 478957</title><scriptsrc="/tests/SimpleTest/SimpleTest.js"></script><linkrel="stylesheet"type="text/css"href="/tests/SimpleTest/test.css"/><scripttype="text/javascript"src="manifest.js"></script></head><body><atarget="_blank"href="https://bugzilla.mozilla.org/show_bug.cgi?id=478957">Mozilla Bug 478957</a><pid="display"></p><divid="content"style="display: none"></div><divid="log"style="font-size: small;"></div><preid="test"><scripttype="application/javascript">/** Test for Bug 478957 **/// Tests whether we leak events and state change info when loading stuff from local files from a webserver.varmanager=newMediaTestManager;vargEventTypes=['loadstart','progress','suspend','abort','error','emptied','stalled','play','pause','loadedmetadata','loadeddata','waiting','playing','canplay','canplaythrough','seeking','seeked','timeupdate','ended','ratechange','durationchange','volumechange'];vargExpectedEvents=['loadstart','error'];functioncreateTestArray(){vartests=[];vartmpVid=document.createElement("video");returnmakeInfoLeakTests().then(infoLeakTests=>{for(vartestNum=0;testNum<infoLeakTests.length;testNum++){vartest=infoLeakTests[testNum];if(!tmpVid.canPlayType(test.type)){continue;}vart={};t.name=test.src;t.type=test.type;tests.push(t);}returntests;})}functionlog(msg){info(msg);varl=document.getElementById('log');l.innerHTML+=msg+"<br>";}functionfinish(v){log("finish: "+v.name);clearInterval(v.checkStateInterval);for(vari=0;i<gEventTypes.length;i++){v.removeEventListener(gEventTypes[i],listener);}removeNodeAndSource(v);manager.finished(v.token);v=null;}functionlistener(evt){varv=evt.target;log(filename(v.name)+': got '+evt.type);// On slow machines like B2G emulator, progress timer could time out before// receiving any HTTP notification. We will ignore the 'stalled' event to// pass the tests.if(evt.type=='stalled'){return;}ok(v.eventNum<gExpectedEvents.length,filename(v.name)+" Too many events received");varexpected=(v.eventNum<gExpectedEvents.length)?gExpectedEvents[v.eventNum]:"NoEvent";is(evt.type,expected,filename(v.name)+" Events received in wrong order");v.eventNum++;if(v.eventNum==gExpectedEvents.length){// In one second, move onto the next test. This give a chance for any// other events to come in. Note: we don't expect any events to come// in, unless we've leaked some info, and 1 second should be enough time// for the leak to show up.setTimeout(function(){finish(v);},1000);}}functioncreateMedia(type,src,token){vartag=getMajorMimeType(type);varv=document.createElement(tag);for(vari=0;i<gEventTypes.length;i++){v.addEventListener(gEventTypes[i],listener);}v.preload="metadata";v.src=src;v.name=src;document.body.appendChild(v);v.eventNum=0;v.token=token;setTimeout(function(){v.checkStateInterval=setInterval(function(){checkState(v);},1);},0);}// Define our own ok() and is() functions. The mochitest ones take ages constructing the log// of all the passes, so only report failures.functiontest_ok(b,msg){if(!b){log("FAILED test_ok: "+msg);ok(b,msg);}}functiontest_is(a,b,msg){if(a!=b){log("FAILED test_is: "+msg);is(a,b,msg);}}functionfilename(uri){returnuri.substr(uri.lastIndexOf("/")+1);}functioncheckState(v){test_ok(v.networkState<=HTMLMediaElement.NETWORK_LOADING||v.networkState==HTMLMediaElement.NETWORK_NO_SOURCE,"NetworkState of "+v.networkState+" was leaked.");test_ok(v.readyState==HTMLMediaElement.HAVE_NOTHING,"Ready state of "+v.readyState+" was leaked");test_is(v.seeking,false,"Seeking leaked");test_is(v.currentTime,0,"Leaked currentTime");test_ok(isNaN(v.duration),"Leaked duration");test_is(v.paused,true,"Paused leaked");test_is(v.ended,false,"Ended leaked");test_is(v.autoplay,false,"Autoplay leaked");test_is(v.controls,false,"Controls leaked");test_is(v.muted,false,"muted leaked");test_ok(v.error==null||v.error.code==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,"Error code should not exist or be SRC_NOT_SUPPORTED. v.error="+(v.error?v.error.code:"null"));test_ok(filename(v.currentSrc)==filename(v.name)||v.networkState==HTMLMediaElement.NETWORK_NO_SOURCE,"currentSrc should match candidate uri, if we've got a valid source");}functionstartTest(test,token){manager.started(token);log("Testing: "+test.type+" @ "+test.name);createMedia(test.type,test.name,token);}SimpleTest.waitForExplicitFinish();createTestArray().then(testArray=>{manager.runTests(testArray,startTest);});</script></pre></body></html>