[Web Animations] Expose Web Animations CSS integration as an experimental feature
[WebKit-https.git] / Source / WebCore / testing / InternalSettings.cpp
index 15df798..24e4aae 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "InternalSettings.h"
 
-#include "Chrome.h"
-#include "ChromeClient.h"
+#include "CaptionUserPreferences.h"
+#include "DeprecatedGlobalSettings.h"
 #include "Document.h"
-#include "ExceptionCode.h"
+#include "FontCache.h"
 #include "Frame.h"
 #include "FrameView.h"
-#include "Language.h"
 #include "LocaleToScriptMapping.h"
-#include "MockPagePopupDriver.h"
 #include "Page.h"
+#include "PageGroup.h"
+#include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
-#include "TextRun.h"
+#include "Supplementable.h"
+#include <wtf/Language.h>
 
 #if ENABLE(INPUT_TYPE_COLOR)
 #include "ColorChooser.h"
 #endif
 
-#define InternalSettingsGuardForSettingsReturn(returnValue) \
-    if (!settings()) { \
-        ec = INVALID_ACCESS_ERR; \
-        return returnValue; \
-    }
-
-#define InternalSettingsGuardForSettings()  \
-    if (!settings()) { \
-        ec = INVALID_ACCESS_ERR; \
-        return; \
-    }
-
-#define InternalSettingsGuardForPage() \
-    if (!page()) { \
-        ec = INVALID_ACCESS_ERR; \
-        return; \
-    }
+#if USE(SOUP)
+#include "SoupNetworkSession.h"
+#endif
 
 namespace WebCore {
 
-InternalSettings::Backup::Backup(Page* page, Settings* settings)
-    : m_originalPasswordEchoDurationInSeconds(settings->passwordEchoDurationInSeconds())
-    , m_originalPasswordEchoEnabled(settings->passwordEchoEnabled())
-    , m_originalCSSExclusionsEnabled(RuntimeEnabledFeatures::cssExclusionsEnabled())
-#if ENABLE(SHADOW_DOM)
-    , m_originalShadowDOMEnabled(RuntimeEnabledFeatures::shadowDOMEnabled())
-    , m_originalAuthorShadowDOMForAnyElementEnabled(RuntimeEnabledFeatures::authorShadowDOMForAnyElementEnabled())
-#endif
-#if ENABLE(STYLE_SCOPED)
-    , m_originalStyleScoped(RuntimeEnabledFeatures::styleScopedEnabled())
-#endif
-    , m_originalEditingBehavior(settings->editingBehaviorType())
-    , m_originalUnifiedSpellCheckerEnabled(settings->unifiedTextCheckerEnabled())
-    , m_originalFixedPositionCreatesStackingContext(settings->fixedPositionCreatesStackingContext())
-    , m_originalSyncXHRInDocumentsEnabled(settings->syncXHRInDocumentsEnabled())
-    , m_originalWindowFocusRestricted(settings->windowFocusRestricted())
-    , m_originalDeviceSupportsTouch(settings->deviceSupportsTouch())
-    , m_originalDeviceSupportsMouse(settings->deviceSupportsMouse())
+InternalSettings::Backup::Backup(Settings& settings)
+    : m_originalEditingBehavior(settings.editingBehaviorType())
 #if ENABLE(TEXT_AUTOSIZING)
-    , m_originalTextAutosizingEnabled(settings->textAutosizingEnabled())
-    , m_originalTextAutosizingWindowSizeOverride(settings->textAutosizingWindowSizeOverride())
-    , m_originalTextAutosizingFontScaleFactor(settings->textAutosizingFontScaleFactor())
-#endif
-    , m_originalResolutionOverride(settings->resolutionOverride())
-    , m_originalMediaTypeOverride(settings->mediaTypeOverride())
-#if ENABLE(DIALOG_ELEMENT)
-    , m_originalDialogElementEnabled(RuntimeEnabledFeatures::dialogElementEnabled())
-#endif
-    , m_canStartMedia(page->canStartMedia())
-    , m_originalMockScrollbarsEnabled(settings->mockScrollbarsEnabled())
-    , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
-    , m_imagesEnabled(settings->areImagesEnabled())
+    , m_originalTextAutosizingEnabled(settings.textAutosizingEnabled())
+    , m_originalTextAutosizingWindowSizeOverride(settings.textAutosizingWindowSizeOverride())
+#endif
+    , m_originalMediaTypeOverride(settings.mediaTypeOverride())
+    , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
+    , m_originalMockScrollbarsEnabled(DeprecatedGlobalSettings::mockScrollbarsEnabled())
+    , m_imagesEnabled(settings.areImagesEnabled())
+    , m_preferMIMETypeForImages(settings.preferMIMETypeForImages())
+    , m_minimumDOMTimerInterval(settings.minimumDOMTimerInterval())
 #if ENABLE(VIDEO_TRACK)
-    , m_shouldDisplaySubtitles(settings->shouldDisplaySubtitles())
-    , m_shouldDisplayCaptions(settings->shouldDisplayCaptions())
-    , m_shouldDisplayTextDescriptions(settings->shouldDisplayTextDescriptions())
+    , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
+    , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
+    , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
+#endif
+    , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
+    , m_forcePendingWebGLPolicy(settings.isForcePendingWebGLPolicy())
+    , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
+    , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
+    , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
+    , m_quickTimePluginReplacementEnabled(settings.quickTimePluginReplacementEnabled())
+    , m_youTubeFlashPluginReplacementEnabled(settings.youTubeFlashPluginReplacementEnabled())
+    , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
+    , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
+    , m_shouldIgnoreFontLoadCompletions(settings.shouldIgnoreFontLoadCompletions())
+    , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
+    , m_storageBlockingPolicy(settings.storageBlockingPolicy())
+    , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
+#if ENABLE(TOUCH_EVENTS)
+    , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
+#endif
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
+#endif
+    , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
+    , m_allowsInlineMediaPlaybackAfterFullscreen(settings.allowsInlineMediaPlaybackAfterFullscreen())
+    , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
+    , m_deferredCSSParserEnabled(settings.deferredCSSParserEnabled())
+    , m_inputEventsEnabled(settings.inputEventsEnabled())
+#if ENABLE(ACCESSIBILITY_EVENTS)
+    , m_accessibilityEventsEnabled(settings.accessibilityEventsEnabled())
 #endif
+    , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
+    , m_systemLayoutDirection(settings.systemLayoutDirection())
+    , m_pdfImageCachingPolicy(settings.pdfImageCachingPolicy())
+    , m_forcedColorsAreInvertedAccessibilityValue(settings.forcedColorsAreInvertedAccessibilityValue())
+    , m_forcedDisplayIsMonochromeAccessibilityValue(settings.forcedDisplayIsMonochromeAccessibilityValue())
+    , m_forcedPrefersReducedMotionAccessibilityValue(settings.forcedPrefersReducedMotionAccessibilityValue())
+    , m_fontLoadTimingOverride(settings.fontLoadTimingOverride())
+    , m_frameFlattening(settings.frameFlattening())
+#if ENABLE(INDEXED_DATABASE_IN_WORKERS)
+    , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
+#endif
+#if ENABLE(WEBGL2)
+    , m_webGL2Enabled(RuntimeEnabledFeatures::sharedFeatures().webGL2Enabled())
+#endif
+#if ENABLE(WEBGPU)
+    , m_webGPUEnabled(RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())
+#endif
+    , m_webVREnabled(RuntimeEnabledFeatures::sharedFeatures().webVREnabled())
+#if ENABLE(MEDIA_STREAM)
+    , m_setScreenCaptureEnabled(RuntimeEnabledFeatures::sharedFeatures().screenCaptureEnabled())
+#endif
+    , m_shouldMockBoldSystemFontForAccessibility(RenderTheme::singleton().shouldMockBoldSystemFontForAccessibility())
+#if USE(AUDIO_SESSION)
+    , m_shouldManageAudioSessionCategory(DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
+#endif
+    , m_customPasteboardDataEnabled(RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled())
+    , m_promptForStorageAccessAPIEnabled(RuntimeEnabledFeatures::sharedFeatures().storageAccessPromptsEnabled())
 {
 }
 
-
-void InternalSettings::Backup::restoreTo(Page* page, Settings* settings)
+void InternalSettings::Backup::restoreTo(Settings& settings)
 {
-    settings->setPasswordEchoDurationInSeconds(m_originalPasswordEchoDurationInSeconds);
-    settings->setPasswordEchoEnabled(m_originalPasswordEchoEnabled);
-    RuntimeEnabledFeatures::setCSSExclusionsEnabled(m_originalCSSExclusionsEnabled);
-#if ENABLE(SHADOW_DOM)
-    RuntimeEnabledFeatures::setShadowDOMEnabled(m_originalShadowDOMEnabled);
-    RuntimeEnabledFeatures::setAuthorShadowDOMForAnyElementEnabled(m_originalAuthorShadowDOMForAnyElementEnabled);
-#endif
-#if ENABLE(STYLE_SCOPED)
-    RuntimeEnabledFeatures::setStyleScopedEnabled(m_originalStyleScoped);
-#endif
-    settings->setEditingBehaviorType(m_originalEditingBehavior);
-    settings->setUnifiedTextCheckerEnabled(m_originalUnifiedSpellCheckerEnabled);
-    settings->setFixedPositionCreatesStackingContext(m_originalFixedPositionCreatesStackingContext);
-    settings->setSyncXHRInDocumentsEnabled(m_originalSyncXHRInDocumentsEnabled);
-    settings->setWindowFocusRestricted(m_originalWindowFocusRestricted);
-    settings->setDeviceSupportsTouch(m_originalDeviceSupportsTouch);
-    settings->setDeviceSupportsMouse(m_originalDeviceSupportsMouse);
+    settings.setEditingBehaviorType(m_originalEditingBehavior);
+
+    for (const auto& standardFont : m_standardFontFamilies)
+        settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
+    m_standardFontFamilies.clear();
+
+    for (const auto& fixedFont : m_fixedFontFamilies)
+        settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
+    m_fixedFontFamilies.clear();
+
+    for (const auto& serifFont : m_serifFontFamilies)
+        settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
+    m_serifFontFamilies.clear();
+
+    for (const auto& sansSerifFont : m_sansSerifFontFamilies)
+        settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
+    m_sansSerifFontFamilies.clear();
+
+    for (const auto& cursiveFont : m_cursiveFontFamilies)
+        settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
+    m_cursiveFontFamilies.clear();
+
+    for (const auto& fantasyFont : m_fantasyFontFamilies)
+        settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
+    m_fantasyFontFamilies.clear();
+
+    for (const auto& pictographFont : m_pictographFontFamilies)
+        settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
+    m_pictographFontFamilies.clear();
+
 #if ENABLE(TEXT_AUTOSIZING)
-    settings->setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
-    settings->setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
-    settings->setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
-#endif
-    settings->setResolutionOverride(m_originalResolutionOverride);
-    settings->setMediaTypeOverride(m_originalMediaTypeOverride);
-#if ENABLE(DIALOG_ELEMENT)
-    RuntimeEnabledFeatures::setDialogElementEnabled(m_originalDialogElementEnabled);
-#endif
-    page->setCanStartMedia(m_canStartMedia);
-    settings->setMockScrollbarsEnabled(m_originalMockScrollbarsEnabled);
-    RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
-    settings->setImagesEnabled(m_imagesEnabled);
+    settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
+    settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
+#endif
+    settings.setMediaTypeOverride(m_originalMediaTypeOverride);
+    settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
+    settings.setImagesEnabled(m_imagesEnabled);
+    settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
+    settings.setMinimumDOMTimerInterval(m_minimumDOMTimerInterval);
 #if ENABLE(VIDEO_TRACK)
-    settings->setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
-    settings->setShouldDisplayCaptions(m_shouldDisplayCaptions);
-    settings->setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
+    settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
+    settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
+    settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
+#endif
+    settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
+    settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
+    settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
+    settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
+    settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
+    settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
+    settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
+    settings.setShouldIgnoreFontLoadCompletions(m_shouldIgnoreFontLoadCompletions);
+    settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
+    settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
+    settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
+#if ENABLE(TOUCH_EVENTS)
+    settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
+#endif
+    settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
+    settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
+    settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
+    settings.setQuickTimePluginReplacementEnabled(m_quickTimePluginReplacementEnabled);
+    settings.setYouTubeFlashPluginReplacementEnabled(m_youTubeFlashPluginReplacementEnabled);
+    settings.setDeferredCSSParserEnabled(m_deferredCSSParserEnabled);
+    settings.setInputEventsEnabled(m_inputEventsEnabled);
+    settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
+    settings.setSystemLayoutDirection(m_systemLayoutDirection);
+    settings.setPdfImageCachingPolicy(m_pdfImageCachingPolicy);
+    settings.setForcedColorsAreInvertedAccessibilityValue(m_forcedColorsAreInvertedAccessibilityValue);
+    settings.setForcedDisplayIsMonochromeAccessibilityValue(m_forcedDisplayIsMonochromeAccessibilityValue);
+    settings.setForcedPrefersReducedMotionAccessibilityValue(m_forcedPrefersReducedMotionAccessibilityValue);
+    settings.setFontLoadTimingOverride(m_fontLoadTimingOverride);
+    DeprecatedGlobalSettings::setAllowsAnySSLCertificate(false);
+    RenderTheme::singleton().setShouldMockBoldSystemFontForAccessibility(m_shouldMockBoldSystemFontForAccessibility);
+    FontCache::singleton().setShouldMockBoldSystemFontForAccessibility(m_shouldMockBoldSystemFontForAccessibility);
+    settings.setFrameFlattening(m_frameFlattening);
+#if ENABLE(ACCESSIBILITY_EVENTS)
+    settings.setAccessibilityEventsEnabled(m_accessibilityEventsEnabled);
+#endif
+
+#if ENABLE(INDEXED_DATABASE_IN_WORKERS)
+    RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
 #endif
+#if ENABLE(WEBGL2)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(m_webGL2Enabled);
+#endif
+#if ENABLE(WEBGPU)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGPUEnabled(m_webGPUEnabled);
+#endif
+    RuntimeEnabledFeatures::sharedFeatures().setWebVREnabled(m_webVREnabled);
+#if ENABLE(MEDIA_STREAM)
+    RuntimeEnabledFeatures::sharedFeatures().setScreenCaptureEnabled(m_setScreenCaptureEnabled);
+#endif
+    RuntimeEnabledFeatures::sharedFeatures().setCustomPasteboardDataEnabled(m_customPasteboardDataEnabled);
+
+#if USE(AUDIO_SESSION)
+    DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(m_shouldManageAudioSessionCategory);
+#endif
+
+    RuntimeEnabledFeatures::sharedFeatures().setStorageAccessPromptsEnabled(m_promptForStorageAccessAPIEnabled);
+}
+
+class InternalSettingsWrapper : public Supplement<Page> {
+public:
+    explicit InternalSettingsWrapper(Page* page)
+        : m_internalSettings(InternalSettings::create(page)) { }
+    virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
+#if !ASSERT_DISABLED
+    bool isRefCountedWrapper() const override { return true; }
+#endif
+    InternalSettings* internalSettings() const { return m_internalSettings.get(); }
+
+private:
+    RefPtr<InternalSettings> m_internalSettings;
+};
+
+const char* InternalSettings::supplementName()
+{
+    return "InternalSettings";
 }
 
 InternalSettings* InternalSettings::from(Page* page)
 {
-    DEFINE_STATIC_LOCAL(AtomicString, name, ("InternalSettings"));
-    if (!SuperType::from(page, name))
-        SuperType::provideTo(page, name, adoptRef(new InternalSettings(page)));
-    return static_cast<InternalSettings*>(SuperType::from(page, name));
+    if (!Supplement<Page>::from(page, supplementName()))
+        Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
+    return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
 }
 
-InternalSettings::~InternalSettings()
+void InternalSettings::hostDestroyed()
 {
+    m_page = nullptr;
 }
 
 InternalSettings::InternalSettings(Page* page)
-    : m_page(page)
-    , m_backup(page, page->settings())
+    : InternalSettingsGenerated(page)
+    , m_page(page)
+    , m_backup(page->settings())
 {
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    setAllowsAirPlayForMediaPlayback(false);
+#endif
+#if ENABLE(MEDIA_STREAM)
+    setMediaCaptureRequiresSecureConnection(false);
+#endif
 }
 
-#if ENABLE(PAGE_POPUP)
-PagePopupController* InternalSettings::pagePopupController()
+Ref<InternalSettings> InternalSettings::create(Page* page)
 {
-    return m_pagePopupDriver ? m_pagePopupDriver->pagePopupController() : 0;
+    return adoptRef(*new InternalSettings(page));
 }
-#endif
 
-void InternalSettings::reset()
+void InternalSettings::resetToConsistentState()
 {
-    TextRun::setAllowsRoundingHacks(false);
-    setUserPreferredLanguages(Vector<String>());
-    page()->setPagination(Pagination());
-    page()->setPageScaleFactor(1, IntPoint(0, 0));
-    setUsesOverlayScrollbars(false);
-#if ENABLE(PAGE_POPUP)
-    m_pagePopupDriver.clear();
-    if (page()->chrome())
-        page()->chrome()->client()->resetPagePopupDriver();
+    m_page->setPageScaleFactor(1, { 0, 0 });
+    m_page->mainFrame().setPageAndTextZoomFactors(1, 1);
+    m_page->setCanStartMedia(true);
+
+    settings().setForcePendingWebGLPolicy(false);
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    settings().setAllowsAirPlayForMediaPlayback(false);
+#endif
+#if ENABLE(MEDIA_STREAM)
+    setMediaCaptureRequiresSecureConnection(false);
 #endif
 
-    m_backup.restoreTo(page(), settings());
-    m_backup = Backup(page(), settings());
-}
+    m_backup.restoreTo(settings());
+    m_backup = Backup { settings() };
 
-Settings* InternalSettings::settings() const
-{
-    if (!page())
-        return 0;
-    return page()->settings();
+    InternalSettingsGenerated::resetToConsistentState();
 }
 
-void InternalSettings::setForceCompositingMode(bool enabled, ExceptionCode& ec)
+Settings& InternalSettings::settings() const
 {
-    InternalSettingsGuardForSettings();
-    settings()->setForceCompositingMode(enabled);
+    ASSERT(m_page);
+    return m_page->settings();
 }
 
-void InternalSettings::setAcceleratedFiltersEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setTouchEventEmulationEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setAcceleratedFiltersEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(TOUCH_EVENTS)
+    settings().setTouchEventEmulationEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+    return { };
 }
 
-void InternalSettings::setEnableCompositingForFixedPosition(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setStandardFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setAcceleratedCompositingForFixedPositionEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_standardFontFamilies.add(code, settings().standardFontFamily(code));
+    settings().setStandardFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setEnableCompositingForScrollableFrames(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setSerifFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setAcceleratedCompositingForScrollableFramesEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_serifFontFamilies.add(code, settings().serifFontFamily(code));
+    settings().setSerifFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setAcceleratedDrawingEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setSansSerifFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setAcceleratedDrawingEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_sansSerifFontFamilies.add(code, settings().sansSerifFontFamily(code));
+    settings().setSansSerifFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setFixedFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setMockScrollbarsEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_fixedFontFamilies.add(code, settings().fixedFontFamily(code));
+    settings().setFixedFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setUsesOverlayScrollbars(bool flag)
+ExceptionOr<void> InternalSettings::setCursiveFontFamily(const String& family, const String& script)
 {
-    settings()->setUsesOverlayScrollbars(flag);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_cursiveFontFamilies.add(code, settings().cursiveFontFamily(code));
+    settings().setCursiveFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setPasswordEchoEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setFantasyFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setPasswordEchoEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_fantasyFontFamilies.add(code, settings().fantasyFontFamily(code));
+    settings().setFantasyFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setPasswordEchoDurationInSeconds(double durationInSeconds, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setPictographFontFamily(const String& family, const String& script)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setPasswordEchoDurationInSeconds(durationInSeconds);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    UScriptCode code = scriptNameToCode(script);
+    if (code == USCRIPT_INVALID_CODE)
+        return { };
+    m_backup.m_pictographFontFamilies.add(code, settings().pictographFontFamily(code));
+    settings().setPictographFontFamily(family, code);
+    return { };
 }
 
-void InternalSettings::setFixedElementsLayoutRelativeToFrame(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setTextAutosizingEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setFixedElementsLayoutRelativeToFrame(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(TEXT_AUTOSIZING)
+    settings().setTextAutosizingEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+    return { };
 }
 
-void InternalSettings::setUnifiedTextCheckingEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setUnifiedTextCheckerEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(TEXT_AUTOSIZING)
+    settings().setTextAutosizingWindowSizeOverride(IntSize(width, height));
+#else
+    UNUSED_PARAM(width);
+    UNUSED_PARAM(height);
+#endif
+    return { };
 }
 
-bool InternalSettings::unifiedTextCheckingEnabled(ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setMediaTypeOverride(const String& mediaType)
 {
-    InternalSettingsGuardForSettingsReturn(false);
-    return settings()->unifiedTextCheckerEnabled();
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setMediaTypeOverride(mediaType);
+    return { };
 }
 
-void InternalSettings::setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setCanStartMedia(bool enabled)
 {
-    InternalSettingsGuardForPage();
-    page()->setPageScaleFactor(scaleFactor, IntPoint(x, y));
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    m_page->setCanStartMedia(enabled);
+    return { };
 }
 
-void InternalSettings::setShadowDOMEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAllowsAirPlayForMediaPlayback(bool allows)
 {
-#if ENABLE(SHADOW_DOM)
-    UNUSED_PARAM(ec);
-    RuntimeEnabledFeatures::setShadowDOMEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    settings().setAllowsAirPlayForMediaPlayback(allows);
 #else
-    // Even SHADOW_DOM is off, InternalSettings allows setShadowDOMEnabled(false) to
-    // have broader test coverage. But it cannot be setShadowDOMEnabled(true).
-    if (enabled)
-        ec = INVALID_ACCESS_ERR;
+    UNUSED_PARAM(allows);
 #endif
+    return { };
 }
 
-void InternalSettings::setAuthorShadowDOMForAnyElementEnabled(bool isEnabled)
+ExceptionOr<void> InternalSettings::setMediaCaptureRequiresSecureConnection(bool requires)
 {
-#if ENABLE(SHADOW_DOM)
-    RuntimeEnabledFeatures::setAuthorShadowDOMForAnyElementEnabled(isEnabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(MEDIA_STREAM)
+    DeprecatedGlobalSettings::setMediaCaptureRequiresSecureConnection(requires);
 #else
-    UNUSED_PARAM(isEnabled);
+    UNUSED_PARAM(requires);
 #endif
+    return { };
+}
+
+ExceptionOr<void> InternalSettings::setEditingBehavior(const String& editingBehavior)
+{
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
+        settings().setEditingBehaviorType(EditingWindowsBehavior);
+    else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
+        settings().setEditingBehaviorType(EditingMacBehavior);
+    else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
+        settings().setEditingBehaviorType(EditingUnixBehavior);
+    else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
+        settings().setEditingBehaviorType(EditingIOSBehavior);
+    else
+        return Exception { SyntaxError };
+    return { };
 }
 
-void InternalSettings::setStyleScopedEnabled(bool enabled)
+ExceptionOr<void> InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled)
 {
-#if ENABLE(STYLE_SCOPED)
-    RuntimeEnabledFeatures::setStyleScopedEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(VIDEO_TRACK)
+    auto& captionPreferences = m_page->group().captionPreferences();
+    if (equalLettersIgnoringASCIICase(kind, "subtitles"))
+        captionPreferences.setUserPrefersSubtitles(enabled);
+    else if (equalLettersIgnoringASCIICase(kind, "captions"))
+        captionPreferences.setUserPrefersCaptions(enabled);
+    else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
+        captionPreferences.setUserPrefersTextDescriptions(enabled);
+    else
+        return Exception { SyntaxError };
 #else
+    UNUSED_PARAM(kind);
     UNUSED_PARAM(enabled);
 #endif
+    return { };
 }
 
-void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<bool> InternalSettings::shouldDisplayTrackKind(const String& kind)
 {
-#if ENABLE(TOUCH_EVENTS)
-    InternalSettingsGuardForSettings();
-    settings()->setTouchEventEmulationEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(VIDEO_TRACK)
+    auto& captionPreferences = m_page->group().captionPreferences();
+    if (equalLettersIgnoringASCIICase(kind, "subtitles"))
+        return captionPreferences.userPrefersSubtitles();
+    if (equalLettersIgnoringASCIICase(kind, "captions"))
+        return captionPreferences.userPrefersCaptions();
+    if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
+        return captionPreferences.userPrefersTextDescriptions();
+
+    return Exception { SyntaxError };
 #else
-    UNUSED_PARAM(enabled);
-    UNUSED_PARAM(ec);
+    UNUSED_PARAM(kind);
+    return false;
 #endif
 }
 
-void InternalSettings::setDeviceSupportsTouch(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setStorageBlockingPolicy(const String& mode)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setDeviceSupportsTouch(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    if (mode == "AllowAll")
+        settings().setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
+    else if (mode == "BlockThirdParty")
+        settings().setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
+    else if (mode == "BlockAll")
+        settings().setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
+    else
+        return Exception { SyntaxError };
+    return { };
 }
 
-void InternalSettings::setDeviceSupportsMouse(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setPreferMIMETypeForImages(bool preferMIMETypeForImages)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setDeviceSupportsMouse(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setPreferMIMETypeForImages(preferMIMETypeForImages);
+    return { };
 }
 
-typedef void (Settings::*SetFontFamilyFunction)(const AtomicString&, UScriptCode);
-static void setFontFamily(Settings* settings, const String& family, const String& script, SetFontFamilyFunction setter)
+ExceptionOr<void> InternalSettings::setImagesEnabled(bool enabled)
 {
-    UScriptCode code = scriptNameToCode(script);
-    if (code != USCRIPT_INVALID_CODE)
-        (settings->*setter)(family, code);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setImagesEnabled(enabled);
+    return { };
 }
 
-void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setPDFImageCachingPolicy(const String& policy)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setStandardFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    if (equalLettersIgnoringASCIICase(policy, "disabled"))
+        settings().setPdfImageCachingPolicy(PDFImageCachingDisabled);
+    else if (equalLettersIgnoringASCIICase(policy, "belowmemorylimit"))
+        settings().setPdfImageCachingPolicy(PDFImageCachingBelowMemoryLimit);
+    else if (equalLettersIgnoringASCIICase(policy, "clipboundsonly"))
+        settings().setPdfImageCachingPolicy(PDFImageCachingClipBoundsOnly);
+    else if (equalLettersIgnoringASCIICase(policy, "enabled"))
+        settings().setPdfImageCachingPolicy(PDFImageCachingEnabled);
+    else
+        return Exception { SyntaxError };
+    return { };
 }
 
-void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setMinimumTimerInterval(double intervalInSeconds)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setSerifFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setMinimumDOMTimerInterval(Seconds { intervalInSeconds });
+    return { };
 }
 
-void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setDefaultVideoPosterURL(const String& url)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setSansSerifFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setDefaultVideoPosterURL(url);
+    return { };
 }
 
-void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setForcePendingWebGLPolicy(bool forced)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setFixedFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setForcePendingWebGLPolicy(forced);
+    return { };
 }
 
-void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setCursiveFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setTimeWithoutMouseMovementBeforeHidingControls(Seconds { time });
+    return { };
 }
 
-void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setFantasyFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setUseLegacyBackgroundSizeShorthandBehavior(enabled);
+    return { };
 }
 
-void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    setFontFamily(settings(), family, script, &Settings::setPictographFontFamily);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setAutoscrollForDragAndDropEnabled(enabled);
+    return { };
 }
 
