-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid doc.write if a 3p frame has already been instrumented #9176
Conversation
Bad ads installing video stream decoding JS. |
@jridgewell why manageWin is not enough and we have to instrumentDocWrite? |
@jridgewell don't quite understand your point. |
It's another defense against badly written code. |
the mystery to me is that we already did
In my local test, I found 1) is necessary, though I don't have explanation. In fact, when I try to debug, it becomes unnecessary. So really want to hear from @cramforce who introduced those hacks :-). What problems were there? |
3p/environment.js
Outdated
@@ -178,13 +142,15 @@ function instrumentEntryPoints(win) { | |||
// Change setTimeout to respect a minimum timeout. | |||
const setTimeout = win.setTimeout; | |||
win.setTimeout = function(fn, time) { | |||
dev().info('SETTIMEOUT', win.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT SUBMIT
?
@lannka Do we know the reason why it breaks anything, however? |
Are we running the code twice on the same window. There is a case of removing all of this code now that browsers throttle themselves more aggressively. |
@dvoytenko as I mentioned in PR description
See that screenshot.
@cramforce No. if (!parent.ampSeen) {
doc.write('<script>window.parent.ampManageWin(window)</script>');
} But I want to understand what corner case this code is trying to handle, can we get rid of them completely? At least the |
That conditional should definitely be added!! There are many ways how iframes are added to ad pages. This is handling one of those cases. Might or might not be needed for doubleclick. |
1e6b102
to
bf1623e
Compare
@cramforce adding the check fixes the issue. this is good for now, let's follow up offline see if we can improve some of the code here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is cool, but the PR description doesn't correctly reflect it.
updated description |
Fixes #9249
@cramforce , do you remember why we had the
instrumentDocWrite
code?doc.write('<script>window.parent.ampManageWin(window)</script>');
is making ads blank.(we might override doc.close too late?)