MCPcopy
hub / github.com/ampproject/amphtml / waitForPageLoad

Function waitForPageLoad

build-system/tasks/visual-diff/verifiers.js:107–124  ·  view source on GitHub ↗

* Wait for all AMP loader indicators to disappear. * * @param {!puppeteer.Page} page page to wait on. * @param {string} testName the full name of the test. * @param {number} timeoutMillis how long to retry. * @return {Promise } * @throws {Error} an encountered error.

(
  page,
  testName,
  timeoutMillis = CSS_SELECTOR_TIMEOUT_MS
)

Source from the content-addressed store, hash-verified

105 * @throws {Error} an encountered error.
106 */
107async function waitForPageLoad(
108 page,
109 testName,
110 timeoutMillis = CSS_SELECTOR_TIMEOUT_MS
111) {
112 const allLoadersGone = await waitForElementVisibility(
113 page,
114 '[class~="i-amphtml-loader"], [class~="i-amphtml-loading"]',
115 {hidden: true},
116 timeoutMillis
117 );
118 if (!allLoadersGone) {
119 throw new Error(
120 `${cyan(testName)} still has the AMP loader dot ` +
121 `after ${CSS_SELECTOR_TIMEOUT_MS} ms`
122 );
123 }
124}
125
126/**
127 * Wait until the element is either hidden or visible or until timed out.

Callers 2

devModeFunction · 0.85
snapshotWebpagesFunction · 0.85

Calls 2

waitForElementVisibilityFunction · 0.85
cyanFunction · 0.85

Tested by

no test coverage detected