-void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs)
 {
-#if ENABLE(TEXT_AUTOSIZING)
-    InternalSettingsGuardForSettings();
-    settings()->setTextAutosizingEnabled(enabled);
-#else
-    UNUSED_PARAM(enabled);
-    UNUSED_PARAM(ec);
-#endif
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setFontFallbackPrefersPictographs(preferPictographs);
+    return { };
 }
 
-void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setFontLoadTimingOverride(const FontLoadTimingOverride& fontLoadTimingOverride)
 {
-#if ENABLE(TEXT_AUTOSIZING)
-    InternalSettingsGuardForSettings();
-    settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
-#else
-    UNUSED_PARAM(width);
-    UNUSED_PARAM(height);
-    UNUSED_PARAM(ec);
-#endif
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    auto policy = Settings::FontLoadTimingOverride::None;
+    switch (fontLoadTimingOverride) {
+    case FontLoadTimingOverride::Block:
+        policy = Settings::FontLoadTimingOverride::Block;
+        break;
+    case FontLoadTimingOverride::Swap:
+        policy = Settings::FontLoadTimingOverride::Swap;
+        break;
+    case FontLoadTimingOverride::Failure:
+        policy = Settings::FontLoadTimingOverride::Failure;
+        break;
+    }
+    settings().setFontLoadTimingOverride(policy);
+    return { };
 }
 
