MCPcopy Index your code
hub / github.com/ampproject/amphtml / getPreconnectIframe

Function getPreconnectIframe

test/unit/test-preconnect.js:28–54  ·  view source on GitHub ↗
(detectFeatures = false)

Source from the content-addressed store, hash-verified

26 const javascriptUrlPrefix = 'javascript';
27
28 function getPreconnectIframe(detectFeatures = false) {
29 return createIframePromise().then((iframe) => {
30 iframeClock = fakeTimers.withGlobal(iframe.win).install();
31 if (detectFeatures) {
32 setPreconnectFeaturesForTesting(null);
33 } else {
34 setPreconnectFeaturesForTesting({
35 preload: preloadSupported,
36 preconnect: preconnectSupported,
37 });
38 }
39
40 const platform = {
41 isSafari: () => !!isSafari,
42 };
43 iframe.win.__AMP_SERVICES['platform'] = {obj: platform, ctor: Object};
44 sandbox.stub(Services, 'platformFor').returns(platform);
45
46 installPreconnectService(iframe.win);
47 preconnect = Services.preconnectFor(iframe.win);
48
49 ampdoc = {
50 whenFirstVisible: () => visiblePromise,
51 };
52 return iframe;
53 });
54 }
55
56 beforeEach(() => {
57 sandbox = env.sandbox;

Callers 1

test-preconnect.jsFile · 0.85

Calls 5

createIframePromiseFunction · 0.90
installPreconnectServiceFunction · 0.90
thenMethod · 0.45
installMethod · 0.45

Tested by

no test coverage detected