Skip to content

Loading…

Fixing #1149 #1195

Merged
merged 8 commits into from

3 participants

@AlexVallat
Collaborator

This is a fix for #1149, but because it's branched off my master it appears to also contain the changes from #1150 in it. I did try to rebase it to make it clean, but I'm clearly not good enough at git.

So, please either approve or reject #1150 first, then this one ought to just work. I hope.

@chrisaljoudi chrisaljoudi merged commit 6c877ee into chrisaljoudi:master
@AlexVallat AlexVallat deleted the AlexVallat:Fixing_#1149 branch
@gorhill

Not sure... Don't you need to also call hiddenDoc.removeEventListener('DOMContentLoaded', onReady)?

Collaborator

This will be handled by line 63. The code to remove the listener this.removeEventListener(e.type, onReady) is generic enough that it doesn't care which listener on which object onReady is listening to when it is called, it removes it regardless.

That's right, I don't know how I could miss this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2015
  1. @AlexVallat
Commits on Apr 2, 2015
  1. @AlexVallat

    Prevent resetting of block count statistics in the more normal case o…

    AlexVallat committed
    …f onLocationChange occurring before document-element-inserted
Commits on Apr 4, 2015
  1. @AlexVallat
  2. @AlexVallat

    Prevent resetting of block count statistics in the more normal case o…

    AlexVallat committed
    …f onLocationChange occurring before document-element-inserted
  3. @AlexVallat
Commits on Apr 5, 2015
  1. @AlexVallat

    Test-fix for #1149

    AlexVallat committed
  2. @AlexVallat
Commits on Apr 6, 2015
  1. @AlexVallat

    Remove diagnostic logging

    AlexVallat committed
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 1 deletion.
  1. +6 −0 platform/firefox/bootstrap.js
  2. +9 −0 platform/firefox/frameModule.js
  3. +7 −1 platform/firefox/vapi-background.js
View
6 platform/firefox/bootstrap.js
@@ -60,6 +60,12 @@ function startup(data, reason) {
}
let hiddenDoc = appShell.hiddenDOMWindow.document;
+
+ if ( hiddenDoc.readyState === 'loading' ) {
+ hiddenDoc.addEventListener('DOMContentLoaded', onReady);
+ return;
+ }
+
bgProcess = hiddenDoc.documentElement.appendChild(
hiddenDoc.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
);
View
9 platform/firefox/frameModule.js
@@ -293,6 +293,15 @@ const contentObserver = {
let docReady = (e) => {
let doc = e.target;
doc.removeEventListener(e.type, docReady, true);
+
+ // It is possible, in some cases (#1140) for document-element-inserted to occur *before* nsIWebProgressListener.onLocationChange, so ensure that the URL is correct before continuing
+ let messageManager = doc.docShell.getInterface(Ci.nsIContentFrameMessageManager);
+
+ messageManager.sendSyncMessage(locationChangedMessageName, {
+ url: loc.href,
+ noRefresh: true, // If the URL is the same, then don't refresh it so that if this occurs after onLocationChange, no the block count isn't reset
+ });
+
lss(this.contentBaseURI + 'contentscript-end.js', sandbox);
if ( doc.querySelector('a[href^="abp:"]') ) {
View
8 platform/firefox/vapi-background.js
@@ -65,7 +65,7 @@ vAPI.app.restart = function() {
var cleanupTasks = [];
// This must be updated manually, every time a new task is added/removed
-var expectedNumberOfCleanups = 7;
+var expectedNumberOfCleanups = 6; // 7 instances of cleanupTasks.push, but one is unique to fennec, and one to desktop.
window.addEventListener('unload', function() {
for ( var cleanup of cleanupTasks ) {
@@ -1325,6 +1325,12 @@ vAPI.net.registerListeners = function() {
var locationChangedListener = function(e) {
var details = e.data;
var browser = e.target;
+
+ if (details.noRefresh && details.url === browser.currentURI.asciiSpec) { // If the location changed message specified not to refresh, and the URL is the same, no need to do anything
+ //console.debug("nsIWebProgressListener: ignoring onLocationChange: " + details.url);
+ return;
+ }
+
var tabId = vAPI.tabs.getTabId(browser);
if (tabId === vAPI.noTabId) {
return; // Do not navigate for behind the scenes
Something went wrong with that request. Please try again.