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=1089880--><head><title>Test for Bug 1089880</title><scriptsrc="/tests/SimpleTest/SimpleTest.js"></script><scriptsrc="/tests/SimpleTest/WindowSnapshot.js"></script><scripttype="application/javascript"src="imgutils.js"></script><linkrel="stylesheet"type="text/css"href="/tests/SimpleTest/test.css"/></head><body><atarget="_blank"href="https://bugzilla.mozilla.org/show_bug.cgi?id=1089880">Mozilla Bug 1089880</a><pid="display"></p><divid="content"></div><preid="test"><scripttype="application/javascript">/** Test for Bug 1089880 **/SimpleTest.requestFlakyTimeout("Early failure timeout");SimpleTest.waitForExplicitFinish();constFAILURE_TIMEOUT=120000;// Fail early after 120 seconds (2 minutes)constCc=SpecialPowers.Cc;constCi=SpecialPowers.Ci;constgContent=document.getElementById("content");vargCanvas;vargCanvasCtx;vargImg;vargMyDecoderObserver;vargIsTestFinished=false;vargFiles;vargCurrentFileIsTransparent=false;vargHasTransparencyWasCalled=false;function*testFiles(){// [A, B] where 'A' is the image and 'B' is whether it's transparent.// PNGs and GIFs may be transparent or not.yield["red.png",false];yield["transparent.png",true];yield["animated-gif-finalframe.gif",false];yield["transparent.gif",true];// GIFs with padding on the first frame are always transparent.yield["first-frame-padding.gif",true];// JPEGs are never transparent.yield["damon.jpg",false];// Most BMPs are not transparent. (The TestMetadata GTest, which will// eventually replace this test totally, has coverage for the kinds that can be// transparent.)yield["opaque.bmp",false];// ICO files which contain BMPs have an additional type of transparency - the// AND mask - that warrants separate testing. (Although, after bug 1201796,// all ICOs are considered transparent.)yield["ico-bmp-opaque.ico",true];yield["ico-bmp-transparent.ico",true];// SVGs are always transparent.yield["lime100x100.svg",true];}functionloadNext(){varcurrentFile="";gHasTransparencyWasCalled=false;let{done,value}=gFiles.next();if(done){// We ran out of test files.cleanUpAndFinish();return;}[currentFile,gCurrentFileIsTransparent]=value;gImg.setAttribute("src",currentFile);}functiononHasTransparency(){gHasTransparencyWasCalled=true;}functiononDecodeComplete(){if(!gCurrentFileIsTransparent){ok(!gHasTransparencyWasCalled,"onHasTransparency was not called for non-transparent file "+gImg.src);}else{ok(gHasTransparencyWasCalled,"onHasTransparency was called for transparent file "+gImg.src);}loadNext();}functiononError(){if(gIsTestFinished){return;}ok(false,"Should successfully load "+gImg.src);loadNext();}functiononLoad(){if(gIsTestFinished){return;}ok(true,"Should successfully load "+gImg.src);// Force decoding of the image.SimpleTest.executeSoon(function(){gCanvasCtx.drawImage(gImg,0,0);});}functionfailTest(){ok(false,"timing out after "+FAILURE_TIMEOUT+"ms. "+"currently displaying "+gImg.src);cleanUpAndFinish();}functioncleanUpAndFinish(){if(gIsTestFinished){return;}gIsTestFinished=true;letimgLoadingContent=SpecialPowers.wrap(gImg);imgLoadingContent.removeObserver(gMyDecoderObserver);SimpleTest.finish();}functionmain(){gFiles=testFiles();gCanvas=document.createElement('canvas');gCanvasCtx=gCanvas.getContext('2d');gImg=newImage();gImg.onload=onLoad;gImg.onerror=onError;// Create, customize & attach decoder observer.varobserver=newImageDecoderObserverStub();observer.hasTransparency=onHasTransparency;observer.decodeComplete=onDecodeComplete;gMyDecoderObserver=Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools).createScriptedObserver(SpecialPowers.wrapCallbackObject(observer));letimgLoadingContent=SpecialPowers.wrap(gImg);imgLoadingContent.addObserver(gMyDecoderObserver);// We want to test the cold loading behavior, so clear cache in case an// earlier test got our image in there already.clearAllImageCaches();// Load the first image.loadNext();// In case something goes wrong, fail earlier than mochitest timeout,// and with more information.setTimeout(failTest,FAILURE_TIMEOUT);}window.onload=main;</script></pre></body></html>