-void InternalSettings::setResolutionOverride(int dotsPerCSSInchHorizontally, int dotsPerCSSInchVertically, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setShouldIgnoreFontLoadCompletions(bool ignore)
 {
-    InternalSettingsGuardForSettings();
-    // An empty size resets the override.
-    settings()->setResolutionOverride(IntSize(dotsPerCSSInchHorizontally, dotsPerCSSInchVertically));
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setShouldIgnoreFontLoadCompletions(ignore);
+    return { };
 }
 
-void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setQuickTimePluginReplacementEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setMediaTypeOverride(mediaType);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setQuickTimePluginReplacementEnabled(enabled);
+    return { };
 }
 
-void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setYouTubeFlashPluginReplacementEnabled(bool enabled)
 {
-#if ENABLE(TEXT_AUTOSIZING)
-    InternalSettingsGuardForSettings();
-    settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
-#else
-    UNUSED_PARAM(fontScaleFactor);
-    UNUSED_PARAM(ec);
-#endif
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setYouTubeFlashPluginReplacementEnabled(enabled);
+    return { };
 }
 
-void InternalSettings::setEnableScrollAnimator(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground)
 {
-#if ENABLE(SMOOTH_SCROLLING)
-    InternalSettingsGuardForSettings();
-    settings()->setEnableScrollAnimator(enabled);
-#else
-    UNUSED_PARAM(enabled);
-    UNUSED_PARAM(ec);
-#endif
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
+    return { };
 }
 
