Explain why we 'Only push styles to the top-level document' #27

This commit is contained in:
Jason Barnabe 2015-02-17 12:52:32 -06:00
parent 6c24362343
commit e6df389f59

View File

@ -1,7 +1,13 @@
// This happens right away, sometimes so fast that the content script isn't even ready. That's // This happens right away, sometimes so fast that the content script isn't even ready. That's
// why the content script also asks for this stuff. // why the content script also asks for this stuff.
chrome.webNavigation.onCommitted.addListener(function(data) { chrome.webNavigation.onCommitted.addListener(function(data) {
if (data.frameId !== 0) return; // Until Chrome 41, we can't target a frame with a message
// (https://developer.chrome.com/extensions/tabs#method-sendMessage)
// so a style affecting a page with an iframe will affect the main page as well.
// Skip doing this for frames for now, which can result in flicker.
if (data.frameId != 0) {
return;
}
getStyles({matchUrl: data.url, enabled: true, asHash: true}, function(styleHash) { getStyles({matchUrl: data.url, enabled: true, asHash: true}, function(styleHash) {
chrome.tabs.sendMessage(data.tabId, {method: "styleApply", styles: styleHash}); chrome.tabs.sendMessage(data.tabId, {method: "styleApply", styles: styleHash});
// Don't show the badge for frames // Don't show the badge for frames