mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 21:58:41 +02:00
A new function Classifier::AsyncApplyUpdates() is implemented for async update. Besides, all public Classifier interfaces become "worker thread only" and we remove DBServiceWorker::ApplyUpdatesBackground/Foreground. In DBServiceWorker::FinishUpdate, instead of calling Classifier::ApplyUpdates, we call Classifier::AsyncApplyUpdates and install a callback for notifying the update observer when update is finished. The callback will occur on the caller thread (i.e. worker thread.) As for the shutdown issue, when the main thread is notified to shut down, we at first *synchronously* dispatch an event to the worker thread to shut down the update thread. After getting synchronized with all other threads, we send last two events "CancelUpdate" and "CloseDb" to notify dangling update (i.e. BeginUpdate is called but FinishUpdate isn't) and do cleanup work. MozReview-Commit-ID: DXZvA2eFKlc --HG-- extra : rebase_source : cd2e27a6b679d2c96e769854d1582ed2dcda12bb
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
const { classes: Cc, interfaces: Ci, results: Cr } = Components;
|
|
|
|
const SECURE_CONTAINER_URL = "https://example.com/browser/browser/components/safebrowsing/content/test/empty_file.html";
|
|
|
|
add_task(function* testNormalBrowsing() {
|
|
yield BrowserTestUtils.withNewTab(SECURE_CONTAINER_URL, function* (browser) {
|
|
// Before we load the phish url, we have to make sure the hard-coded
|
|
// black list has been added to the database.
|
|
yield new Promise(resolve => waitForDBInit(resolve));
|
|
|
|
yield ContentTask.spawn(browser, PHISH_URL, function* (aPhishUrl) {
|
|
return new Promise(resolve => {
|
|
// Register listener before loading phish URL.
|
|
let listener = e => {
|
|
removeEventListener("AboutBlockedLoaded", listener, false, true);
|
|
resolve();
|
|
};
|
|
addEventListener("AboutBlockedLoaded", listener, false, true);
|
|
|
|
// Create an iframe which is going to load a phish url.
|
|
let iframe = content.document.createElement("iframe");
|
|
iframe.src = aPhishUrl;
|
|
content.document.body.appendChild(iframe);
|
|
});
|
|
});
|
|
|
|
ok(true, "about:blocked is successfully loaded!");
|
|
});
|
|
});
|