-bool InternalSettings::scrollAnimatorEnabled(ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert)
 {
-#if ENABLE(SMOOTH_SCROLLING)
-    InternalSettingsGuardForSettingsReturn(false);
-    return settings()->scrollAnimatorEnabled();
-#else
-    UNUSED_PARAM(ec);
-    return false;
-#endif
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setShouldConvertPositionStyleOnCopy(convert);
+    return { };
 }
 
-void InternalSettings::setCSSExclusionsEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setScrollingTreeIncludesFrames(bool enabled)
 {
-    UNUSED_PARAM(ec);
-    RuntimeEnabledFeatures::setCSSExclusionsEnabled(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setScrollingTreeIncludesFrames(enabled);
+    return { };
 }
 
-void InternalSettings::setCSSVariablesEnabled(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAllowUnclampedScrollPosition(bool allowUnclamped)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setCSSVariablesEnabled(enabled);
+    if (!m_page || !m_page->mainFrame().view())
+        return Exception { InvalidAccessError };
+
+    m_page->mainFrame().view()->setAllowsUnclampedScrollPositionForTesting(allowUnclamped);
+    return { };
 }
 
-bool InternalSettings::cssVariablesEnabled(ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAllowsInlineMediaPlayback(bool allows)
 {
-    InternalSettingsGuardForSettingsReturn(false);
-    return settings()->cssVariablesEnabled();
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setAllowsInlineMediaPlayback(allows);
+    return { };
 }
 
-void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows)
 {
-    InternalSettingsGuardForSettings();
-    m_page->setCanStartMedia(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setAllowsInlineMediaPlaybackAfterFullscreen(allows);
+    return { };
 }
 
-void InternalSettings::setMediaPlaybackRequiresUserGesture(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setMediaPlaybackRequiresUserGesture(enabled);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
+    return { };
 }
 
-void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setShouldMockBoldSystemFontForAccessibility(bool requires)
 {
-    InternalSettingsGuardForSettings();
-    if (equalIgnoringCase(editingBehavior, "win"))
-        settings()->setEditingBehaviorType(EditingWindowsBehavior);
-    else if (equalIgnoringCase(editingBehavior, "mac"))
-        settings()->setEditingBehaviorType(EditingMacBehavior);
-    else if (equalIgnoringCase(editingBehavior, "unix"))
-        settings()->setEditingBehaviorType(EditingUnixBehavior);
-    else
-        ec = SYNTAX_ERR;
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    RenderTheme::singleton().setShouldMockBoldSystemFontForAccessibility(requires);
+    FontCache::singleton().setShouldMockBoldSystemFontForAccessibility(requires);
+    return { };
 }
 
-void InternalSettings::setFixedPositionCreatesStackingContext(bool creates, ExceptionCode& ec)
+void InternalSettings::setIndexedDBWorkersEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setFixedPositionCreatesStackingContext(creates);
+#if ENABLE(INDEXED_DATABASE_IN_WORKERS)
+    RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
 }
 
-void InternalSettings::setSyncXHRInDocumentsEnabled(bool enabled, ExceptionCode& ec)
+void InternalSettings::setWebGL2Enabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setSyncXHRInDocumentsEnabled(enabled);
+#if ENABLE(WEBGL2)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
 }
 
