Skip to content

IOptionalBrowserSettings

David Ortner edited this page May 29, 2024 · 9 revisions

IOptionalBrowserSettings represents the settings of the browser sent to the constructor.

Signature

interface IOptionalBrowserSettings

Example

import { Browser } from "happy-dom";

const browser = new Browser({
    settings: {
        navigator: : {
           userAgent: "Mozilla/5.0 (X11; Linux x64) AppleWebKit/537.36 (KHTML, like Gecko) HappyDOM/2.0.0"
        }
    }
});

Properties

Property Type Description
disableJavaScriptEvaluation? boolean Disables JavaScript evaluation.
disableJavaScriptFileLoading? boolean Disables JavaScript file loading.
disableCSSFileLoading? boolean Disables CSS file loading.
disableComputedStyleRendering? boolean Disables computed style rendering.
handleDisabledFileLoadingAsSuccess? boolean Set to "true" to trigger a load event instead of an error event when file loading is disabled.
errorCapture? BrowserErrorCaptureEnum Error capturing policy.
navigation.disableMainFrameNavigation? boolean Disables navigation to other pages in the main frame or a page.
navigation.disableChildFrameNavigation? boolean Disables navigation to other pages in child frames (such as iframes).
navigation.disableChildPageNavigation? boolean Disables navigation to other pages in child pages (such as popup windows).
navigation.disableFallbackToSetURL? boolean Disables the fallback to setting the URL when navigating to a page is disabled or when inside a detached browser frame.
navigation.crossOriginPolicy? BrowserNavigationCrossOriginPolicyEnum Sets the policy for cross-origin navigation.
navigator.userAgent? string User agent.
navigator.maxTouchPoints? number Max touch points.
timer.maxTimeout? number Sets the maximum time a timeout is allowed to have. This can improve load times if the environment has long running timers.
timer.maxIntervalTime? number Sets the maximum time an interval is allowed to have. This can improve load times if the environment has long running intervals.
timer.maxIntervalIterations? number Sets the maximum number of interval iterations. This can unblock environments from completing loading.
device.prefersColorScheme? string Prefers color scheme.
device.mediaType? string Media type.
Clone this wiki locally