From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../browser/browser_print_content_analysis.js | 68 +--------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'toolkit/components/contentanalysis/tests/browser/browser_print_content_analysis.js') 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); -- cgit v1.2.3