-void InternalSettings::setWindowFocusRestricted(bool restricted, ExceptionCode& ec)
+void InternalSettings::setWebGPUEnabled(bool enabled)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setWindowFocusRestricted(restricted);
+#if ENABLE(WEBGPU)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGPUEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+}
+
+void InternalSettings::setWebVREnabled(bool enabled)
+{
+    RuntimeEnabledFeatures::sharedFeatures().setWebVREnabled(enabled);
 }
 
-void InternalSettings::setDialogElementEnabled(bool enabled, ExceptionCode& ec)
+void InternalSettings::setScreenCaptureEnabled(bool enabled)
 {
-    UNUSED_PARAM(ec);
-#if ENABLE(DIALOG_ELEMENT)
-    RuntimeEnabledFeatures::setDialogElementEnabled(enabled);
+#if ENABLE(MEDIA_STREAM)
+    RuntimeEnabledFeatures::sharedFeatures().setScreenCaptureEnabled(enabled);
 #else
     UNUSED_PARAM(enabled);
 #endif
 }
 
-void InternalSettings::allowRoundingHacks() const
+void InternalSettings::setStorageAccessPromptsEnabled(bool enabled)
+{
+    RuntimeEnabledFeatures::sharedFeatures().setStorageAccessPromptsEnabled(enabled);
+}
+    
+ExceptionOr<String> InternalSettings::userInterfaceDirectionPolicy()
+{
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    switch (settings().userInterfaceDirectionPolicy()) {
+    case UserInterfaceDirectionPolicy::Content:
+        return String { ASCIILiteral { "Content" } };
+    case UserInterfaceDirectionPolicy::System:
+        return String { ASCIILiteral { "View" } };
+    }
+    ASSERT_NOT_REACHED();
+    return Exception { InvalidAccessError };
+}
+
+ExceptionOr<void> InternalSettings::setUserInterfaceDirectionPolicy(const String& policy)
 {
-    TextRun::setAllowsRoundingHacks(true);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    if (equalLettersIgnoringASCIICase(policy, "content")) {
+        settings().setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
+        return { };
+    }
+    if (equalLettersIgnoringASCIICase(policy, "view")) {
+        settings().setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
+        return { };
+    }
+    return Exception { InvalidAccessError };
 }
 
