Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include.preload.js

Issue 29436567: Issue 3200 - Delay initialization for prerendered documents (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Delay composer.ready until document is visible Created May 12, 2017, 1:30 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 }); 578 });
579 } 579 }
580 }; 580 };
581 581
582 if (document instanceof HTMLDocument) 582 if (document instanceof HTMLDocument)
583 { 583 {
584 checkSitekey(); 584 checkSitekey();
585 wrapWebSocket(); 585 wrapWebSocket();
586 586
587 var elemhide = new ElemHide(); 587 var elemhide = new ElemHide();
588 elemhide.apply(); 588
589 if (document.visibilityState == "prerender")
590 {
591 // For prerendered documents, wait until the document is made visible. We
592 // do not have access to the page property of the SafariBrowserTab object
593 // associated with this document until it is visible. Without the page
594 // property, we cannot get a response from the background page.
595 document.addEventListener("visibilitychange", function onVisibilitychange()
596 {
597 document.removeEventListener("visibilitychange", onVisibilitychange);
598
599 elemhide.apply();
600 });
601 }
602 else
603 {
604 elemhide.apply();
605 }
589 606
590 document.addEventListener("error", function(event) 607 document.addEventListener("error", function(event)
591 { 608 {
592 checkCollapse(event.target); 609 checkCollapse(event.target);
593 }, true); 610 }, true);
594 611
595 document.addEventListener("load", function(event) 612 document.addEventListener("load", function(event)
596 { 613 {
597 var element = event.target; 614 var element = event.target;
598 if (/^i?frame$/.test(element.localName)) 615 if (/^i?frame$/.test(element.localName))
599 checkCollapse(element); 616 checkCollapse(element);
600 }, true); 617 }, true);
601 } 618 }
OLDNEW

Powered by Google App Engine
This is Rietveld