Fix flaky tests in test-custom-element.js (#19853)
Fix flaky tests in test-custom-element.js (#19853)

* mock window.matchMedia call.

* fix test

* update comment

* address choumx comments

* lint

Gregable/amphtml,yandex-pcode/amphtml,alanorozco/amphtml,rsimha-amp/amphtml,tlong2/amphtml,Gregable/amphtml,jpettitt/amphtml,alanorozco/amphtml,ampproject/amphtml,smartadserver/amphtml,jridgewell/amphtml,honeybadgerdontcare/amphtml,techhtml/amphtml,yandex-pcode/amphtml,Gregable/amphtml,Gregable/amphtml,tlong2/amphtml,taboola/amphtml,zhouyx/amphtml,jmadler/amphtml,honeybadgerdontcare/amphtml,widespace-os/amphtml,honeybadgerdontcare/amphtml,zhangsu/amphtml,cvializ/amphtml,adup-tech/amphtml,laterpay/amphtml,sharethrough/amphtml,danielrozenberg/amphtml,lannka/amphtml,zhangsu/amphtml,mhc-gh/amphtml,jpettitt/amphtml,rsimha-amp/amphtml,lannka/amphtml,nexxtv/amphtml,jridgewell/amphtml,sebastianbenz/amphtml,sharethrough/amphtml,src-code/amphtml,adup-tech/amphtml,nexxtv/amphtml,nexxtv/amphtml,voyagegroup/amphtml,jpettitt/amphtml,honeybadgerdontcare/amphtml,jmadler/amphtml,laterpay/amphtml,src-code/amphtml,prateekbh/amphtml,honeybadgerdontcare/amphtml,smartadserver/amphtml,alanorozco/amphtml,erwinmombay/amphtml,ampproject/amphtml,adup-tech/amphtml,rsimha-amp/amphtml,voyagegroup/amphtml,sebastianbenz/amphtml,taboola/amphtml,danielrozenberg/amphtml,yandex-pcode/amphtml,voyagegroup/amphtml,zhangsu/amphtml,cory-work/amphtml,sharethrough/amphtml,erwinmombay/amphtml,rsimha-amp/amphtml,media-net/amphtml,media-net/amphtml,zhouyx/amphtml,cvializ/amphtml,erwinmombay/amphtml,taboola/amphtml,dotandads/amphtml,jridgewell/amphtml,voyagegroup/amphtml,yandex-pcode/amphtml,src-code/amphtml,danielrozenberg/amphtml,widespace-os/amphtml,taboola/amphtml,nexxtv/amphtml,erwinmombay/amphtml,zhangsu/amphtml,sebastianbenz/amphtml,alanorozco/amphtml,yandex-pcode/amphtml,voyagegroup/amphtml,Gregable/amphtml,cory-work/amphtml,prateekbh/amphtml,mhc-gh/amphtml,adup-tech/amphtml,honeybadgerdontcare/amphtml,cvializ/amphtml,cvializ/amphtml,media-net/amphtml,adup-tech/amphtml,smartadserver/amphtml,media-net/amphtml,voyagegroup/amphtml,media-net/amphtml,smartadserver/amphtml,danielrozenberg/amphtml,sharethrough/amphtml,cory-work/amphtml,jpettitt/amphtml,rsimha-amp/amphtml,zhouyx/amphtml,mhc-gh/amphtml,lannka/amphtml,techhtml/amphtml,taboola/amphtml,techhtml/amphtml,jpettitt/amphtml,tlong2/amphtml,src-code/amphtml,laterpay/amphtml,Gregable/amphtml,mhc-gh/amphtml,mhc-gh/amphtml,cory-work/amphtml,alanorozco/amphtml,cory-work/amphtml,src-code/amphtml,jpettitt/amphtml,dotandads/amphtml,adup-tech/amphtml,dotandads/amphtml,ampproject/amphtml,jmadler/amphtml,prateekbh/amphtml,lannka/amphtml,jridgewell/amphtml,cvializ/amphtml,nexxtv/amphtml,sharethrough/amphtml,mhc-gh/amphtml,sebastianbenz/amphtml,dotandads/amphtml,smartadserver/amphtml,rsimha-amp/amphtml,ampproject/amphtml,cvializ/amphtml,sebastianbenz/amphtml,jpettitt/amphtml,cory-work/amphtml,prateekbh/amphtml,zhangsu/amphtml,Gregable/amphtml,zhouyx/amphtml,lannka/amphtml,lannka/amphtml,jmadler/amphtml,mhc-gh/amphtml,media-net/amphtml,alanorozco/amphtml,jmadler/amphtml,rsimha-amp/amphtml,cory-work/amphtml,erwinmombay/amphtml,jridgewell/amphtml,dotandads/amphtml,widespace-os/amphtml,tlong2/amphtml,ampproject/amphtml,taboola/amphtml,Gregable/amphtml,zhouyx/amphtml,danielrozenberg/amphtml,jpettitt/amphtml,honeybadgerdontcare/amphtml,alanorozco/amphtml,widespace-os/amphtml,sharethrough/amphtml,danielrozenberg/amphtml,techhtml/amphtml,yandex-pcode/amphtml,media-net/amphtml,erwinmombay/amphtml,prateekbh/amphtml,zhouyx/amphtml,danielrozenberg/amphtml,voyagegroup/amphtml,zhouyx/amphtml,tlong2/amphtml,ampproject/amphtml,jmadler/amphtml,smartadserver/amphtml,laterpay/amphtml,widespace-os/amphtml,dotandads/amphtml,jridgewell/amphtml,mhc-gh/amphtml,media-net/amphtml,nexxtv/amphtml,sebastianbenz/amphtml,prateekbh/amphtml,widespace-os/amphtml,jridgewell/amphtml,techhtml/amphtml,yandex-pcode/amphtml,techhtml/amphtml,danielrozenberg/amphtml,zhangsu/amphtml,laterpay/amphtml,laterpay/amphtml,ampproject/amphtml,nexxtv/amphtml,src-code/amphtml,alanorozco/amphtml,ampproject/amphtml,lannka/amphtml,prateekbh/amphtml,taboola/amphtml,tlong2/amphtml