-Vector<String> InternalSettings::userPreferredLanguages() const
+ExceptionOr<String> InternalSettings::systemLayoutDirection()
 {
-    return WebCore::userPreferredLanguages();
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    switch (settings().systemLayoutDirection()) {
+    case LTR:
+        return String { ASCIILiteral { "LTR" } };
+    case RTL:
+        return String { ASCIILiteral { "RTL" } };
+    }
+    ASSERT_NOT_REACHED();
+    return Exception { InvalidAccessError };
 }
 
-void InternalSettings::setUserPreferredLanguages(const Vector<String>& languages)
+ExceptionOr<void> InternalSettings::setSystemLayoutDirection(const String& direction)
 {
-    WebCore::overrideUserPreferredLanguages(languages);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    if (equalLettersIgnoringASCIICase(direction, "ltr")) {
+        settings().setSystemLayoutDirection(LTR);
+        return { };
+    }
+    if (equalLettersIgnoringASCIICase(direction, "rtl")) {
+        settings().setSystemLayoutDirection(RTL);
+        return { };
+    }
+    return Exception { InvalidAccessError };
 }
 
-void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setFrameFlattening(FrameFlatteningValue frameFlattening)
 {
-    InternalSettingsGuardForSettings();
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setFrameFlattening(frameFlattening);
+    return { };
+}
 
