| Index: lib/crawler.js | 
| diff --git a/lib/crawler.js b/lib/crawler.js | 
| index fae18c76edffa77382910c4ef55a45167635d02b..3445b2f5424fd846e71c3ffe3cb6fe964fc78329 100644 | 
| --- a/lib/crawler.js | 
| +++ b/lib/crawler.js | 
| @@ -20,11 +20,8 @@ function abprequire(module) | 
| return result.exports; | 
| } | 
| -let {Policy} = abprequire("contentPolicy"); | 
| let {RequestNotifier} = abprequire("requestNotifier"); | 
| -let {Utils} = abprequire("utils"); | 
| -let dataForTab = new WeakMap(); | 
| /** | 
| * Creates a pool of tabs and allocates them to tasks on request. | 
| @@ -193,31 +190,6 @@ WindowCloser.prototype = { | 
| }; | 
| /** | 
| - * Retrieves crawler results associated with a particular content window. | 
| - * | 
| - * @param {Window} window | 
| - * Content window to retrieve crawler results for | 
| - * @result {Object} | 
| - * Crawler results or undefined if the window wasn't created by the crawler. | 
| - */ | 
| -function getDataForWindow(window) | 
| -{ | 
| - let topWindow = window.top; | 
| - if (!topWindow.document) | 
| - throw new Error("No document associated with the node's top window"); | 
| - let tabbrowser = Utils.getChromeWindow(topWindow).getBrowser(); | 
| - if (!tabbrowser) | 
| - throw new Error("Unable to get a tabbrowser reference from the window"); | 
| - let browser = tabbrowser.getBrowserForDocument(topWindow.document); | 
| - if (!browser) | 
| - throw new Error("Unable to get browser for the content window"); | 
| - let tab = tabbrowser.getTabForBrowser(browser); | 
| - if (!tab) | 
| - throw new Error("Unable to get tab for the browser"); | 
| - return dataForTab.get(tab); | 
| -}; | 
| - | 
| -/** | 
| * Starts the crawling session. The crawler opens each URL in a tab and stores | 
| * the results. | 
| * | 
| @@ -232,11 +204,6 @@ function getDataForWindow(window) | 
| */ | 
| function run(window, urls, timeout, maxtabs, targetURL, onDone) | 
| { | 
| - let requestNotifier = new RequestNotifier(null, function() {}); | 
| - | 
| - let origProcessNode = Policy.processNode; | 
| - Policy.processNode = processNodeReplacement.bind(null, origProcessNode, requestNotifier); | 
| - | 
| let tabAllocator = new TabAllocator(window.getBrowser(), maxtabs); | 
| let loadListener = new LoadListener(window.getBrowser(), timeout); | 
| let running = 0; | 
| @@ -246,8 +213,6 @@ function run(window, urls, timeout, maxtabs, targetURL, onDone) | 
| running--; | 
| if (running <= 0) | 
| { | 
| - Policy.processNode = origProcessNode; | 
| - requestNotifier.shutdown(); | 
| loadListener.stop(); | 
| windowCloser.stop(); | 
| onDone(); | 
| @@ -294,12 +259,20 @@ exports.run = run; | 
| function* crawl_url(url, tabAllocator, loadListener) | 
| { | 
| let tab = yield tabAllocator.getTab(); | 
| - let result = {url: url}; | 
| - | 
| - dataForTab.set(tab, result); | 
| + let result = {url, requests: []}; | 
| + let requestNotifier; | 
| try | 
| { | 
| result.startTime = Date.now(); | 
| + requestNotifier = new RequestNotifier(tab.linkedBrowser.outerWindowID, | 
| + function(entry, scanComplete) | 
| + { | 
| + if (!entry) | 
| + return; | 
| + let {type: contentType, location, filter} = entry; | 
| + result.requests.push({location, contentType, filter}); | 
| + }); | 
| + | 
| tab.linkedBrowser.loadURI(url, null, null); | 
| [result.channelStatus, result.headers] = yield loadListener.waitForLoad(tab); | 
| result.endTime = Date.now(); | 
| @@ -331,6 +304,8 @@ function* crawl_url(url, tabAllocator, loadListener) | 
| } | 
| finally | 
| { | 
| + if (requestNotifier) | 
| + requestNotifier.shutdown(); | 
| tabAllocator.releaseTab(tab); | 
| } | 
| return result; | 
| @@ -345,63 +320,3 @@ function reportException(e) | 
| Cu.reportError(e); | 
| dump(e + "\n" + stack + "\n"); | 
| } | 
| - | 
| -/** | 
| - * Wrapper for the Policy.processNode() function in ABP. Calls the original | 
| - * function and records all the data. | 
| - * | 
| - * @param {Function} origProcessNode | 
| - * The original processNode function. | 
| - * @param {RequestNotifier} requestNotifier | 
| - * The crawler's RequestNotifier object instance. | 
| - * @param {nsIDOMWindow} wnd | 
| - * @param {nsIDOMElement} node | 
| - * @param {Number} contentType | 
| - * @param {nsIURI} location | 
| - * @param {Boolean} collapse | 
| - * @return {Boolean} | 
| - */ | 
| -function processNodeReplacement(origProcessNode, requestNotifier, wnd, node, contentType, location, collapse) | 
| -{ | 
| - let filters = []; | 
| - let origListener = requestNotifier.listener; | 
| - requestNotifier.listener = function(window, node, entry) | 
| - { | 
| - if (entry.filter) | 
| - filters.push(entry.filter.text); | 
| - }; | 
| - | 
| - /* | 
| - * Call the original processNode. If the original throws, then we will too, so this is outside a try clause. | 
| - */ | 
| - let result; | 
| - try | 
| - { | 
| - result = origProcessNode(wnd, node, contentType, location, collapse); | 
| - } | 
| - finally | 
| - { | 
| - requestNotifier.listener = origListener; | 
| - } | 
| - | 
| - try | 
| - { | 
| - let data = getDataForWindow(wnd); | 
| - if (data) | 
| - { | 
| - if (!("requests" in data)) | 
| - data.requests = []; | 
| - data.requests.push({ | 
| - contentType: contentType, | 
| - location: (contentType == Policy.type.ELEMHIDE ? location.text : location.spec), | 
| - blocked: result != Ci.nsIContentPolicy.ACCEPT, | 
| - filters: filters | 
| - }); | 
| - } | 
| - } | 
| - catch (e) | 
| - { | 
| - reportException(e); | 
| - } | 
| - return result; | 
| -}; |