Merge pull request #12773 from Snuffleupagus/move-sandboxBundleSrc
Pass in the "sandboxBundleSrc" option when calling `DefaultExternalServices.createScripting`
This commit is contained in:
		
						commit
						df53e7811c
					
				@ -167,7 +167,7 @@ class DefaultExternalServices {
 | 
				
			|||||||
    throw new Error("Not implemented: createL10n");
 | 
					    throw new Error("Not implemented: createL10n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static createScripting() {
 | 
					  static createScripting(options) {
 | 
				
			||||||
    throw new Error("Not implemented: createScripting");
 | 
					    throw new Error("Not implemented: createScripting");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1477,7 +1477,12 @@ const PDFViewerApplication = {
 | 
				
			|||||||
    if (pdfDocument !== this.pdfDocument) {
 | 
					    if (pdfDocument !== this.pdfDocument) {
 | 
				
			||||||
      return; // The document was closed while the data resolved.
 | 
					      return; // The document was closed while the data resolved.
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const scripting = this.externalServices.createScripting();
 | 
					    const scripting = this.externalServices.createScripting(
 | 
				
			||||||
 | 
					      typeof PDFJSDev === "undefined" ||
 | 
				
			||||||
 | 
					        PDFJSDev.test("!PRODUCTION || GENERIC || CHROME")
 | 
				
			||||||
 | 
					        ? { sandboxBundleSrc: AppOptions.get("sandboxBundleSrc") }
 | 
				
			||||||
 | 
					        : null
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    // Store a reference to the current scripting-instance, to allow destruction
 | 
					    // Store a reference to the current scripting-instance, to allow destruction
 | 
				
			||||||
    // of the sandbox and removal of the event listeners at document closing.
 | 
					    // of the sandbox and removal of the event listeners at document closing.
 | 
				
			||||||
    const internalEvents = new Map(),
 | 
					    const internalEvents = new Map(),
 | 
				
			||||||
 | 
				
			|||||||
@ -430,8 +430,8 @@ class ChromeExternalServices extends DefaultExternalServices {
 | 
				
			|||||||
    return new GenericL10n(navigator.language);
 | 
					    return new GenericL10n(navigator.language);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static createScripting() {
 | 
					  static createScripting({ sandboxBundleSrc }) {
 | 
				
			||||||
    return new GenericScripting();
 | 
					    return new GenericScripting(sandboxBundleSrc);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
PDFViewerApplication.externalServices = ChromeExternalServices;
 | 
					PDFViewerApplication.externalServices = ChromeExternalServices;
 | 
				
			||||||
 | 
				
			|||||||
@ -366,7 +366,7 @@ class FirefoxExternalServices extends DefaultExternalServices {
 | 
				
			|||||||
    return new MozL10n(mozL10n);
 | 
					    return new MozL10n(mozL10n);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static createScripting() {
 | 
					  static createScripting(options) {
 | 
				
			||||||
    return FirefoxScripting;
 | 
					    return FirefoxScripting;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,13 +13,12 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { AppOptions } from "./app_options.js";
 | 
					 | 
				
			||||||
import { loadScript } from "pdfjs-lib";
 | 
					import { loadScript } from "pdfjs-lib";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GenericScripting {
 | 
					class GenericScripting {
 | 
				
			||||||
  constructor() {
 | 
					  constructor(sandboxBundleSrc) {
 | 
				
			||||||
    this._ready = loadScript(
 | 
					    this._ready = loadScript(
 | 
				
			||||||
      AppOptions.get("sandboxBundleSrc"),
 | 
					      sandboxBundleSrc,
 | 
				
			||||||
      /* removeScriptElement = */ true
 | 
					      /* removeScriptElement = */ true
 | 
				
			||||||
    ).then(() => {
 | 
					    ).then(() => {
 | 
				
			||||||
      return window.pdfjsSandbox.QuickJSSandbox();
 | 
					      return window.pdfjsSandbox.QuickJSSandbox();
 | 
				
			||||||
 | 
				
			|||||||
@ -51,8 +51,8 @@ class GenericExternalServices extends DefaultExternalServices {
 | 
				
			|||||||
    return new GenericL10n(locale);
 | 
					    return new GenericL10n(locale);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static createScripting() {
 | 
					  static createScripting({ sandboxBundleSrc }) {
 | 
				
			||||||
    return new GenericScripting();
 | 
					    return new GenericScripting(sandboxBundleSrc);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
PDFViewerApplication.externalServices = GenericExternalServices;
 | 
					PDFViewerApplication.externalServices = GenericExternalServices;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user