summaryrefslogtreecommitdiffstats
path: root/toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js')
-rw-r--r--toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js68
1 files changed, 1 insertions, 67 deletions
diff --git a/toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js b/toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js
index 9b4c0ffa60..05897b5ca6 100644
--- a/toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js
+++ b/toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js
@@ -12,73 +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 = [];
- },
-
- clearCalls() {
- 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);