-#if ENABLE(VIDEO_TRACK)
-    if (equalIgnoringCase(kind, "Subtitles"))
-        settings()->setShouldDisplaySubtitles(enabled);
-    else if (equalIgnoringCase(kind, "Captions"))
-        settings()->setShouldDisplayCaptions(enabled);
-    else if (equalIgnoringCase(kind, "TextDescriptions"))
-        settings()->setShouldDisplayTextDescriptions(enabled);
-    else
-        ec = SYNTAX_ERR;
-#else
-    UNUSED_PARAM(kind);
-    UNUSED_PARAM(enabled);
+void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
+{
+    DeprecatedGlobalSettings::setAllowsAnySSLCertificate(allowsAnyCertificate);
+#if USE(SOUP)
+    SoupNetworkSession::setShouldIgnoreTLSErrors(allowsAnyCertificate);
 #endif
 }
 
-bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
+ExceptionOr<bool> InternalSettings::deferredCSSParserEnabled()
 {
-    InternalSettingsGuardForSettingsReturn(false);
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    return settings().deferredCSSParserEnabled();
+}
 
-#if ENABLE(VIDEO_TRACK)
-    if (equalIgnoringCase(kind, "Subtitles"))
-        return settings()->shouldDisplaySubtitles();
-    if (equalIgnoringCase(kind, "Captions"))
-        return settings()->shouldDisplayCaptions();
-    if (equalIgnoringCase(kind, "TextDescriptions"))
-        return settings()->shouldDisplayTextDescriptions();
-
-    ec = SYNTAX_ERR;
-    return false;
+ExceptionOr<void> InternalSettings::setDeferredCSSParserEnabled(bool enabled)
+{
+    if (!m_page)
+        return Exception { InvalidAccessError };
+    settings().setDeferredCSSParserEnabled(enabled);
+    return { };
+}
+
+ExceptionOr<void> InternalSettings::setShouldManageAudioSessionCategory(bool should)
+{
+#if USE(AUDIO_SESSION)
+    DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(should);
+    return { };
 #else
-    UNUSED_PARAM(kind);
-    return false;
+    UNUSED_PARAM(should);
+    return Exception { InvalidAccessError };
 #endif
 }
 
-void InternalSettings::setPagination(const String& mode, int gap, int pageLength, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setCustomPasteboardDataEnabled(bool enabled)
 {
-    if (!page()) {
-        ec = INVALID_ACCESS_ERR;
-        return;
-    }
-
-    Pagination pagination;
-    if (mode == "Unpaginated")
-        pagination.mode = Pagination::Unpaginated;
-    else if (mode == "LeftToRightPaginated")
-        pagination.mode = Pagination::LeftToRightPaginated;
-    else if (mode == "RightToLeftPaginated")
-        pagination.mode = Pagination::RightToLeftPaginated;
-    else if (mode == "TopToBottomPaginated")
-        pagination.mode = Pagination::TopToBottomPaginated;
-    else if (mode == "BottomToTopPaginated")
-        pagination.mode = Pagination::BottomToTopPaginated;
-    else {
-        ec = SYNTAX_ERR;
-        return;
-    }
-
-    pagination.gap = gap;
-    pagination.pageLength = pageLength;
-    page()->setPagination(pagination);
+    RuntimeEnabledFeatures::sharedFeatures().setCustomPasteboardDataEnabled(enabled);
+    return { };
 }
 
-void InternalSettings::setEnableMockPagePopup(bool enabled, ExceptionCode& ec)
+ExceptionOr<void> InternalSettings::setAccessibilityEventsEnabled(bool enabled)
 {
-#if ENABLE(PAGE_POPUP)
-    InternalSettingsGuardForPage();
-    if (!page()->chrome())
-        return;
-    if (!enabled) {
-        page()->chrome()->client()->resetPagePopupDriver();
-        return;
-    }
-    if (!m_pagePopupDriver)
-        m_pagePopupDriver = MockPagePopupDriver::create(page()->mainFrame());
-    page()->chrome()->client()->setPagePopupDriver(m_pagePopupDriver.get());
+    if (!m_page)
+        return Exception { InvalidAccessError };
+#if ENABLE(ACCESSIBILITY_EVENTS)
+    settings().setAccessibilityEventsEnabled(enabled);
 #else
     UNUSED_PARAM(enabled);
-    UNUSED_PARAM(ec);
 #endif
+    return { };
 }
 
-String InternalSettings::configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
+static InternalSettings::ForcedAccessibilityValue settingsToInternalSettingsValue(Settings::ForcedAccessibilityValue value)
 {
-    if (!page()) {
-        ec = INVALID_ACCESS_ERR;
-        return String();
+    switch (value) {
+    case Settings::ForcedAccessibilityValue::System:
+        return InternalSettings::ForcedAccessibilityValue::System;
+    case Settings::ForcedAccessibilityValue::On:
+        return InternalSettings::ForcedAccessibilityValue::On;
+    case Settings::ForcedAccessibilityValue::Off:
+        return InternalSettings::ForcedAccessibilityValue::Off;
     }
 
-    const int defaultLayoutWidthForNonMobilePages = 980;
+    ASSERT_NOT_REACHED();
+    return InternalSettings::ForcedAccessibilityValue::Off;
+}
 
-    ViewportArguments arguments = page()->viewportArguments();
-    ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
-    restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio);
-    restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
+static Settings::ForcedAccessibilityValue internalSettingsToSettingsValue(InternalSettings::ForcedAccessibilityValue value)
+{
+    switch (value) {
+    case InternalSettings::ForcedAccessibilityValue::System:
+        return Settings::ForcedAccessibilityValue::System;
+    case InternalSettings::ForcedAccessibilityValue::On:
+        return Settings::ForcedAccessibilityValue::On;
+    case InternalSettings::ForcedAccessibilityValue::Off:
+        return Settings::ForcedAccessibilityValue::Off;
+    }
 
-    return "viewport size " + String::number(attributes.layoutSize.width()) + "x" + String::number(attributes.layoutSize.height()) + " scale " + String::number(attributes.initialScale) + " with limits [" + String::number(attributes.minimumScale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (attributes.userScalable ? "true" : "false");
+    ASSERT_NOT_REACHED();
+    return Settings::ForcedAccessibilityValue::Off;
 }
 
-void InternalSettings::setMemoryInfoEnabled(bool enabled, ExceptionCode& ec)
+InternalSettings::ForcedAccessibilityValue InternalSettings::forcedColorsAreInvertedAccessibilityValue() const
 {
-    InternalSettingsGuardForSettings();
-    settings()->setMemoryInfoEnabled(enabled);
+    return settingsToInternalSettingsValue(settings().forcedColorsAreInvertedAccessibilityValue());
 }
 
-void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
+void InternalSettings::setForcedColorsAreInvertedAccessibilityValue(InternalSettings::ForcedAccessibilityValue value)
 {
-    InternalSettingsGuardForSettings();
+    settings().setForcedColorsAreInvertedAccessibilityValue(internalSettingsToSettingsValue(value));
+}
 
-    if (mode == "AllowAll")
-        settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
-    else if (mode == "BlockThirdParty")
-        settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
-    else if (mode == "BlockAll")
-        settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
-    else
-        ec = SYNTAX_ERR;
+InternalSettings::ForcedAccessibilityValue InternalSettings::forcedDisplayIsMonochromeAccessibilityValue() const
+{
+    return settingsToInternalSettingsValue(settings().forcedDisplayIsMonochromeAccessibilityValue());
+}
+
+void InternalSettings::setForcedDisplayIsMonochromeAccessibilityValue(InternalSettings::ForcedAccessibilityValue value)
+{
+    settings().setForcedDisplayIsMonochromeAccessibilityValue(internalSettingsToSettingsValue(value));
 }
 
-void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
+InternalSettings::ForcedAccessibilityValue InternalSettings::forcedPrefersReducedMotionAccessibilityValue() const
 {
-    RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(enabled);
+    return settingsToInternalSettingsValue(settings().forcedPrefersReducedMotionAccessibilityValue());
 }
 
-void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
+void InternalSettings::setForcedPrefersReducedMotionAccessibilityValue(InternalSettings::ForcedAccessibilityValue value)
 {
-    InternalSettingsGuardForSettings();
-    settings()->setImagesEnabled(enabled);
+    settings().setForcedPrefersReducedMotionAccessibilityValue(internalSettingsToSettingsValue(value));
 }
 
+bool InternalSettings::webAnimationsCSSIntegrationEnabled()
+{
+    return RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled();
+}
+
+// If you add to this class, make sure that you update the Backup class for test reproducability!
+
 }