LoadURIDelegateChild.sys.mjs (1499B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { GeckoViewActorChild } from "resource://gre/modules/GeckoViewActorChild.sys.mjs"; 6 7 const lazy = {}; 8 9 ChromeUtils.defineESModuleGetters(lazy, { 10 LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.sys.mjs", 11 }); 12 13 // Implements nsILoadURIDelegate. 14 export class LoadURIDelegateChild extends GeckoViewActorChild { 15 // nsILoadURIDelegate. 16 handleLoadError(aUri, aError, aErrorModule) { 17 debug`handleLoadError: uri=${aUri && aUri.spec} 18 displaySpec=${aUri && aUri.displaySpec} 19 error=${aError}`; 20 let errorClass = 0; 21 try { 22 const nssErrorsService = Cc[ 23 "@mozilla.org/nss_errors_service;1" 24 ].getService(Ci.nsINSSErrorsService); 25 errorClass = nssErrorsService.getErrorClass(aError); 26 } catch (e) {} 27 28 const msg = { 29 uri: aUri && aUri.spec, 30 error: aError, 31 errorModule: aErrorModule, 32 errorClass, 33 }; 34 35 let errorPagePromise = this.sendQuery("GeckoView:OnLoadError", msg); 36 37 return lazy.LoadURIDelegate.handleLoadError( 38 this.contentWindow, 39 errorPagePromise 40 ); 41 } 42 } 43 44 LoadURIDelegateChild.prototype.QueryInterface = ChromeUtils.generateQI([ 45 "nsILoadURIDelegate", 46 ]); 47 48 const { debug, warn } = LoadURIDelegateChild.initLogging("LoadURIDelegate");