[{"data":1,"prerenderedAt":416},["ShallowReactive",2],{"navigation_docs":3,"-fake-browser-triggering-events":133,"-fake-browser-triggering-events-surround":413},[4,22,51,62,73,84,99,118],{"title":5,"path":6,"stem":7,"children":8,"page":21},"Get Started","/get-started","0.get-started",[9,13,17],{"title":10,"path":11,"stem":12},"Introduction","/get-started/introduction","0.get-started/0.introduction",{"title":14,"path":15,"stem":16},"Browser Support","/get-started/browser-support","0.get-started/1.browser-support",{"title":18,"path":19,"stem":20},"Contributing","/get-started/contributing","0.get-started/2.contributing",false,{"title":23,"path":24,"stem":25,"children":26,"page":21},"Fake Browser","/fake-browser","fake-browser",[27,31,35,39,43,47],{"title":28,"path":29,"stem":30},"Installation","/fake-browser/installation","fake-browser/0.installation",{"title":32,"path":33,"stem":34},"Testing Frameworks","/fake-browser/testing-frameworks","fake-browser/1.testing-frameworks",{"title":36,"path":37,"stem":38},"Triggering Events","/fake-browser/triggering-events","fake-browser/2.triggering-events",{"title":40,"path":41,"stem":42},"Resetting State","/fake-browser/reseting-state","fake-browser/3.reseting-state",{"title":44,"path":45,"stem":46},"Implemented Apis","/fake-browser/implemented-apis","fake-browser/4.implemented-apis",{"title":48,"path":49,"stem":50},"Api","/fake-browser/api","fake-browser/api",{"title":52,"path":53,"stem":54,"children":55,"page":21},"Isolated Element","/isolated-element","isolated-element",[56,59],{"title":28,"path":57,"stem":58},"/isolated-element/installation","isolated-element/0.installation",{"title":48,"path":60,"stem":61},"/isolated-element/api","isolated-element/api",{"title":63,"path":64,"stem":65,"children":66,"page":21},"Job Scheduler","/job-scheduler","job-scheduler",[67,70],{"title":28,"path":68,"stem":69},"/job-scheduler/installation","job-scheduler/0.installation",{"title":48,"path":71,"stem":72},"/job-scheduler/api","job-scheduler/api",{"title":74,"path":75,"stem":76,"children":77,"page":21},"Match Patterns","/match-patterns","match-patterns",[78,81],{"title":28,"path":79,"stem":80},"/match-patterns/installation","match-patterns/0.installation",{"title":48,"path":82,"stem":83},"/match-patterns/api","match-patterns/api",{"title":85,"path":86,"stem":87,"children":88,"page":21},"Messaging","/messaging","messaging",[89,92,96],{"title":28,"path":90,"stem":91},"/messaging/installation","messaging/0.installation",{"title":93,"path":94,"stem":95},"Protocol Maps","/messaging/protocol-maps","messaging/1.protocol-maps",{"title":48,"path":97,"stem":98},"/messaging/api","messaging/api",{"title":100,"path":101,"stem":102,"children":103,"page":21},"Proxy Service","/proxy-service","proxy-service",[104,107,111,115],{"title":28,"path":105,"stem":106},"/proxy-service/installation","proxy-service/0.installation",{"title":108,"path":109,"stem":110},"Defining Services","/proxy-service/defining-services","proxy-service/1.defining-services",{"title":112,"path":113,"stem":114},"Service Keys","/proxy-service/service-keys","proxy-service/2.service-keys",{"title":48,"path":116,"stem":117},"/proxy-service/api","proxy-service/api",{"title":119,"path":120,"stem":121,"children":122,"page":21},"Storage","/storage","storage",[123,126,130],{"title":28,"path":124,"stem":125},"/storage/installation","storage/0.installation",{"title":127,"path":128,"stem":129},"Typescript","/storage/typescript","storage/1.typescript",{"title":48,"path":131,"stem":132},"/storage/api","storage/api",{"id":134,"title":36,"body":135,"description":208,"extension":407,"links":408,"meta":409,"navigation":410,"path":37,"seo":411,"stem":38,"__hash__":412},"docs/fake-browser/2.triggering-events.md",{"type":136,"value":137,"toc":405},"minimark",[138,142,166,177,185,191,202,394,401],[139,140,141],"p",{},"When possible, events are triggered based on other calls to other browser APIs. For example:",[143,144,145,158],"ul",{},[146,147,148,149,153,154,157],"li",{},"Calling ",[150,151,152],"code",{},"fakeBrowser.runtime.sendMessage()"," will trigger the ",[150,155,156],{},"fakeBrowser.runtime.onMessage"," listeners",[146,159,148,160,153,163,157],{},[150,161,162],{},"fakeBrowser.tabs.create()",[150,164,165],{},"fakeBrowser.tabs.onCreated",[139,167,168,169,172,173,176],{},"Some events, like ",[150,170,171],{},"runtime.onInstalled"," or ",[150,174,175],{},"alarms.onAlarm",", can't be triggered as they would be in a real extension.",[178,179,180,181,184],"alert",{},"In the case of ",[150,182,183],{},"onInstalled",", when is an extension \"installed\" during tests? Never? Or when the tests start? Either way, not useful for testing.",[178,186,180,187,190],{},[150,188,189],{},"onAlarm",", alarms are meant to trigger in the far future, usually a much longer timespan than the duration of a unit test. Also, timers in tests are notoriously flakey and difficult to work with.",[139,192,193,194,197,198,201],{},"Instead, the ",[150,195,196],{},"fakeBrowser"," provides a ",[150,199,200],{},"trigger"," method on every implemented event that you can call to trigger them manually. Pass in the arguments that the listeners are called with:",[203,204,209],"pre",{"className":205,"code":206,"language":207,"meta":208,"style":208},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","await fakeBrowser.runtime.onInstalled.trigger({ reason: 'install' });\nawait fakeBrowser.alarms.onAlarm.trigger({\n  name: 'alarm-name',\n  periodInMinutes: 5,\n  scheduledTime: Date.now(),\n});\nawait fakeBrowser.tab.onCreated.trigger({ ... });\n","ts","",[150,210,211,272,297,315,329,350,360],{"__ignoreMap":208},[212,213,216,220,224,228,231,233,235,237,240,243,246,250,253,256,260,263,266,269],"span",{"class":214,"line":215},"line",1,[212,217,219],{"class":218},"s7zQu","await",[212,221,223],{"class":222},"sTEyZ"," fakeBrowser",[212,225,227],{"class":226},"sMK4o",".",[212,229,230],{"class":222},"runtime",[212,232,227],{"class":226},[212,234,183],{"class":222},[212,236,227],{"class":226},[212,238,200],{"class":239},"s2Zo4",[212,241,242],{"class":222},"(",[212,244,245],{"class":226},"{",[212,247,249],{"class":248},"swJcz"," reason",[212,251,252],{"class":226},":",[212,254,255],{"class":226}," '",[212,257,259],{"class":258},"sfazB","install",[212,261,262],{"class":226},"'",[212,264,265],{"class":226}," }",[212,267,268],{"class":222},")",[212,270,271],{"class":226},";\n",[212,273,275,277,279,281,284,286,288,290,292,294],{"class":214,"line":274},2,[212,276,219],{"class":218},[212,278,223],{"class":222},[212,280,227],{"class":226},[212,282,283],{"class":222},"alarms",[212,285,227],{"class":226},[212,287,189],{"class":222},[212,289,227],{"class":226},[212,291,200],{"class":239},[212,293,242],{"class":222},[212,295,296],{"class":226},"{\n",[212,298,300,303,305,307,310,312],{"class":214,"line":299},3,[212,301,302],{"class":248},"  name",[212,304,252],{"class":226},[212,306,255],{"class":226},[212,308,309],{"class":258},"alarm-name",[212,311,262],{"class":226},[212,313,314],{"class":226},",\n",[212,316,318,321,323,327],{"class":214,"line":317},4,[212,319,320],{"class":248},"  periodInMinutes",[212,322,252],{"class":226},[212,324,326],{"class":325},"sbssI"," 5",[212,328,314],{"class":226},[212,330,332,335,337,340,342,345,348],{"class":214,"line":331},5,[212,333,334],{"class":248},"  scheduledTime",[212,336,252],{"class":226},[212,338,339],{"class":222}," Date",[212,341,227],{"class":226},[212,343,344],{"class":239},"now",[212,346,347],{"class":222},"()",[212,349,314],{"class":226},[212,351,353,356,358],{"class":214,"line":352},6,[212,354,355],{"class":226},"}",[212,357,268],{"class":222},[212,359,271],{"class":226},[212,361,363,365,367,369,372,374,377,379,381,383,385,388,390,392],{"class":214,"line":362},7,[212,364,219],{"class":218},[212,366,223],{"class":222},[212,368,227],{"class":226},[212,370,371],{"class":222},"tab",[212,373,227],{"class":226},[212,375,376],{"class":222},"onCreated",[212,378,227],{"class":226},[212,380,200],{"class":239},[212,382,242],{"class":222},[212,384,245],{"class":226},[212,386,387],{"class":226}," ...",[212,389,265],{"class":226},[212,391,268],{"class":222},[212,393,271],{"class":226},[395,396,397,398,400],"info",{},"If you await the call to ",[150,399,200],{},", it will wait for all the listener to finish running.",[402,403,404],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":208,"searchDepth":274,"depth":274,"links":406},[],"md",null,{},true,{"title":36,"description":208},"V1Zn8HTbie3-_66G8w905VP2c-E_atUBTSsc5tHFn9o",[414,415],{"title":32,"path":33,"stem":34,"description":208,"children":-1},{"title":40,"path":41,"stem":42,"description":208,"children":-1},1779305976862]