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

Function instrumentDocWrite

3p/environment.js:63–77  ·  view source on GitHub ↗

* Add instrumentation code to doc.write. * @param {!Window} parent * @param {!Window} win

(parent, win)

Source from the content-addressed store, hash-verified

61 * @param {!Window} win
62 */
63function instrumentDocWrite(parent, win) {
64 const doc = win.document;
65 const {close} = doc;
66 doc.close = function () {
67 parent.ampManageWin = function (win) {
68 manageWin(win);
69 };
70 if (!parent.ampSeen) {
71 // .call does not work in Safari with document.write.
72 doc.write('<script>window.parent.ampManageWin(window)</script>');
73 }
74 doc._close = close;
75 return doc._close();
76 };
77}
78
79/**
80 * Add instrumentation code to iframe's srcdoc.

Callers 1

instrumentIframeWindowFunction · 0.85

Calls 2

manageWinFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected