Skip to content

Commit

Permalink
Firefox: workaround for gorhill#886
Browse files Browse the repository at this point in the history
  • Loading branch information
Deathamns committed Mar 2, 2015
1 parent 4a9e6c2 commit cc47d13
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions platform/firefox/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,14 +1052,7 @@ var httpObserver = {
12: 'object',
14: 'font'
},
lastRequest: {
url: null,
type: null,
tabId: null,
frameId: null,
parentFrameId: null,
openerURL: null
},
lastRequest: [{}, {}],

get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
Expand Down Expand Up @@ -1238,12 +1231,21 @@ var httpObserver = {

// http-on-opening-request

var lastRequest = this.lastRequest;
var lastRequest = this.lastRequest[0];

if ( lastRequest.url !== URI.spec ) {
if ( this.lastRequest[1].url === URI.spec ) {
lastRequest = this.lastRequest[1];
} else {
lastRequest.url = null;
}
}

if ( lastRequest.url === null ) {
lastRequest.type = channel.loadInfo && channel.loadInfo.contentPolicyType || 1;
result = this.handleRequest(channel, URI, {
tabId: vAPI.noTabId,
type: channel.loadInfo && channel.loadInfo.contentPolicyType
type: lastRequest.type
});

if ( result === true ) {
Expand All @@ -1255,14 +1257,10 @@ var httpObserver = {
}

// Carry data for behind-the-scene redirects
channelData = [
channel.loadInfo && channel.loadInfo.contentPolicyType || 1,
vAPI.noTabId,
null,
0,
-1
];
channel.setProperty(this.REQDATAKEY, channelData);
channel.setProperty(
this.REQDATAKEY,
[lastRequest.type, vAPI.noTabId, null, 0, -1]
);
return;
}

Expand Down Expand Up @@ -1311,14 +1309,13 @@ var httpObserver = {

// If request is not handled we may use the data in on-modify-request
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
channelData = [
channel.setProperty(this.REQDATAKEY, [
lastRequest.type,
lastRequest.tabId,
sourceTabId,
lastRequest.frameId,
lastRequest.parentFrameId
];
channel.setProperty(this.REQDATAKEY, channelData);
]);
}
},

Expand Down Expand Up @@ -1385,12 +1382,15 @@ vAPI.net.registerListeners = function() {
var shouldLoadListener = function(e) {
var details = e.data;
var lastRequest = httpObserver.lastRequest;
lastRequest.url = details.url;
lastRequest.type = details.type;
lastRequest.tabId = vAPI.tabs.getTabId(e.target);
lastRequest.frameId = details.frameId;
lastRequest.parentFrameId = details.parentFrameId;
lastRequest.openerURL = details.openerURL;
lastRequest[1] = lastRequest[0];
lastRequest[0] = {
url: details.url,
type: details.type,
tabId: vAPI.tabs.getTabId(e.target),
frameId: details.frameId,
parentFrameId: details.parentFrameId,
openerURL: details.openerURL
};
};

vAPI.messaging.globalMessageManager.addMessageListener(
Expand Down

0 comments on commit cc47d13

Please sign in to comment.