summaryrefslogtreecommitdiffstats
path: root/toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js')
-rw-r--r--toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js64
1 files changed, 1 insertions, 63 deletions
diff --git a/toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js b/toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js
index 72a7dcbb91..0f2d846627 100644
--- a/toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js
+++ b/toolkit/components/contentanalysis/tests/browser/browser_print_changing_page_content_analysis.js
@@ -12,69 +12,7 @@ const PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
Ci.nsIPrintSettingsService
);
-let mockCA = {
- isActive: true,
- mightBeActive: true,
- errorValue: undefined,
-
- setupForTest(shouldAllowRequest) {
- this.shouldAllowRequest = shouldAllowRequest;
- this.errorValue = undefined;
- this.calls = [];
- },
-
- setupForTestWithError(errorValue) {
- this.errorValue = errorValue;
- this.calls = [];
- },
-
- getAction() {
- if (this.shouldAllowRequest === undefined) {
- this.shouldAllowRequest = true;
- }
- return this.shouldAllowRequest
- ? Ci.nsIContentAnalysisResponse.eAllow
- : Ci.nsIContentAnalysisResponse.eBlock;
- },
-
- // nsIContentAnalysis methods
- async analyzeContentRequest(request, _autoAcknowledge) {
- info(
- "Mock ContentAnalysis service: analyzeContentRequest, this.shouldAllowRequest=" +
- this.shouldAllowRequest +
- ", this.errorValue=" +
- this.errorValue
- );
- this.calls.push(request);
- if (this.errorValue) {
- throw this.errorValue;
- }
- // Use setTimeout to simulate an async activity
- await new Promise(res => setTimeout(res, 0));
- return makeContentAnalysisResponse(this.getAction(), request.requestToken);
- },
-
- analyzeContentRequestCallback(request, autoAcknowledge, callback) {
- info(
- "Mock ContentAnalysis service: analyzeContentRequestCallback, this.shouldAllowRequest=" +
- this.shouldAllowRequest +
- ", this.errorValue=" +
- this.errorValue
- );
- this.calls.push(request);
- if (this.errorValue) {
- throw this.errorValue;
- }
- let response = makeContentAnalysisResponse(
- this.getAction(),
- request.requestToken
- );
- // Use setTimeout to simulate an async activity
- setTimeout(() => {
- callback.contentResult(response);
- }, 0);
- },
-};
+let mockCA = makeMockContentAnalysis();
add_setup(async function test_setup() {
mockCA = mockContentAnalysisService(mockCA);