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

Delta Between Two Patch Sets: ext/content.js

Issue 4731979438227456: Issue 1663 - Emulate background page and implement proper message responder (Closed)
Left Patch Set: Properly convert Subscription objects as notification arguments Created Dec. 17, 2014, 10:15 p.m.
Right Patch Set: Using Services.vc Created Dec. 19, 2014, 5:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ext/common.js ('k') | firstRun.js » ('j') | messageResponder.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function(global) 18 (function(global)
19 { 19 {
20 if (!global.ext) 20 if (!global.ext)
21 global.ext = {}; 21 global.ext = {};
22 22
23 var backgroundFrame = document.createElement("iframe"); 23 var backgroundFrame = document.createElement("iframe");
24 backgroundFrame.setAttribute("src", "background.html" + window.location.search ); 24 backgroundFrame.setAttribute("src", "background.html" + window.location.search );
25 backgroundFrame.style.visibility = "hidden"; 25 backgroundFrame.style.display = "none";
Thomas Greiner 2014/12/18 17:32:06 Rather use `backgroundFrame.style.display = "none"
Wladimir Palant 2014/12/18 22:04:44 Right, I forgot that frames will still load despit
26 window.addEventListener("DOMContentLoaded", function() 26 window.addEventListener("DOMContentLoaded", function()
27 { 27 {
28 document.body.appendChild(backgroundFrame); 28 document.body.appendChild(backgroundFrame);
29 }, false); 29 }, false);
30 30
31 var messageQueue = []; 31 var messageQueue = [];
32 var maxMessageId = -1; 32 var maxMessageId = -1;
33 var loadHandler = function(event) 33 var loadHandler = function(event)
34 { 34 {
35 if (event.data.type == "backgroundPageLoaded") 35 if (event.data.type == "backgroundPageLoaded")
(...skipping 28 matching lines...) Expand all
64 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId) 64 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId)
65 { 65 {
66 window.removeEventListener("message", callbackWrapper, false); 66 window.removeEventListener("message", callbackWrapper, false);
67 responseCallback(event.data.payload); 67 responseCallback(event.data.payload);
68 } 68 }
69 }; 69 };
70 window.addEventListener("message", callbackWrapper, false); 70 window.addEventListener("message", callbackWrapper, false);
71 } 71 }
72 } 72 }
73 }; 73 };
74
75 window.addEventListener("unload", function()
Thomas Greiner 2014/12/18 17:32:06 I don't see why an "unload" handler make sense in
Wladimir Palant 2014/12/18 22:04:44 Happens to be good enough for testing, the message
76 {
77 global.ext.backgroundPage.sendMessage({type: "removePage"});
78 }, false);
79 })(this); 74 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld