MCPcopy Create free account
hub / github.com/ampproject/amphtml / blockSyncPopups

Function blockSyncPopups

3p/environment.js:216–240  ·  view source on GitHub ↗

* Blackhole the legacy popups since they should never be used for anything. * @param {!Window} win

(win)

Source from the content-addressed store, hash-verified

214 * @param {!Window} win
215 */
216function blockSyncPopups(win) {
217 let count = 0;
218 /**
219 * Checks for security error.
220 */
221 function maybeThrow() {
222 // Prevent deep recursion.
223 if (count++ > 2) {
224 throw new Error('security error');
225 }
226 }
227 try {
228 win.alert = maybeThrow;
229 win.prompt = function () {
230 maybeThrow();
231 return '';
232 };
233 win.confirm = function () {
234 maybeThrow();
235 return false;
236 };
237 } catch (e) {
238 console./*OK*/ error(e.message, e.stack);
239 }
240}
241
242/**
243 * Calculates the minimum time that a timeout should have right now.

Callers 1

manageWin_Function · 0.85

Calls 2

maybeThrowFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected