diff --git a/lib/src/test/kotlin/dev/hossain/json5kt/JSON5ParserTextExampleFiles.kt b/lib/src/test/kotlin/dev/hossain/json5kt/JSON5ParserTextExampleFiles.kt index 59b2874..f949560 100644 --- a/lib/src/test/kotlin/dev/hossain/json5kt/JSON5ParserTextExampleFiles.kt +++ b/lib/src/test/kotlin/dev/hossain/json5kt/JSON5ParserTextExampleFiles.kt @@ -203,4 +203,61 @@ class JSON5ParserTextExampleFiles { assertEquals(expected, result) } + + /** + * Tests parsing of a real-world HarmonyOS IDE hvigor build profile from `harmonyos-ide-hvigor-build-profile-V13.json5`. + * This file represents a complex build configuration with nested objects, arrays, + * and extensive use of JSON5 features like comments and trailing commas. + */ + @Test + fun testParseHarmonyOSBuildProfileJson5() { + val path = Paths.get("src/test/resources/harmonyos-ide-hvigor-build-profile-V13.json5") + val json5Text = Files.readString(path) + val result = JSON5Parser.parse(json5Text) + + // Validate basic structure and key properties + val resultMap = result as Map<*, *> + assert(resultMap.containsKey("app")) { "Should contain 'app' key" } + assert(resultMap.containsKey("modules")) { "Should contain 'modules' key" } + + val app = resultMap["app"] as Map<*, *> + assert(app.containsKey("signingConfigs")) { "App should contain 'signingConfigs'" } + assert(app.containsKey("products")) { "App should contain 'products'" } + assert(app.containsKey("buildModeSet")) { "App should contain 'buildModeSet'" } + + val modules = resultMap["modules"] as List<*> + assert(modules.isNotEmpty()) { "Modules should not be empty" } + val firstModule = modules.first() as Map<*, *> + assertEquals("entry", firstModule["name"]) { "First module name should be 'entry'" } + assertEquals("./entry", firstModule["srcPath"]) { "First module srcPath should be './entry'" } + } + + /** + * Tests parsing of a real-world Blink renderer core frame settings from `blink-renderer-core-frame-settings.json5`. + * This file represents a comprehensive configuration with parameters and data arrays, + * demonstrating JSON5's capability to handle large, complex configuration files with comments. + */ + @Test + fun testParseBlinkRendererFrameSettingsJson5() { + val path = Paths.get("src/test/resources/blink-renderer-core-frame-settings.json5") + val json5Text = Files.readString(path) + val result = JSON5Parser.parse(json5Text) + + // Validate basic structure and key properties + val resultMap = result as Map<*, *> + assert(resultMap.containsKey("parameters")) { "Should contain 'parameters' key" } + assert(resultMap.containsKey("data")) { "Should contain 'data' key" } + + val parameters = resultMap["parameters"] as Map<*, *> + assert(parameters.containsKey("type")) { "Parameters should contain 'type'" } + assert(parameters.containsKey("include_paths")) { "Parameters should contain 'include_paths'" } + assert(parameters.containsKey("initial")) { "Parameters should contain 'initial'" } + assert(parameters.containsKey("invalidate")) { "Parameters should contain 'invalidate'" } + + val data = resultMap["data"] as List<*> + assert(data.isNotEmpty()) { "Data should not be empty" } + val firstDataItem = data.first() as Map<*, *> + assertEquals("defaultTextEncodingName", firstDataItem["name"]) { "First data item name should be 'defaultTextEncodingName'" } + assertEquals("String", firstDataItem["type"]) { "First data item type should be 'String'" } + } } diff --git a/lib/src/test/resources/blink-renderer-core-frame-settings.json5 b/lib/src/test/resources/blink-renderer-core-frame-settings.json5 new file mode 100644 index 0000000..8af16b4 --- /dev/null +++ b/lib/src/test/resources/blink-renderer-core-frame-settings.json5 @@ -0,0 +1,1159 @@ +{ + // Defines properties which are available on the Settings object. + // + // Please think carefully before adding a new Setting. Some questions to + // consider are: + // - Should this be a RuntimeEnabledFeature instead? Settings are for things + // which we support either values of at runtime. Features are set at renderer + // process startup and are never changed. Features also tend to be set to a + // value based on the platform or the stability of the code in question, where + // as settings both codepaths need to be stable. + // - How will you ensure test coverage of all relevant values of your setting? + // - Is the default value appropriate for other platforms or ports which may + // not be aware of your setting? + // - Can your setting result in behavior differences observable to web + // developers? + // - Should this setting ideally be removed in the future? If so please file + // a bug and reference it in the comments for your setting. + // + // One reason to add a Setting is to manage the risk associated with adding a + // new feature. For example, we may choose to ship a new UI behavior or + // performance optimization to ChromeOS users first (in order to gather feedback + // and metrics on its use from the wild) before attempting to ship it to + // Windows. + // + // FIXME: Add support for global settings. + // FIXME: Add support for custom getters/setters. + // Valid parameters for data entries below. + parameters: { + type: { + default: "bool", + valid_type: "str", // The string value should be a C++ type name + }, + // List of files containing the definitions of the types in 'type'. + include_paths: { + default: [], + valid_type: "list", + }, + // The initial value. Can be a boolean, integer or string representing the + // value. + // Can be set per platform using an object with keys being any of the + // platforms listed in valid_keys below. The 'default' key will cover any + // platforms that has not been explicitly specified and should always be + // present. + initial: { + valid_keys: ["Android", "Win", "ChromeOS", "Mac", "Linux"], + }, + invalidate: { + default: [], + valid_type: "list", + // See SettingsDelegate::ChangeType for valid values (without "k"), + }, + }, + data: [ + { + name: "defaultTextEncodingName", + type: "String", + }, + // Do not hide chars typed in password fields immediately, but let the last char stay + // visible for N seconds, configured by the passwordEchoDurationInSeconds setting + // FIXME: Enable automatically if passwordEchoDurationInSeconds is set to a positive value. + { + name: "passwordEchoEnabled", + initial: false, + }, + // Configure how long the last char should say visible in seconds. + { + name: "passwordEchoDurationInSeconds", + initial: 1, + type: "double", + }, + // Sets the magnification value for validation message timer. If the + // magnification value is N, a validation message disappears automatically after + // * N / 1000 seconds. If N is equal to or less than 0, a + // validation message doesn't disappears automaticaly. + { + name: "validationMessageTimerMagnification", + initial: 50, + type: "int", + }, + // Sets the minimum font-size in CSS px. That means the minimum font-size is + // applied before applying the device scale factor or page zoom. + { + name: "minimumFontSize", + initial: 0, + invalidate: ["Style"], + type: "int", + }, + // Sets the minimum font-size in CSS px, but only applies to relative font + // units like 'small', em, and percentage sizes. + { + name: "minimumLogicalFontSize", + initial: 0, + invalidate: ["Style"], + type: "int", + }, + { + name: "defaultFontSize", + initial: 0, + invalidate: ["Style"], + type: "int", + }, + { + name: "defaultFixedFontSize", + initial: 0, + invalidate: ["Style"], + type: "int", + }, + { + name: "editingBehaviorType", + // NOTEs + // 1) EditingMacBehavior comprises builds on Mac; + // 2) EditingWindowsBehavior comprises builds on Windows; + // 3) EditingUnixBehavior comprises all unix-based systems, but + // Darwin/MacOS/Android (and then abusing the terminology); + // 4) EditingAndroidBehavior comprises Android builds. + // 99) MacEditingBehavior is used a fallback. + initial: { + "Mac": "mojom::blink::EditingBehavior::kEditingMacBehavior", + "Win": "mojom::blink::EditingBehavior::kEditingWindowsBehavior", + "Android": "mojom::blink::EditingBehavior::kEditingAndroidBehavior", + "ChromeOS": "mojom::blink::EditingBehavior::kEditingChromeOSBehavior", + "default": "mojom::blink::EditingBehavior::kEditingUnixBehavior", + }, + type: "mojom::EditingBehavior", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + { + name: "localStorageEnabled", + initial: false, + }, + { + name: "allowUniversalAccessFromFileURLs", + initial: true, + invalidate: ["UniversalAccess"], + }, + { + name: "allowFileAccessFromFileURLs", + initial: true, + }, + { + name: "supportsMultipleWindows", + initial: true, + }, + { + name: "javaScriptCanAccessClipboard", + initial: false, + }, + { + name: "shouldPrintBackgrounds", + initial: false, + }, + { + name: "shouldClearDocumentBackground", + initial: true, + }, + { + name: "HighlightAds", + initial: false, + invalidate: ["HighlightAds"], + }, + { + name: "textAreasAreResizable", + initial: false, + invalidate: ["Style"], + }, + { + name: "acceleratedCompositingEnabled", + initial: false, + invalidate: ["AcceleratedCompositing"], + }, + { + name: "allowScriptsToCloseWindows", + initial: false, + }, + // FIXME: This should really be disabled by default as it makes platforms that + // don't support the feature download files they can't use by. + // Leaving enabled for now to not change existing behavior. + { + name: "downloadableBinaryFontsEnabled", + initial: true, + }, + { + name: "LCDTextPreference", + type: "LCDTextPreference", + include_paths: [ + "third_party/blink/renderer/platform/graphics/lcd_text_preference.h" + ], + initial: "LCDTextPreference::kStronglyPreferred", + invalidate: ["AcceleratedCompositing"], + }, + { + name: "webGL1Enabled", + initial: true, + }, + { + name: "webGL2Enabled", + initial: true, + }, + { + name: "webGLErrorsToConsoleEnabled", + initial: true, + }, + { + name: "antialiased2dCanvasEnabled", + initial: true, + }, + { + name: "antialiasedClips2dCanvasEnabled", + initial: true, + }, + { + name: "accelerated2dCanvasMSAASampleCount", + initial: 0, + type: "int", + }, + { + name: "hyperlinkAuditingEnabled", + initial: false, + }, + { + name: "allowRunningOfInsecureContent", + initial: true, + }, + { + name: "pictureInPictureEnabled", + initial: true, + }, + { + name: "webAppScope", + type: "String", + }, + { + name: "presentationRequiresUserGesture", + initial: true, + }, + { + name: "embeddedMediaExperienceEnabled", + initial: false, + }, + // This is true when the page is being displayed in a 3D context (eg, a VR + // headset). + { + name: "immersiveModeEnabled", + initial: false, + }, + // Only affects main thread scrolling + { + name: "scrollAnimatorEnabled", + initial: true, + }, + // Used in web tests for gesture tap highlights. Makes the highlights square + // (rather than rounded) to make it possible to reftest the results. + { + name: "mockGestureTapHighlightsEnabled", + initial: false, + }, + // This value indicates the number of simultaneous multi-touch points supported + // by the currently connected screen/digitizer that supports the most points. + // From Pointer Events spec: + // http://www.w3.org/TR/pointerevents///widl-Navigator-maxTouchPoints + { + name: "maxTouchPoints", + initial: 0, + type: "int", + }, + // Determines whether WebViewClient::didTapMultipleTargets will be used for + // touch disambiguation. + { + name: "multiTargetTapNotificationEnabled", + initial: true, + }, + // Determines whether the barrel on stylus input should be used for selecting + // text and dragging. + { + name: "barrelButtonForDragEnabled", + initial: false, + }, + { + name: "syncXHRInDocumentsEnabled", + initial: true, + }, + { + name: "targetBlankImpliesNoOpenerEnabledWillBeRemoved", + initial: true, + }, + { + name: "allowNonEmptyNavigatorPlugins", + initial: false, + }, + { + name: "ignorePermissionForDeviceChangedEvent", + initial: false, + }, + { + name: "cookieEnabled", + initial: true, + }, + { + name: "navigateOnDragDrop", + initial: true, + }, + { + name: "DOMPasteAllowed", + initial: false, + }, + { + name: "allowCustomScrollbarInMainFrame", + initial: true, + }, + { + name: "placeRTLScrollbarsOnLeftSideInMainFrame", + initial: false, + invalidate: ["ScrollbarLayout"], + }, + { + name: "webSecurityEnabled", + initial: true, + }, + // Special keyboard navigation mode intented for platforms with no + // proper mouse or touch support, such as a TV controller with a remote. + { + name: "spatialNavigationEnabled", + initial: false, + }, + // This setting adds a means to enable/disable touch initiated drag & drop. If + // enabled, the user can initiate drag using long press. + // crbug.com/304894 tracks removal once it's been enabled on all platforms. + { + name: "touchDragDropEnabled", + initial: false, + }, + // Fires a contextmenu event when a touch-drag ends, which by default shows + // a context-menu. When implementation issues have been resolved, this + // should be merged to touchDragDropEnabled. See crbug.com/1126473. + { + name: "touchDragEndContextMenu", + initial: false, + }, + // Some apps could have a default video poster if it is not set. + { + name: "defaultVideoPosterURL", + type: "String", + }, + { + name: "smartInsertDeleteEnabled", + initial: false, + }, + { + name: "selectTrailingWhitespaceEnabled", + initial: {"Win": true, "default": false}, + }, + { + name: "selectionIncludesAltImageText", + initial: false, + }, + { + name: "selectionStrategy", + initial: "SelectionStrategy::kCharacter", + type: "SelectionStrategy", + include_paths: [ + "third_party/blink/renderer/core/editing/selection_strategy.h" + ], + }, + //////////////// Settings used by Android WebView below //////////////// + // This quirk is to maintain compatibility with Android apps built on + // the Android SDK prior to and including version 18. + // Presumably, this can be removed any time after 2015. + // See http://crbug.com/282130. + { + name: "viewportMetaZeroValuesQuirk", + initial: false, + }, + // Another Android SDK <= 18 quirk, removable 2015. + // See http://crbug.com/295287 + { + name: "ignoreMainFrameOverflowHiddenQuirk", + initial: false, + }, + // Yet another Android SDK <= 18 quirk, removable 2015. + // See http://crbug.com/305236 + { + name: "reportScreenSizeInPhysicalPixelsQuirk", + initial: false, + }, + // One more Android SDK <= 18 quirk, removable 2015. + // See http://crbug.com/306548 + { + name: "viewportMetaMergeContentQuirk", + initial: false, + }, + // This quirk is to maintain compatibility with Android apps. + // It will be possible to remove it once WebSettings.{get|set}UseWideViewPort + // API function will be removed. + // See http://crbug.com/288037. + { + name: "wideViewportQuirkEnabled", + initial: false, + }, + // Used by the android_webview to support a horizontal height auto-sizing + // mode. + { + name: "forceZeroLayoutHeight", + initial: false, + invalidate: ["ViewportDescription"], + }, + { + name: "mainFrameClipsContent", + initial: true, + invalidate: ["ViewportPaintProperties"], + }, + // For android.webkit.WebSettings.setUseWideViewport() + // http://developer.android.com/reference/android/webkit/WebSettings.html//setUseWideViewPort(boolean) + { + name: "useWideViewport", + initial: true, + invalidate: ["ViewportDescription"], + }, + // For android.webkit.WebSettings.setLoadWithOverviewMode() + // http://developer.android.com/reference/android/webkit/WebSettings.html//setLoadWithOverviewMode(boolean) + { + name: "loadWithOverviewMode", + initial: true, + invalidate: ["ViewportDescription"], + }, + // Used by android_webview to support legacy apps that inject script into a top-level initial empty + // document and expect it to persist on navigation, even though the origin is unique. Note that this + // behavior violates the requirements described by [Initialising a new Document object] in + // https://html.spec.whatwg.org/multipage/browsers.html//navigating-across-documents. + { + name: "shouldReuseGlobalForUnownedMainFrame", + initial: false, + }, + //////////////// End of settings used by Android WebView //////////////// + // Touch based text selection and editing on desktop. + // crbug.com/304873 tracks removal once it's been enabled on all platforms. + { + name: "touchEditingEnabled", + initial: false, + }, + // The rubber-band overscroll effect is implemented in Blink and is being moved + // to the compositor thread. This will be set to true and eventually removed. + // crbug.com/133097 + { + name: "rubberBandingOnCompositorThread", + initial: false, + }, + // The current state of caret browsing mode. + { + name: "caretBrowsingEnabled", + initial: false, + invalidate: ["Style"], + }, + // Font scale factor for accessibility, applied as part of text autosizing. + { + name: "accessibilityFontScaleFactor", + initial: "1.0", + invalidate: ["TextAutosizing", "FontScaleFactor"], + type: "double", + }, + // Font weight adjustment for accessibility, set at OS-level. + { + name: "accessibilityFontWeightAdjustment", + initial: "0", + type: "int", + }, + // Text size contrast factor for accessibility, applied as part of page zoom. + { + name: "accessibilityTextSizeContrastFactor", + initial: "0", + type: "int", + }, + // Only used by web tests and inspector emulation. + { + name: "mediaTypeOverride", + initial: "\"\"", + invalidate: ["MediaQuery"], + type: "String", + }, + { + name: "displayModeOverride", + initial: "blink::mojom::DisplayMode::kUndefined", + invalidate: ["MediaQuery"], + type: "blink::mojom::DisplayMode", + include_paths: [ + "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h" + ], + }, + // Only used by web tests. + { + name: "windowShowState", + initial: "ui::mojom::blink::WindowShowState::kDefault", + invalidate: ["MediaQuery"], + type: "ui::mojom::blink::WindowShowState", + include_paths: ["ui/base/mojom/window_show_state.mojom-blink.h"], + }, + // Only used by web tests. + { + name: "resizable", + initial: true, + invalidate: ["MediaQuery"], + type: "bool", + }, + // loadsImagesAutomatically only suppresses the network load of + // the image URL. A cached image will still be rendered if requested. + { + name: "loadsImagesAutomatically", + initial: false, + invalidate: ["ImageLoading"], + }, + { + name: "imagesEnabled", + initial: true, + invalidate: ["ImageLoading"], + }, + { + name: "imageAnimationPolicy", + initial: "mojom::blink::ImageAnimationPolicy::kImageAnimationPolicyAllowed", + type: "mojom::blink::ImageAnimationPolicy", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + // Html preload scanning is a fast, early scan of HTML documents to find loadable + // resources before the parser advances to them. If it is disabled, resources will + // be loaded later. + { + name: "doHtmlPreloadScanning", + initial: true, + }, + { + name: "pluginsEnabled", + initial: false, + invalidate: ["Plugins"], + }, + { + name: "viewportEnabled", + initial: false, + invalidate: ["ViewportDescription"], + }, + { + name: "viewportMetaEnabled", + initial: false, + invalidate: ["ViewportDescription"], + }, + // When true, Blink will use the content width and viewport size to set the + // minimum scale factor such that the user can't zoom out into the area + // beyond the content. + { + name: "shrinksViewportContentToFit", + initial: false, + }, + { + name: "dnsPrefetchingEnabled", + initial: false, + invalidate: ["DNSPrefetching"], + }, + // Clients that execute script should call ExecutionContext::canExecuteScripts() + // instead of this function. ExecutionContext::canExecuteScripts() checks the + // HTML sandbox, plugin sandboxing, and other important details. + { + name: "scriptEnabled", + initial: false, + invalidate: ["MediaQuery"], + }, + { + name: "parserScriptingFlagPolicy", + initial: "ParserScriptingFlagPolicy::kOnlyIfScriptIsEnabled", + type: "ParserScriptingFlagPolicy", + include_paths: [ + "third_party/blink/renderer/core/html/parser/parser_scripting_flag_policy.h" + ], + }, + // Forces Android Overlay Scrollbar for mobile emulator. + { + name: "forceAndroidOverlayScrollbar", + initial: false, + invalidate: ["ScrollbarLayout"], + }, + // Set the timeout seconds of the network-quiet timers in IdlenessDetector. + // Used by embedders who want to change the timeout time in order to run web contents + // on various embedded devices and changeable network bandwidths in different regions. + { + name: "NetworkQuietTimeout", + initial: "0.5", + type: "double", + }, + // Forces initialization of main world, even if no scripts will be executed. + // Used by inspector to report all contexts. + { + name: "forceMainWorldInitialization", + initial: false, + invalidate: ["DOMWorlds"], + }, + // Forces TouchEventFeatureDetection conditional feature for all main + // worlds in the page. Used by inspector to emulate touch on devices + // which don't support it naturally. + { + name: "forceTouchEventFeatureDetectionForInspector", + initial: false, + }, + // Compensates for poor text legibility on mobile devices. This value is + // multiplied by the font scale factor when performing text autosizing of + // websites that do not set an explicit viewport description. + { + name: "deviceScaleAdjustment", + initial: "1.0", + invalidate: ["TextAutosizing"], + type: "double", + }, + // This value is set to false if the platform does not support fullscreen. + // When set to false all the requests to enter fullscreen will return an error + // (fullscreenerror or webkitfullscreenerror) as specified in the standard: + // http://fullscreen.spec.whatwg.org///dom-element-requestfullscreen + { + name: "fullscreenSupported", + initial: true, + }, + // V8 supports different types of caching. Used by V8 bindings. + { + name: "v8CacheOptions", + initial: "mojom::blink::V8CacheOptions::kDefault", + type: "mojom::blink::V8CacheOptions", + include_paths: [ + "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h" + ], + }, + // These values are bit fields for the properties of available pointing devices + // and may take on multiple values (e.g. laptop with touchpad and touchscreen + // has pointerType coarse *and* fine). + { + name: "availablePointerTypes", + initial: "ui::POINTER_TYPE_NONE", + invalidate: ["MediaQuery"], + type: "int", + include_paths: ["ui/base/pointer/pointer_device.h"], + }, + { + name: "availableHoverTypes", + initial: "ui::HOVER_TYPE_NONE", + invalidate: ["MediaQuery"], + type: "int", + include_paths: ["ui/base/pointer/pointer_device.h"], + }, + // These values specify properties of the user's primary pointing device only. + { + name: "primaryPointerType", + initial: "mojom::blink::PointerType::kPointerNone", + invalidate: ["MediaQuery"], + type: "blink::mojom::PointerType", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + { + name: "primaryHoverType", + initial: "mojom::blink::HoverType::kHoverNone", + invalidate: ["MediaQuery"], + type: "mojom::blink::HoverType", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + // The ability of the output device to modify the appearance of content once + // it has been rendered: + // kSlowType: E-ink screens or severely under-powered devices. + // kFastType: Computer screens. + { + name: "outputDeviceUpdateAbilityType", + initial: "mojom::blink::OutputDeviceUpdateAbilityType::kFastType", + invalidate: ["MediaQuery"], + type: "mojom::blink::OutputDeviceUpdateAbilityType", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + // If true, the value in password fields is exposed to assistive technologies. + { + name: "accessibilityPasswordValuesEnabled", + initial: false, + }, + // If true, context menu will be shown on mouse up instead of mouse down. + // Typically enabled on Windows to match platform convention. + { + name: "showContextMenuOnMouseUp", + initial: false, + }, + // If true, context menu will be shown on any long press event. + // Used on Android to prevent a context menu from being shown in certain situations + // (i.e. long pressing an empty div) + { + name: "alwaysShowContextMenuOnTouch", + initial: true, + }, + { + name: "disableReadingFromCanvas", + initial: false, + }, + { + name: "strictMixedContentChecking", + initial: false, + }, + { + name: "strictMixedContentCheckingForPlugin", + initial: false, + }, + { + name: "strictPowerfulFeatureRestrictions", + initial: false, + }, + { + name: "strictlyBlockBlockableMixedContent", + initial: false, + }, + { + name: "allowGeolocationOnInsecureOrigins", + initial: false, + }, + { + name: "logDnsPrefetchAndPreconnect", + initial: false, + }, + { + name: "logPreload", + initial: false, + }, + { + name: "smoothScrollForFindEnabled", + initial: false, + }, + // These values specify the UA intial viewport style. + // It is dynamically set by the inspector for mobile emulation and can be + // used by content embedders to specify custom style on certain platforms. + { + name: "viewportStyle", + initial: "mojom::blink::ViewportStyle::kDefault", + invalidate: ["ViewportStyle"], + type: "mojom::blink::ViewportStyle", + include_paths: [ + "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h" + ], + }, + // Automatic track selection is performed based on user preference for track kind specified + // by this setting. + { + name: "textTrackKindUserPreference", + initial: "TextTrackKindUserPreference::kDefault", + invalidate: ["TextTrackKindUserPreference"], + type: "TextTrackKindUserPreference", + include_paths: [ + "third_party/blink/renderer/core/html/track/text_track_kind_user_preference.h" + ], + }, + // User style overrides for captions and subtitles + { + name: "textTrackBackgroundColor", + type: "String", + }, + { + name: "textTrackFontFamily", + type: "String", + }, + { + name: "textTrackFontStyle", + type: "String", + }, + { + name: "textTrackFontVariant", + type: "String", + }, + { + name: "textTrackTextColor", + type: "String", + }, + { + name: "textTrackTextShadow", + type: "String", + }, + { + name: "textTrackTextSize", + type: "String", + }, + { + name: "textTrackWindowColor", + type: "String", + }, + { + name: "textTrackWindowRadius", + type: "String", + }, + // Margin for title-safe placement of cues with overscan, gives top and bottom margin size as + // percentage of video element height (for horizontal text) into which cues will not be placed. + { + name: "textTrackMarginPercentage", + initial: 0, + type: "double", + }, + // Do we want to try to save screen real estate in the media player by hiding + // the volume slider / mute button? + { + name: "preferHiddenVolumeControls", + initial: false, + }, + // Whether to disallow network fetches for parser blocking scripts in the main + // frame inserted via document.write, for users on 2G or connections that are + // effectively 2G. + { + name: "disallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G", + initial: false, + }, + // Whether to disallow network fetches for parser blocking scripts in the main + // frame inserted via document.write, for users on slow connections. + { + name: "disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections", + initial: true, + }, + // Whether to disallow network fetches for parser blocking scripts in the main + // frame inserted via document.write, regardless of connection type. + { + name: "disallowFetchForDocWrittenScriptsInMainFrame", + initial: false, + }, + // Whether to invalidate device-dependent media queries and restore scroll positions + // on frame resize assuming device rotation. + { + name: "mainFrameResizesAreOrientationChanges", + initial: false, + }, + { + name: "hideScrollbars", + initial: false, + invalidate: ["ViewportPaintProperties"], + }, + // Spellchecking is enabled by default for elements that do not specify it explicitly + // using the "spellcheck" attribute. + { + name: "spellCheckEnabledByDefault", + initial: true, + }, + // Whether download UI should be hidden for the current page content. + { + name: "hideDownloadUI", + initial: false, + }, + // Whether the frame is a presentation receiver and should expose + // `navigator.presentation.receiver`. + { + name: "presentationReceiver", + initial: false, + }, + // Whether Blink should show media controls when `controls` attribute is used. + { + name: "mediaControlsEnabled", + initial: true, + invalidate: ["MediaControls"], + }, + // Whether we should not update selection attributes when mutating selection range. + // TODO(changwan): remove this flag when we no longer support Android M. + { + name: "doNotUpdateSelectionOnMutatingSelectionRange", + initial: false, + }, + // Defines the autoplay policy to use. + { + name: "autoplayPolicy", + type: "AutoplayPolicy::Type", + include_paths: ["third_party/blink/renderer/core/html/media/autoplay_policy.h"], + initial: "AutoplayPolicy::Type::kNoUserGestureRequired", + }, + // `getDisplayMedia()`'s transient activation requirement can be bypassed via + // `ScreenCaptureWithoutGestureAllowedForOrigins` policy. + { + name: "requireTransientActivationForGetDisplayMedia", + initial: true, + }, + // `show{OpenFile|SaveFile|Directory}Picker()`'s transient activation + // requirement can be bypassed via + // `FileOrDirectoryPickerWithoutGestureAllowedForOrigins` policy. + { + name: "requireTransientActivationForShowFileOrDirectoryPicker", + initial: true, + }, + // + // Dark mode + // + { + name: "forceDarkModeEnabled", + initial: false, + invalidate: ["ColorScheme", "Style", "Paint"], + }, + { + name: "navigatorPlatformOverride", + type: "String", + }, + { + name: "lowPriorityIframesThreshold", + initial: "WebEffectiveConnectionType::kTypeUnknown", + type: "WebEffectiveConnectionType", + include_paths: [ + "third_party/blink/public/platform/web_effective_connection_type.h" + ], + }, + { + name: "shouldProtectAgainstIpcFlooding", + initial: true, + }, + { + name: "lazyLoadEnabled", + initial: true, + }, + // + // Lazy loading frame margins (distance from viewport) for different effective connection types. + // + { + name: "lazyLoadingFrameMarginPxUnknown", + initial: 4000, + type: "int", + }, + { + name: "lazyLoadingFrameMarginPxOffline", + initial: 8000, + type: "int", + }, + { + name: "lazyLoadingFrameMarginPxSlow2G", + initial: 8000, + type: "int", + }, + { + name: "lazyLoadingFrameMarginPx2G", + initial: 6000, + type: "int", + }, + { + name: "lazyLoadingFrameMarginPx3G", + initial: 3500, + type: "int", + }, + { + name: "lazyLoadingFrameMarginPx4G", + initial: 2500, + type: "int", + }, + // + // Lazy loading image margins for different effective connection types. + // + { + name: "lazyLoadingImageMarginPxUnknown", + initial: 3000, + type: "int", + }, + { + name: "lazyLoadingImageMarginPxOffline", + initial: 8000, + type: "int", + }, + { + name: "lazyLoadingImageMarginPxSlow2G", + initial: 8000, + type: "int", + }, + { + name: "lazyLoadingImageMarginPx2G", + initial: 6000, + type: "int", + }, + { + name: "lazyLoadingImageMarginPx3G", + initial: 2500, + type: "int", + }, + { + name: "lazyLoadingImageMarginPx4G", + initial: 1250, + type: "int", + }, + // The forced colors state for the web content. The forced colors state + // is used to evaluate the forced-colors media query, as well as determining + // when to apply system color overrides to author specified styles. + { + name: "inForcedColors", + initial: false, + type: "bool", + }, + { + name: "isForcedColorsDisabled", + initial: false, + invalidate: ["ForcedColors"], + type: "bool", + }, + // Holds the browser's theme color to be used to render root non-overlay + // Fluent scrollbars. Stored from an SkColor as ARGB. + { + name: "rootScrollbarThemeColor", + initial: "std::nullopt", + invalidate: ["Paint"], + type: "std::optional", + }, + // The preferred color scheme set by the user's browser settings. The + // variable follows the browser's color mode setting unless a browser theme + // (custom or not) is defined, in which case the color scheme is set to the + // default value. This value is used to evaluate the used color scheme in + // non overlay root scrollbars. + { + name: "preferredRootScrollbarColorScheme", + initial: "mojom::blink::PreferredColorScheme::kLight", + invalidate: ["Paint"], + type: "mojom::blink::PreferredColorScheme", + include_paths: [ + "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h" + ], + }, + // Preferred color scheme from the OS/application passed to the renderer for + // evaluating the prefers-color-scheme media query. + { + name: "preferredColorScheme", + initial: "mojom::blink::PreferredColorScheme::kLight", + invalidate: ["ColorScheme"], + type: "mojom::blink::PreferredColorScheme", + include_paths: [ + "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h" + ], + }, + // Preferred contrast from the OS/application passed to the renderer for + // evaluating the prefers-contrast media query. + { + name: "preferredContrast", + initial: "mojom::blink::PreferredContrast::kNoPreference", + invalidate: ["MediaQuery"], + type: "mojom::blink::PreferredContrast", + include_paths: [ + "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h" + ], + }, + // Preferred motion-reduction setting from the OS/application passed to the + // renderer for evaluating the prefers-reduced-motion media query. + { + name: "prefersReducedMotion", + initial: false, + invalidate: ["MediaQuery"], + }, + // Preferred transparency-reduction setting from the OS/application passed to the + // renderer for evaluating the prefers-reduced-transparency media query. + { + name: "prefersReducedTransparency", + initial: false, + invalidate: ["MediaQuery"], + }, + // inverted-colors setting from the OS/application passed to the + // renderer for evaluating the inverted-colors media query. + { + name: "invertedColors", + initial: false, + invalidate: ["MediaQuery"], + }, + { + name: "DontSendKeyEventsToJavascript", + initial: false, + }, + // Navigation controls from the application passed to the renderer for + // evaluating the navigation-controls media query. + { + name: "navigationControls", + initial: "NavigationControls::kNone", + invalidate: ["MediaQuery"], + type: "NavigationControls", + include_paths: [ + "third_party/blink/public/common/css/navigation_controls.h" + ], + }, + { + name: "accessibilityAlwaysShowFocus", + initial: false, + invalidate: ["Style"], + }, + // aria-modal="true" on some platforms requires the accessibility tree to + // be pruned so no other background content is exposed to assistive + // technology. + // https://www.w3.org/TR/core-aam-1.1/#ariaModalTrue + { + name: "ariaModalPrunesAXTree", + initial: false, + }, + // The AXMenuList class provides a fake implementation of the + // select element pop-up menu, which is required on platforms like + // Mac and Android that use a native pop-up. On other platforms you + // can set this flag to false and expose the actual pop-up menu + // instead of letting AXMenuList handle it. + { + name: "useAXMenuList", + initial: true, + }, + { + name: "selectionClipboardBufferAvailable", + initial: false, + }, + { + name: "accessibilityIncludeSvgGElement", + initial: false, + }, + { + name: "bypassCSP", + initial: false, + }, + // Enables automatic adjustments of text size on mobile. This enables the + // text autosizer, and controls whether text-size-adjust can apply. + { + name: "textAutosizingEnabled", + initial: false, + invalidate: ["TextAutosizing"], + }, + // Only set by web tests, and only used if textAutosizingEnabled is true. + { + name: "textAutosizingWindowSizeOverride", + invalidate: ["TextAutosizing"], + type: "gfx::Size", + include_paths: ["ui/gfx/geometry/size.h"], + }, + { + name: "WebXRImmersiveArAllowed", + initial: true, + type: "bool", + }, + { + name: "modalContextMenu", + initial: true, + type: "bool", + }, + { + // This number determines how small we are willing to reduce the page + // content in order to accommodate the widest piece of content. If the + // page would have to be reduced smaller to make the widest line fit, we + // just clip instead. + name: "printingMaximumShrinkFactor", + initial: 1.5, + type: "float", + }, + { + name: "prefersDefaultScrollbarStyles", + initial: false, + invalidate: ["Style"], + type: "bool", + }, + // SubApps APIs transient activation requirement can be bypassed via + // `SubAppsAPIsAllowedWithoutGestureAndAuthorizationForOrigins` policy. + { + name: "requireTransientActivationAndAuthorizationForSubAppsAPI", + initial: true, + }, + // Enable the features to change the safe-area-inset* CSS environment + // variables based on the browser controls's shown ration. + { + name: "dynamicSafeAreaInsetsEnabled", + initial: false, + type: "bool" + }, + ], +} \ No newline at end of file diff --git a/lib/src/test/resources/harmonyos-ide-hvigor-build-profile-V13.json5 b/lib/src/test/resources/harmonyos-ide-hvigor-build-profile-V13.json5 new file mode 100644 index 0000000..e10e2e1 --- /dev/null +++ b/lib/src/test/resources/harmonyos-ide-hvigor-build-profile-V13.json5 @@ -0,0 +1,130 @@ +{ + "app": { + // Signature information of the project. Multiple signatures can be included. + "signingConfigs": [ + { + "name": "default", // Name of the signature scheme, which can be customized + "type": "HarmonyOS", // Identifier of the app, which is HarmonyOS. + // Material of the signature scheme. + "material": { + "certpath": "D:\\SigningConfig\\debug_hos.cer", // Debug or release certificate file in .cer format. + "storePassword": "******", // Keystore password, which is displayed in ciphertext. + "keyAlias": "debugKey", // Key alias. + "keyPassword": "******", // Key password, which is displayed in ciphertext. + "profile": "D:\\SigningConfig\\debug_hos.p7b", // Debug or release profile file in .p7b format. + "signAlg": "SHA256withECDSA", // Keystore signing algorithm. + "storeFile": "D:\\SigningConfig\\debug_hos.p12" // Keystore file in .p12 format. + } + } + ], + // Product category, such as the general default edition, paid edition, and free edition. + "products": [ + { + "name": "default", // Product name. Multiple custom products can be configured. + "signingConfig": "default", // Signature information for the current product. It must be defined in signingConfigs. + "compatibleSdkVersion": "5.0.1(13)", // Earliest version compatible with the app/atomic service. + "targetSdkVersion": "5.0.1(13)", // Target version of the app/atomic service. + "runtimeOS": "HarmonyOS", // Runtime operating system. + } + ], + // Build mode set. Each build mode refers to a collection of build configurations used for a target task. By default, debug is used for HAP packing, and release is used for app packing. + "buildModeSet": [ + { + "name": "debug", // Type name of the build mode. Three values are provided by default: test, debug, and release. You can also customize the type name. + "buildOption": { // Related configuration used during build. + "packOptions": { // Packing configuration, which can be used to avoid generating a signed HAP during app build. + "buildAppSkipSignHap": false + }, + "debuggable": true, + "resOptions": { + "compression": { + "media": { + "enable": true // Set whether to enable texture compression for media images. + }, + // File filter for texture compression, which is optional. If it is not specified, texture compression is performed on all images in the resource directory. + "filters": [ + { + "method": { + "type": "sut", // Conversion type. + "blocks": "4x4" // Extended parameter of the conversion type. + }, + // Specify the files to be compressed. Only the files that meet all conditions and are not filtered by exclude can be compressed. + "files": { + "path": ["./**/*"], // Specify all files in the resource directory. + "size": [[0, '10k']], // Specify files smaller than 10 KB. + // Specify images with a resolution less than 2048 x 2048. + "resolution": [ + [ + { "width": 0, "height": 0 }, // Minimum width and height. + { "width": 2048, "height": 2048 } // Maximum width and height. + ] + ] + }, + // Exclude files from files that do not need to be compressed; only files that meet all filtering conditions are excluded. + "exclude": { + "path": ["./**/*.jpg"], // Filter out all .jpg files. + "size": [[0, '1k']], // Filter out files smaller than 1 KB. + // Filter out images with a resolution less than 1024 x 1024. + "resolution": [ + [ + { "width": 0, "height": 0 }, // Minimum width and height. + { "width": 1024, "height": 1024 } // Maximum width and height. + ] + ] + } + } + ] + } + }, + // CPP compilation configuration. + "externalNativeOptions": { + "path": "./entry/src/main/cpp/CMakeLists.txt", // Path of the CMake configuration file, which provides the CMake build script. + "arguments": [], // Optional build parameters passed to CMake. + "abiFilters": [ // Supported ABI build environment. + "arm64-v8a", + "x86_64" + ], + "cppFlags": "" // Optional parameters of the C++ compiler. + }, + "sourceOption": { // Different tags are used to classify source code so that different source code can be processed differently during build. + "workers": [] + }, + // Rule for filtering the .so resource files on which the HAR depends. + "nativeLib": { + "filter": { + // Pack the .so file with the highest priority based on the priority of the .so files. + "pickFirsts": [ + "**/1.so" + ], + // Pack the .so file with the lowest priority based on the priority of the .so files. + "pickLasts": [ + "**/2.so" + ], + // Exclude .so files that match the regular expression. The matches are not be packaged. + "excludes": [ + "**/3.so", // Exclude all .so files whose names are 3. + "**/x86_64/*.so" // Exclude all .so files of the x86_64 architecture. + ], + // Allow the .so file with a higher priority to overwrite the .so file with a lower priority when these files have the same name. + "enableOverride": true + } + }, + } + } + ] + }, + "modules": [ + { + "name": "entry", // Module name, which must be the same as module.name in the module.json5 file of the module. + "srcPath": "./entry", // Path of the module root directory relative to the project root directory. + "targets": [ // App Pack build targets, jointly defined by product and module-level targets settings. + { + "name": "default", // Name of the build targets, defined by the targets item in the module-level build-profile.json5 file. + "applyToProducts": [ + "default" // Product to which the default target of the module will be packed. + ] + } + ] + } + ] +} \ No newline at end of file