diff --git a/front_end/core/root/Runtime.ts b/front_end/core/root/Runtime.ts index f6da68183ed6476998867dc6853a3ce0f5b7abc2..a90c6cea8f4492356b20196a9082a5333bc042c5 100644 --- a/front_end/core/root/Runtime.ts +++ b/front_end/core/root/Runtime.ts @@ -319,4 +319,7 @@ export enum ExperimentName { export enum ConditionName { CAN_DOCK = 'can_dock', NOT_SOURCES_HIDE_ADD_FOLDER = '!sources.hide_add_folder', + // #ifdef OHOS_DEVTOOLS + USE_ORIGNAL = 'use_orignal', + // #endif OHOS_DEVTOOLS } diff --git a/front_end/entrypoints/devtools_app/devtools_app.ts b/front_end/entrypoints/devtools_app/devtools_app.ts index 2982e4ebbd33cca61d388c7b6738a725eddf8e9c..b2a58eeb21c1fbadbc2f7e16c58a9a0a16d6fe31 100644 --- a/front_end/entrypoints/devtools_app/devtools_app.ts +++ b/front_end/entrypoints/devtools_app/devtools_app.ts @@ -2,27 +2,39 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import '../shell/shell.js'; -import '../../panels/css_overview/css_overview-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/css_overview/css_overview-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/elements/elements-meta.js'; import '../../panels/browser_debugger/browser_debugger-meta.js'; import '../../panels/network/network-meta.js'; -import '../../panels/security/security-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/security/security-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/emulation/emulation-meta.js'; import '../../panels/sensors/sensors-meta.js'; import '../../panels/accessibility/accessibility-meta.js'; -import '../../panels/animation/animation-meta.js'; -import '../../panels/developer_resources/developer_resources-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/animation/animation-meta.js'; +//import '../../panels/developer_resources/developer_resources-meta.js'; +// #endif OHOS_DEVTOOLS import '../inspector_main/inspector_main-meta.js'; import '../../panels/application/application-meta.js'; import '../../panels/issues/issues-meta.js'; -import '../../panels/layers/layers-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/layers/layers-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/lighthouse/lighthouse-meta.js'; -import '../../panels/media/media-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/media/media-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/mobile_throttling/mobile_throttling-meta.js'; import '../../panels/performance_monitor/performance_monitor-meta.js'; import '../../panels/timeline/timeline-meta.js'; -import '../../panels/web_audio/web_audio-meta.js'; -import '../../panels/webauthn/webauthn-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/web_audio/web_audio-meta.js'; +//import '../../panels/webauthn/webauthn-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/layer_viewer/layer_viewer-meta.js'; import * as Root from '../../core/root/root.js'; diff --git a/front_end/entrypoints/main/MainImpl.ts b/front_end/entrypoints/main/MainImpl.ts index 0913afa67d295c6c3d8b78fe498560c6430faecd..f85d05ab83e4d6cb78749ac618ac9f4be525786a 100644 --- a/front_end/entrypoints/main/MainImpl.ts +++ b/front_end/entrypoints/main/MainImpl.ts @@ -280,23 +280,42 @@ export class MainImpl { Root.Runtime.experiments.register( 'ignoreListJSFramesOnTimeline', 'Ignore List for JavaScript frames on Timeline', true); Root.Runtime.experiments.register('liveHeapProfile', 'Live heap profile', true); - Root.Runtime.experiments.register( - 'protocolMonitor', 'Protocol Monitor', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-92/#protocol-monitor'); - Root.Runtime.experiments.register('developerResourcesView', 'Show developer resources view'); - Root.Runtime.experiments.register( - 'cspViolationsView', 'Show CSP Violations view', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-89/#csp'); - Root.Runtime.experiments.register('samplingHeapProfilerTimeline', 'Sampling heap profiler timeline', true); - Root.Runtime.experiments.register( - 'showOptionToExposeInternalsInHeapSnapshot', 'Show option to expose internals in heap snapshots'); - Root.Runtime.experiments.register( - 'sourceOrderViewer', 'Source order viewer', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-92/#source-order'); - Root.Runtime.experiments.register('webauthnPane', 'WebAuthn Pane'); - Root.Runtime.experiments.register( - 'keyboardShortcutEditor', 'Enable keyboard shortcut editor', false, - 'https://developer.chrome.com/blog/new-in-devtools-88/#keyboard-shortcuts'); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + Root.Runtime.experiments.register( + 'protocolMonitor', 'Protocol Monitor'); + Root.Runtime.experiments.register('developerResourcesView', 'Show developer resources view'); + Root.Runtime.experiments.register( + 'cspViolationsView', 'Show CSP Violations view'); + Root.Runtime.experiments.register('samplingHeapProfilerTimeline', 'Sampling heap profiler timeline', true); + Root.Runtime.experiments.register( + 'showOptionToExposeInternalsInHeapSnapshot', 'Show option to expose internals in heap snapshots'); + Root.Runtime.experiments.register( + 'sourceOrderViewer', 'Source order viewer'); + Root.Runtime.experiments.register('webauthnPane', 'WebAuthn Pane'); + Root.Runtime.experiments.register( + 'keyboardShortcutEditor', 'Enable keyboard shortcut editor'); + } else { + Root.Runtime.experiments.register( + 'protocolMonitor', 'Protocol Monitor', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-92/#protocol-monitor'); + Root.Runtime.experiments.register('developerResourcesView', 'Show developer resources view'); + Root.Runtime.experiments.register( + 'cspViolationsView', 'Show CSP Violations view', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-89/#csp'); + Root.Runtime.experiments.register('samplingHeapProfilerTimeline', 'Sampling heap profiler timeline', true); + Root.Runtime.experiments.register( + 'showOptionToExposeInternalsInHeapSnapshot', 'Show option to expose internals in heap snapshots'); + Root.Runtime.experiments.register( + 'sourceOrderViewer', 'Source order viewer', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-92/#source-order'); + Root.Runtime.experiments.register('webauthnPane', 'WebAuthn Pane'); + Root.Runtime.experiments.register( + 'keyboardShortcutEditor', 'Enable keyboard shortcut editor', false, + 'https://developer.chrome.com/blog/new-in-devtools-88/#keyboard-shortcuts'); + } + // #endif OHOS_DEVTOOLS // Back/forward cache Root.Runtime.experiments.register( @@ -312,56 +331,101 @@ export class MainImpl { 'timelineAsConsoleProfileResultPanel', 'View console.profile() results in the Performance panel for Node.js', true); - // JS Profiler - Root.Runtime.experiments.register( + // #ifdef OHOS_DEVTOOLS + if (adaptForOhos) { + // JS Profiler + Root.Runtime.experiments.register( + 'jsProfilerTemporarilyEnable', 'Enable JavaScript Profiler temporarily'); + + // Debugging + Root.Runtime.experiments.register( + 'wasmDWARFDebugging', 'WebAssembly Debugging: Enable DWARF support'); + Root.Runtime.experiments.register( + 'evaluateExpressionsWithSourceMaps', 'Console: Resolve variable names in expressions using source maps', + undefined); + Root.Runtime.experiments.register('instrumentationBreakpoints', 'Enable instrumentation breakpoints', true); + + // Dual-screen + Root.Runtime.experiments.register( + 'dualScreenSupport', 'Emulation: Support dual screen mode'); + Root.Runtime.experiments.setEnabled('dualScreenSupport', true); + + // Advanced Perceptual Contrast Algorithm. + Root.Runtime.experiments.register( + 'APCA', + 'Enable new Advanced Perceptual Contrast Algorithm (APCA) replacing previous contrast ratio and AA/AAA guidelines'); + + // Full Accessibility Tree + Root.Runtime.experiments.register( + 'fullAccessibilityTree', 'Enable full accessibility tree view in the Elements panel'); + + // Font Editor + Root.Runtime.experiments.register( + 'fontEditor', 'Enable new Font Editor tool within the Styles Pane.'); + + // Contrast issues reported via the Issues panel. + Root.Runtime.experiments.register( + 'contrastIssues', 'Enable automatic contrast issue reporting via the Issues panel'); + + // New cookie features. + Root.Runtime.experiments.register('experimentalCookieFeatures', 'Enable experimental cookie features'); + + // CSS authoring tool. + Root.Runtime.experiments.register( + 'cssTypeComponentLength', 'Enable CSS authoring tool in the Styles pane'); + } else { + // JS Profiler + Root.Runtime.experiments.register( 'jsProfilerTemporarilyEnable', 'Enable JavaScript Profiler temporarily', /* unstable= */ false, 'https://developer.chrome.com/blog/js-profiler-deprecation/', 'https://bugs.chromium.org/p/chromium/issues/detail?id=1354548'); - // Debugging - Root.Runtime.experiments.register( - 'wasmDWARFDebugging', 'WebAssembly Debugging: Enable DWARF support', undefined, - 'https://developer.chrome.com/blog/wasm-debugging-2020/'); - Root.Runtime.experiments.register( - 'evaluateExpressionsWithSourceMaps', 'Console: Resolve variable names in expressions using source maps', - undefined); - Root.Runtime.experiments.register('instrumentationBreakpoints', 'Enable instrumentation breakpoints', true); - - // Dual-screen - Root.Runtime.experiments.register( - 'dualScreenSupport', 'Emulation: Support dual screen mode', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-89#dual-screen'); - Root.Runtime.experiments.setEnabled('dualScreenSupport', true); - - // Advanced Perceptual Contrast Algorithm. - Root.Runtime.experiments.register( - 'APCA', - 'Enable new Advanced Perceptual Contrast Algorithm (APCA) replacing previous contrast ratio and AA/AAA guidelines', - undefined, 'https://developer.chrome.com/blog/new-in-devtools-89/#apca'); - - // Full Accessibility Tree - Root.Runtime.experiments.register( - 'fullAccessibilityTree', 'Enable full accessibility tree view in the Elements panel', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-90/#accesibility-tree', - 'https://g.co/devtools/a11y-tree-feedback'); - - // Font Editor - Root.Runtime.experiments.register( - 'fontEditor', 'Enable new Font Editor tool within the Styles Pane.', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-89/#font'); - - // Contrast issues reported via the Issues panel. - Root.Runtime.experiments.register( - 'contrastIssues', 'Enable automatic contrast issue reporting via the Issues panel', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-90/#low-contrast'); - - // New cookie features. - Root.Runtime.experiments.register('experimentalCookieFeatures', 'Enable experimental cookie features'); - - // CSS authoring tool. - Root.Runtime.experiments.register( - 'cssTypeComponentLength', 'Enable CSS authoring tool in the Styles pane', undefined, - 'https://developer.chrome.com/blog/new-in-devtools-96/#length', 'https://g.co/devtools/length-feedback'); + // Debugging + Root.Runtime.experiments.register( + 'wasmDWARFDebugging', 'WebAssembly Debugging: Enable DWARF support', undefined, + 'https://developer.chrome.com/blog/wasm-debugging-2020/'); + Root.Runtime.experiments.register( + 'evaluateExpressionsWithSourceMaps', 'Console: Resolve variable names in expressions using source maps', + undefined); + Root.Runtime.experiments.register('instrumentationBreakpoints', 'Enable instrumentation breakpoints', true); + + // Dual-screen + Root.Runtime.experiments.register( + 'dualScreenSupport', 'Emulation: Support dual screen mode', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-89#dual-screen'); + Root.Runtime.experiments.setEnabled('dualScreenSupport', true); + + // Advanced Perceptual Contrast Algorithm. + Root.Runtime.experiments.register( + 'APCA', + 'Enable new Advanced Perceptual Contrast Algorithm (APCA) replacing previous contrast ratio and AA/AAA guidelines', + undefined, 'https://developer.chrome.com/blog/new-in-devtools-89/#apca'); + + // Full Accessibility Tree + Root.Runtime.experiments.register( + 'fullAccessibilityTree', 'Enable full accessibility tree view in the Elements panel', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-90/#accesibility-tree', + 'https://g.co/devtools/a11y-tree-feedback'); + + // Font Editor + Root.Runtime.experiments.register( + 'fontEditor', 'Enable new Font Editor tool within the Styles Pane.', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-89/#font'); + + // Contrast issues reported via the Issues panel. + Root.Runtime.experiments.register( + 'contrastIssues', 'Enable automatic contrast issue reporting via the Issues panel', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-90/#low-contrast'); + + // New cookie features. + Root.Runtime.experiments.register('experimentalCookieFeatures', 'Enable experimental cookie features'); + + // CSS authoring tool. + Root.Runtime.experiments.register( + 'cssTypeComponentLength', 'Enable CSS authoring tool in the Styles pane', undefined, + 'https://developer.chrome.com/blog/new-in-devtools-96/#length', 'https://g.co/devtools/length-feedback'); + } + // #endif OHOS_DEVTOOLS // Display precise changes in the Changes tab. Root.Runtime.experiments.register( @@ -385,10 +449,18 @@ export class MainImpl { Root.Runtime.experiments.register( Root.Runtime.ExperimentName.EYEDROPPER_COLOR_PICKER, 'Enable color picking outside the browser window'); - // Change grouping of sources panel to use Authored/Deployed trees - Root.Runtime.experiments.register( - Root.Runtime.ExperimentName.AUTHORED_DEPLOYED_GROUPING, 'Group sources into Authored and Deployed trees', - undefined, 'https://goo.gle/authored-deployed', 'https://goo.gle/authored-deployed-feedback'); + // #ifdef OHOS_DEVTOOLS + if (adaptForOhos) { + // Change grouping of sources panel to use Authored/Deployed trees + Root.Runtime.experiments.register( + Root.Runtime.ExperimentName.AUTHORED_DEPLOYED_GROUPING, 'Group sources into Authored and Deployed trees'); + } else { + // Change grouping of sources panel to use Authored/Deployed trees + Root.Runtime.experiments.register( + Root.Runtime.ExperimentName.AUTHORED_DEPLOYED_GROUPING, 'Group sources into Authored and Deployed trees', + undefined, 'https://goo.gle/authored-deployed', 'https://goo.gle/authored-deployed-feedback'); + } + // #endif OHOS_DEVTOOLS // Hide third party code (as determined by ignore lists or source maps) Root.Runtime.experiments.register( @@ -915,9 +987,16 @@ export class MainMenuItem implements UI.Toolbar.Provider { right.setToggled(UI.DockController.DockController.instance().dockSide() === UI.DockController.DockState.RIGHT); left.setToggled(UI.DockController.DockController.instance().dockSide() === UI.DockController.DockState.LEFT); dockItemToolbar.appendToolbarItem(undock); - dockItemToolbar.appendToolbarItem(left); - dockItemToolbar.appendToolbarItem(bottom); - dockItemToolbar.appendToolbarItem(right); + // #ifdef OHOS_DEVTOOLS + const onlySupportUndock = true; + if (onlySupportUndock) { + // ohos doesn't support dock side. + } else { + dockItemToolbar.appendToolbarItem(left); + dockItemToolbar.appendToolbarItem(bottom); + dockItemToolbar.appendToolbarItem(right); + } + // #endif OHOS_DEVTOOLS dockItemElement.addEventListener('keydown', event => { let dir = 0; if (event.key === 'ArrowLeft') { @@ -932,6 +1011,14 @@ export class MainMenuItem implements UI.Toolbar.Provider { return; } + // #ifdef OHOS_DEVTOOLS + const onlySupportUndock = true; + if (onlySupportUndock) { + // ohos doesn't support dock side. + dir = 0; + } + // #endif OHOS_DEVTOOLS + const buttons = [undock, left, bottom, right]; let index = buttons.findIndex(button => button.element.hasFocus()); index = Platform.NumberUtilities.clamp(index + dir, 0, buttons.length - 1); @@ -1007,8 +1094,15 @@ export class MainMenuItem implements UI.Toolbar.Provider { }); } - const helpSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.help)); - helpSubMenu.appendItemsAtLocation('mainMenuHelp'); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const helpSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.help)); + helpSubMenu.appendItemsAtLocation('mainMenuHelp'); + } + // #endif OHOS_DEVTOOLS } } diff --git a/front_end/entrypoints/main/main-meta.ts b/front_end/entrypoints/main/main-meta.ts index 6a34eae699053100b7888d910a2c27a25425c231..5e3f8727267fbb7199089e7a5cec0b0af91ca756 100644 --- a/front_end/entrypoints/main/main-meta.ts +++ b/front_end/entrypoints/main/main-meta.ts @@ -13,6 +13,9 @@ import type * as InspectorMain from '../inspector_main/inspector_main.js'; import type * as Main from './main.js'; import * as i18n from '../../core/i18n/i18n.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS const UIStrings = { /** *@description Text in Main @@ -730,7 +733,9 @@ Common.Settings.registerSettingExtension({ category: Common.Settings.SettingCategory.GLOBAL, settingName: 'currentDockState', settingType: Common.Settings.SettingType.ENUM, - defaultValue: 'right', + // DevTools stage 1 : use 'undocked' as default. + defaultValue: 'undocked', + // defaultValue: 'right', options: [ { value: 'right', @@ -920,18 +925,24 @@ UI.Toolbar.registerToolbarItem({ experiment: Root.Runtime.ExperimentName.OUTERMOST_TARGET_SELECTOR, }); -UI.Toolbar.registerToolbarItem({ - async loadItem() { - const Main = await loadMainModule(); - return Main.MainImpl.SettingsButtonProvider.instance(); - }, - order: 99, - location: UI.Toolbar.ToolbarItemLocation.MAIN_TOOLBAR_RIGHT, - showLabel: undefined, - condition: undefined, - separator: undefined, - actionId: undefined, -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb does't support settings. +} else { + UI.Toolbar.registerToolbarItem({ + async loadItem() { + const Main = await loadMainModule(); + return Main.MainImpl.SettingsButtonProvider.instance(); + }, + order: 99, + location: UI.Toolbar.ToolbarItemLocation.MAIN_TOOLBAR_RIGHT, + showLabel: undefined, + condition: undefined, + separator: undefined, + actionId: undefined, + }); +} +// #endif OHOS_DEVTOOLS UI.Toolbar.registerToolbarItem({ async loadItem() { diff --git a/front_end/entrypoints/shell/shell.ts b/front_end/entrypoints/shell/shell.ts index b22591ee606ef449817aef1f9bd5ff0c024d1c05..97e0a94d33a64632840757429214487fb2bba221 100644 --- a/front_end/entrypoints/shell/shell.ts +++ b/front_end/entrypoints/shell/shell.ts @@ -8,11 +8,15 @@ import '../../core/dom_extension/dom_extension.js'; import '../../panels/sources/sources-meta.js'; import '../../panels/profiler/profiler-meta.js'; import '../../panels/console/console-meta.js'; -import '../../panels/coverage/coverage-meta.js'; -import '../../panels/changes/changes-meta.js'; -import '../../ui/components/linear_memory_inspector/linear_memory_inspector-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/coverage/coverage-meta.js'; +//import '../../panels/changes/changes-meta.js'; +//import '../../ui/components/linear_memory_inspector/linear_memory_inspector-meta.js'; +// #endif OHOS_DEVTOOLS import '../../panels/settings/settings-meta.js'; -import '../../panels/protocol_monitor/protocol_monitor-meta.js'; +// #ifdef OHOS_DEVTOOLS +//import '../../panels/protocol_monitor/protocol_monitor-meta.js'; +// #endif OHOS_DEVTOOLS import '../../models/persistence/persistence-meta.js'; import '../../models/logs/logs-meta.js'; import '../main/main-meta.js'; diff --git a/front_end/panels/application/AppManifestView.ts b/front_end/panels/application/AppManifestView.ts index 18665325e983262dac6465c2e839e5817f25b626..53c6d3fd6bdd8a9db187d475032fcc1542afa578 100644 --- a/front_end/panels/application/AppManifestView.ts +++ b/front_end/panels/application/AppManifestView.ts @@ -425,7 +425,14 @@ export class AppManifestView extends UI.Widget.VBox implements SDK.TargetManager .addChangeListener(this.updateManifest.bind(this, true)); this.emptyView = emptyView; - this.emptyView.appendLink('https://web.dev/add-manifest/' as Platform.DevToolsPath.UrlString); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + this.emptyView.appendLink('https://web.dev/add-manifest/' as Platform.DevToolsPath.UrlString); + } + // #endif OHOS_DEVTOOLS this.emptyView.show(this.contentElement); this.emptyView.hideWidget(); @@ -604,8 +611,15 @@ export class AppManifestView extends UI.Widget.VBox implements SDK.TargetManager helpIcon.tabIndex = 0; appIdField.appendChild(helpIcon); - appIdField.appendChild(UI.XLink.XLink.create( + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + appIdField.appendChild(UI.XLink.XLink.create( 'https://developer.chrome.com/blog/pwa-manifest-id/', i18nString(UIStrings.learnMore), 'learn-more')); + } + // #endif OHOS_DEVTOOLS if (!stringProperty('id')) { const suggestedIdNote = appIdField.createChild('div', 'multiline-value'); @@ -732,10 +746,17 @@ export class AppManifestView extends UI.Widget.VBox implements SDK.TargetManager this.iconsSection.setIconMasked(setIconMaskedCheckbox.checkboxElement.checked); }); this.iconsSection.appendRow().appendChild(setIconMaskedCheckbox); - const documentationLink = - UI.XLink.XLink.create('https://web.dev/maskable-icon/', i18nString(UIStrings.documentationOnMaskableIcons)); - this.iconsSection.appendRow().appendChild( - i18n.i18n.getFormatLocalizedString(str_, UIStrings.needHelpReadOurS, {PH1: documentationLink})); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const documentationLink = + UI.XLink.XLink.create('https://web.dev/maskable-icon/', i18nString(UIStrings.documentationOnMaskableIcons)); + this.iconsSection.appendRow().appendChild( + i18n.i18n.getFormatLocalizedString(str_, UIStrings.needHelpReadOurS, {PH1: documentationLink})); + } + // #endif OHOS_DEVTOOLS let squareSizedIconAvailable = false; for (const icon of icons) { diff --git a/front_end/panels/application/ApplicationPanelSidebar.ts b/front_end/panels/application/ApplicationPanelSidebar.ts index 4e440a8a09f43962dfa9a5499f388e4bcce2156c..cb186b35e22b6dbec950d81bc507e0cfbd3e3aea 100644 --- a/front_end/panels/application/ApplicationPanelSidebar.ts +++ b/front_end/panels/application/ApplicationPanelSidebar.ts @@ -308,48 +308,75 @@ export class ApplicationPanelSidebar extends UI.Widget.VBox implements SDK.Targe const clearStorageTreeElement = new ClearStorageTreeElement(panel); this.applicationTreeElement.appendChild(clearStorageTreeElement); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; const storageSectionTitle = i18nString(UIStrings.storage); const storageTreeElement = this.addSidebarSection(storageSectionTitle); - this.localStorageListTreeElement = - new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.localStorage), 'LocalStorage'); - this.localStorageListTreeElement.setLink( - 'https://developer.chrome.com/docs/devtools/storage/localstorage/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); const localStorageIcon = UI.Icon.Icon.create('table', 'resource-tree-item'); - this.localStorageListTreeElement.setLeadingIcons([localStorageIcon]); - - storageTreeElement.appendChild(this.localStorageListTreeElement); - this.sessionStorageListTreeElement = - new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.sessionStorage), 'SessionStorage'); - this.sessionStorageListTreeElement.setLink( - 'https://developer.chrome.com/docs/devtools/storage/sessionstorage/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); const sessionStorageIcon = UI.Icon.Icon.create('table', 'resource-tree-item'); - this.sessionStorageListTreeElement.setLeadingIcons([sessionStorageIcon]); - - storageTreeElement.appendChild(this.sessionStorageListTreeElement); - this.indexedDBListTreeElement = new IndexedDBTreeElement(panel); - this.indexedDBListTreeElement.setLink( - 'https://developer.chrome.com/docs/devtools/storage/indexeddb/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); - storageTreeElement.appendChild(this.indexedDBListTreeElement); - this.databasesListTreeElement = - new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.webSql), 'Databases'); - this.databasesListTreeElement.setLink( - 'https://developer.chrome.com/docs/devtools/storage/websql/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); const databaseIcon = UI.Icon.Icon.create('database', 'resource-tree-item'); - this.databasesListTreeElement.setLeadingIcons([databaseIcon]); - - storageTreeElement.appendChild(this.databasesListTreeElement); - this.cookieListTreeElement = - new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.cookies), 'Cookies'); - this.cookieListTreeElement.setLink( - 'https://developer.chrome.com/docs/devtools/storage/cookies/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); const cookieIcon = UI.Icon.Icon.create('cookie', 'resource-tree-item'); - this.cookieListTreeElement.setLeadingIcons([cookieIcon]); - storageTreeElement.appendChild(this.cookieListTreeElement); + if (adaptForOhos) { + this.localStorageListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.localStorage), 'LocalStorage'); + this.localStorageListTreeElement.setLeadingIcons([localStorageIcon]); + + storageTreeElement.appendChild(this.localStorageListTreeElement); + this.sessionStorageListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.sessionStorage), 'SessionStorage'); + this.sessionStorageListTreeElement.setLeadingIcons([sessionStorageIcon]); + + storageTreeElement.appendChild(this.sessionStorageListTreeElement); + this.indexedDBListTreeElement = new IndexedDBTreeElement(panel); + storageTreeElement.appendChild(this.indexedDBListTreeElement); + this.databasesListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.webSql), 'Databases'); + this.databasesListTreeElement.setLeadingIcons([databaseIcon]); + + storageTreeElement.appendChild(this.databasesListTreeElement); + this.cookieListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.cookies), 'Cookies'); + this.cookieListTreeElement.setLeadingIcons([cookieIcon]); + storageTreeElement.appendChild(this.cookieListTreeElement); + } else { + this.localStorageListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.localStorage), 'LocalStorage'); + this.localStorageListTreeElement.setLink( + 'https://developer.chrome.com/docs/devtools/storage/localstorage/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + this.localStorageListTreeElement.setLeadingIcons([localStorageIcon]); + + storageTreeElement.appendChild(this.localStorageListTreeElement); + this.sessionStorageListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.sessionStorage), 'SessionStorage'); + this.sessionStorageListTreeElement.setLink( + 'https://developer.chrome.com/docs/devtools/storage/sessionstorage/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + this.sessionStorageListTreeElement.setLeadingIcons([sessionStorageIcon]); + + storageTreeElement.appendChild(this.sessionStorageListTreeElement); + this.indexedDBListTreeElement = new IndexedDBTreeElement(panel); + this.indexedDBListTreeElement.setLink( + 'https://developer.chrome.com/docs/devtools/storage/indexeddb/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + storageTreeElement.appendChild(this.indexedDBListTreeElement); + this.databasesListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.webSql), 'Databases'); + this.databasesListTreeElement.setLink( + 'https://developer.chrome.com/docs/devtools/storage/websql/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + this.databasesListTreeElement.setLeadingIcons([databaseIcon]); + + storageTreeElement.appendChild(this.databasesListTreeElement); + this.cookieListTreeElement = + new ExpandableApplicationPanelTreeElement(panel, i18nString(UIStrings.cookies), 'Cookies'); + this.cookieListTreeElement.setLink( + 'https://developer.chrome.com/docs/devtools/storage/cookies/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + this.cookieListTreeElement.setLeadingIcons([cookieIcon]); + storageTreeElement.appendChild(this.cookieListTreeElement); + } + // #endif OHOS_DEVTOOLS this.trustTokensTreeElement = new TrustTokensTreeElement(panel); storageTreeElement.appendChild(this.trustTokensTreeElement); diff --git a/front_end/panels/application/BackgroundServiceView.ts b/front_end/panels/application/BackgroundServiceView.ts index 177f4b302c4d1f37b66e5ac9a4cbfc62725bc7ac..280481f67ee999546107bd73b6c8d39a48bb25fb 100644 --- a/front_end/panels/application/BackgroundServiceView.ts +++ b/front_end/panels/application/BackgroundServiceView.ts @@ -485,8 +485,14 @@ export class BackgroundServiceView extends UI.Widget.VBox { inlineButton.classList.add('background-service-record-inline-button'); centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( str_, UIStrings.clickTheRecordButtonSOrHitSTo, {PH1: inlineButton, PH2: recordKey})); - - centered.appendChild(this.createLearnMoreLink()); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + centered.appendChild(this.createLearnMoreLink()); + } + // #endif OHOS_DEVTOOLS } this.preview.show(this.previewPanel.contentElement); diff --git a/front_end/panels/application/DOMStorageItemsView.ts b/front_end/panels/application/DOMStorageItemsView.ts index 28b43122e77a96103666aa59050af2a0d9631365..539c64e7f71f1f39087f3827ed2f810b8e6520d4 100644 --- a/front_end/panels/application/DOMStorageItemsView.ts +++ b/front_end/panels/application/DOMStorageItemsView.ts @@ -206,16 +206,19 @@ export class DOMStorageItemsView extends StorageItemsView { const storageData = event.data; const childNode = this.dataGrid.rootNode().children.find( (child: DataGrid.DataGrid.DataGridNode) => child.data.key === storageData.key); - if (!childNode || childNode.data.value === storageData.value) { + if (!childNode) { return; } - - childNode.data.value = storageData.value; - childNode.refresh(); + if (childNode.data.value !== storageData.value) { + childNode.data.value = storageData.value; + childNode.refresh(); + } if (!childNode.selected) { return; } - void this.previewEntry(childNode); + if (this.previewValue !== storageData.value) { + void this.previewEntry(childNode); + } this.setCanDeleteSelected(true); } diff --git a/front_end/panels/application/ServiceWorkerCacheTreeElement.ts b/front_end/panels/application/ServiceWorkerCacheTreeElement.ts index 99555a41698b97e7a0ee7785499861baa3bfba84..60e37d818ef53c184ac5c473d3c329cc10ccbda1 100644 --- a/front_end/panels/application/ServiceWorkerCacheTreeElement.ts +++ b/front_end/panels/application/ServiceWorkerCacheTreeElement.ts @@ -36,9 +36,16 @@ export class ServiceWorkerCacheTreeElement extends ExpandableApplicationPanelTre constructor(resourcesPanel: ResourcesPanel) { super(resourcesPanel, i18nString(UIStrings.cacheStorage), 'CacheStorage'); const icon = UI.Icon.Icon.create('database', 'resource-tree-item'); - this.setLink( - 'https://developer.chrome.com/docs/devtools/storage/cache/?utm_source=devtools' as - Platform.DevToolsPath.UrlString); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + this.setLink( + 'https://developer.chrome.com/docs/devtools/storage/cache/?utm_source=devtools' as + Platform.DevToolsPath.UrlString); + } + // #endif OHOS_DEVTOOLS this.setLeadingIcons([icon]); this.swCacheModels = new Set(); this.swCacheTreeElements = new Set(); diff --git a/front_end/panels/application/ServiceWorkersView.ts b/front_end/panels/application/ServiceWorkersView.ts index 9517dbbc61b1f58a4b4d1b760d9cb01611114612..e971fdfc207288680da28d57d57ca18bfffa6f1b 100644 --- a/front_end/panels/application/ServiceWorkersView.ts +++ b/front_end/panels/application/ServiceWorkersView.ts @@ -220,18 +220,24 @@ export class ServiceWorkersView extends UI.Widget.VBox implements othersView.setHeaderVisible(false); othersView.show(othersDiv); const othersSection = othersView.appendSection(i18nString(UIStrings.serviceWorkersFromOtherOrigins)); - const othersSectionRow = othersSection.appendRow(); - const seeOthers = - UI.Fragment - .html`${ - i18nString(UIStrings.seeAllRegistrations)}`; - self.onInvokeElement(seeOthers, event => { - const rootTarget = SDK.TargetManager.TargetManager.instance().rootTarget(); - rootTarget && rootTarget.targetAgent().invoke_createTarget({url: 'chrome://serviceworker-internals?devtools'}); - event.consume(true); - }); - othersSectionRow.appendChild(seeOthers); - + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const othersSectionRow = othersSection.appendRow(); + const seeOthers = + UI.Fragment + .html`${ + i18nString(UIStrings.seeAllRegistrations)}`; + self.onInvokeElement(seeOthers, event => { + const rootTarget = SDK.TargetManager.TargetManager.instance().rootTarget(); + rootTarget && rootTarget.targetAgent().invoke_createTarget({url: 'chrome://serviceworker-internals?devtools'}); + event.consume(true); + }); + othersSectionRow.appendChild(seeOthers); + } + // #endif OHOS_DEVTOOLS this.toolbar.appendToolbarItem( MobileThrottling.ThrottlingManager.throttlingManager().createOfflineToolbarCheckbox()); const updateOnReloadSetting = diff --git a/front_end/panels/application/StorageView.ts b/front_end/panels/application/StorageView.ts index 486f7cf8b1e877a7b6a7b7123a1fe9a744782a25..8719448a8b60d6100a1b5c0d8542565b13ba2481 100644 --- a/front_end/panels/application/StorageView.ts +++ b/front_end/panels/application/StorageView.ts @@ -195,11 +195,18 @@ export class StorageView extends UI.ThrottledWidget.ThrottledWidget { const quota = this.reportView.appendSection(i18nString(UIStrings.usage)); this.quotaRow = quota.appendSelectableRow(); this.quotaRow.classList.add('quota-usage-row'); - const learnMoreRow = quota.appendRow(); - const learnMore = UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/progressive-web-apps#opaque-responses', - i18nString(UIStrings.learnMore)); - learnMoreRow.appendChild(learnMore); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const learnMoreRow = quota.appendRow(); + const learnMore = UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/progressive-web-apps#opaque-responses', + i18nString(UIStrings.learnMore)); + learnMoreRow.appendChild(learnMore); + } + // #endif OHOS_DEVTOOLS this.quotaUsage = null; this.pieChart = new PerfUI.PieChart.PieChart(); this.populatePieChart(0, []); diff --git a/front_end/panels/application/components/BackForwardCacheView.ts b/front_end/panels/application/components/BackForwardCacheView.ts index 27cb69c125caef284f20948ade3e50160bfeb908..a395e88172d0d477fd5bbbaa21e7f66e380c3247 100644 --- a/front_end/panels/application/components/BackForwardCacheView.ts +++ b/front_end/panels/application/components/BackForwardCacheView.ts @@ -289,6 +289,40 @@ export class BackForwardCacheView extends HTMLElement { // Prevent running BFCache test on the DevTools window itself via DevTools on DevTools const isTestingForbidden = Common.ParsedURL.schemeIs(this.#frame.url, 'devtools:'); // clang-format off + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return LitHtml.html` + ${this.#renderBackForwardCacheStatus(this.#frame.backForwardCacheDetails.restoredFromCache)} +
+
+ ${i18nString(UIStrings.url)} +
+
+ ${this.#frame.url} +
+
+ ${this.#maybeRenderFrameTree(this.#frame.backForwardCacheDetails.explanationsTree)} + <${ReportView.ReportView.ReportSection.litTagName}> + <${Buttons.Button.Button.litTagName} + aria-label=${i18nString(UIStrings.runTest)} + .disabled=${isTestRunning || isTestingForbidden} + .spinner=${isTestRunning} + .variant=${Buttons.Button.Variant.PRIMARY} + @click=${this.#navigateAwayAndBack}> + ${isTestRunning ? LitHtml.html` + ${i18nString(UIStrings.runningTest)}`:` + ${i18nString(UIStrings.runTest)} + `} + + + <${ReportView.ReportView.ReportSectionDivider.litTagName}> + + ${this.#maybeRenderExplanations(this.#frame.backForwardCacheDetails.explanations, + this.#frame.backForwardCacheDetails.explanationsTree)} + `; + } + // #endif OHOS_DEVTOOLS return LitHtml.html` ${this.#renderBackForwardCacheStatus(this.#frame.backForwardCacheDetails.restoredFromCache)}
@@ -594,13 +628,20 @@ export class BackForwardCacheView extends HTMLElement { } #maybeRenderDeepLinkToUnload(explanation: Protocol.Page.BackForwardCacheNotRestoredExplanation): LitHtml.LitTemplate { - if (explanation.reason === Protocol.Page.BackForwardCacheNotRestoredReason.UnloadHandlerExistsInMainFrame || - explanation.reason === Protocol.Page.BackForwardCacheNotRestoredReason.UnloadHandlerExistsInSubFrame) { - return LitHtml.html` - - ${i18nString(UIStrings.neverUseUnload)} - `; + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + if (explanation.reason === Protocol.Page.BackForwardCacheNotRestoredReason.UnloadHandlerExistsInMainFrame || + explanation.reason === Protocol.Page.BackForwardCacheNotRestoredReason.UnloadHandlerExistsInSubFrame) { + return LitHtml.html` + + ${i18nString(UIStrings.neverUseUnload)} + `; + } } + // #endif OHOS_DEVTOOLS return LitHtml.nothing; } diff --git a/front_end/panels/application/components/FrameDetailsView.ts b/front_end/panels/application/components/FrameDetailsView.ts index c71cc015c70a186ae9ea41f9dcb21fa80531ae48..757697a2c679a3e6de1ce828bc1ece2da107b27b 100644 --- a/front_end/panels/application/components/FrameDetailsView.ts +++ b/front_end/panels/application/components/FrameDetailsView.ts @@ -745,6 +745,22 @@ export class FrameDetailsReportView extends HTMLElement { return LitHtml.nothing; } + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return LitHtml.html` + <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)} +
+ ${i18nString(UIStrings.availabilityOfCertainApisDepends)} +
+ ${this.#renderSharedArrayBufferAvailability()} + ${this.#renderMeasureMemoryAvailability()} + <${ReportView.ReportView.ReportSectionDivider.litTagName}> + `; + } + // #endif OHOS_DEVTOOLS return LitHtml.html` <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)} @@ -816,6 +832,19 @@ export class FrameDetailsReportView extends HTMLElement { measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable); const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) : i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return LitHtml.html` + <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)} + <${ReportView.ReportView.ReportValue.litTagName}> + ${ + availabilityText} + + `; + } + // #endif OHOS_DEVTOOLS return LitHtml.html` <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)} diff --git a/front_end/panels/application/components/ProtocolHandlersView.ts b/front_end/panels/application/components/ProtocolHandlersView.ts index 3f396c3178ccc47c3ac6d812885ae71a8a923a8a..1f1e6d2b4b240f903140cd2ec149da9d651919f4 100644 --- a/front_end/panels/application/components/ProtocolHandlersView.ts +++ b/front_end/panels/application/components/ProtocolHandlersView.ts @@ -170,17 +170,29 @@ export class ProtocolHandlersView extends HTMLElement { } #render(): void { - const protocolDocLink = - UI.XLink.XLink.create(PROTOCOL_DOCUMENT_URL, i18nString(UIStrings.protocolHandlerRegistrations)); - // clang-format off - LitHtml.render(LitHtml.html` - ${this.#renderStatusMessage()} -
- ${i18n.i18n.getFormatLocalizedString(str_, UIStrings.needHelpReadOur, {PH1: protocolDocLink})} -
- ${this.#renderProtocolTest()} - `, this.#shadow, {host: this}); - // clang-format on + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // clang-format off + LitHtml.render(LitHtml.html` + ${this.#renderStatusMessage()} + ${this.#renderProtocolTest()} + `, this.#shadow, {host: this}); + // clang-format on + } else { + const protocolDocLink = + UI.XLink.XLink.create(PROTOCOL_DOCUMENT_URL, i18nString(UIStrings.protocolHandlerRegistrations)); + // clang-format off + LitHtml.render(LitHtml.html` + ${this.#renderStatusMessage()} +
+ ${i18n.i18n.getFormatLocalizedString(str_, UIStrings.needHelpReadOur, {PH1: protocolDocLink})} +
+ ${this.#renderProtocolTest()} + `, this.#shadow, {host: this}); + // clang-format on + } + // #endif OHOS_DEVTOOLS } } diff --git a/front_end/panels/emulation/emulation-meta.ts b/front_end/panels/emulation/emulation-meta.ts index dd98f2ae6f545ab81fd2f99a3fef02d79d713765..cc2c2de31911f8c23813a587744e4ca36751982b 100644 --- a/front_end/panels/emulation/emulation-meta.ts +++ b/front_end/panels/emulation/emulation-meta.ts @@ -81,7 +81,10 @@ UI.ActionRegistration.registerActionExtension({ const Emulation = await loadEmulationModule(); return Emulation.DeviceModeWrapper.ActionDelegate.instance(); }, - condition: Root.Runtime.ConditionName.CAN_DOCK, + // #ifdef OHOS_DEVTOOLS + //condition: Root.Runtime.ConditionName.CAN_DOCK, + condition: Root.Runtime.ConditionName.USE_ORIGNAL, + // #endif OHOS_DEVTOOLS title: i18nLazyString(UIStrings.toggleDeviceToolbar), iconClass: UI.ActionRegistration.IconClass.LARGEICON_PHONE, bindings: [ @@ -185,7 +188,10 @@ Common.Settings.registerSettingExtension({ UI.Toolbar.registerToolbarItem({ actionId: 'emulation.toggle-device-mode', - condition: Root.Runtime.ConditionName.CAN_DOCK, + // #ifdef OHOS_DEVTOOLS + //condition: Root.Runtime.ConditionName.CAN_DOCK, + condition: Root.Runtime.ConditionName.USE_ORIGNAL, + // #endif OHOS_DEVTOOLS location: UI.Toolbar.ToolbarItemLocation.MAIN_TOOLBAR_LEFT, order: 1, showLabel: undefined, diff --git a/front_end/panels/lighthouse/LighthouseController.ts b/front_end/panels/lighthouse/LighthouseController.ts index 30260bd9d276bf784590080d6cda9bab14a30e15..d8764d76b79a9c15d1773bc3910ff9ffa602e2f6 100644 --- a/front_end/panels/lighthouse/LighthouseController.ts +++ b/front_end/panels/lighthouse/LighthouseController.ts @@ -734,8 +734,9 @@ export const RuntimeSettings: RuntimeSetting[] = [ value: 'snapshot', }, ], - learnMore: 'https://github.com/GoogleChrome/lighthouse/blob/HEAD/docs/user-flows.md' as - Platform.DevToolsPath.UrlString, + // #ifdef OHOS_DEVTOOLS + learnMore: undefined, + // #endif OHOS_DEVTOOLS }, { // This setting is disabled, but we keep it around to show in the UI. @@ -743,9 +744,9 @@ export const RuntimeSettings: RuntimeSetting[] = [ 'lighthouse.throttling', 'simulate', Common.Settings.SettingStorageType.Synced), title: i18nLazyString(UIStrings.throttlingMethod), // We will disable this when we have a Lantern trace viewer within DevTools. - learnMore: - 'https://github.com/GoogleChrome/lighthouse/blob/master/docs/throttling.md#devtools-lighthouse-panel-throttling' as - Platform.DevToolsPath.UrlString, + // #ifdef OHOS_DEVTOOLS + learnMore: undefined, + // #endif OHOS_DEVTOOLS description: i18nLazyString(UIStrings.simulateASlowerPageLoadBasedOn), setFlags: (flags: Flags, value: string|boolean): void => { if (typeof value === 'string') { diff --git a/front_end/panels/network/NetworkLogView.ts b/front_end/panels/network/NetworkLogView.ts index 5132cba1bf93d82c7eaf0f044f4cdc6f6527ac08..965ec650b5e0e8f835571ca742ebf3764c2c2e2b 100644 --- a/front_end/panels/network/NetworkLogView.ts +++ b/front_end/panels/network/NetworkLogView.ts @@ -74,6 +74,10 @@ import { type NetworkTimeCalculator, } from './NetworkTimeCalculator.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Text in Network Log View of the Network panel @@ -944,10 +948,17 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin): void { const request = event.data; - if (SDK.TargetManager.TargetManager.instance().isInScope(SDK.NetworkManager.NetworkManager.forRequest(request))) { + const networkManager = SDK.NetworkManager.NetworkManager.forRequest(request); + if (!networkManager || SDK.TargetManager.TargetManager.instance().isInScope(networkManager)) { this.refreshRequest(request); } } @@ -1629,12 +1641,22 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin pattern.url !== url); manager.setBlockedPatterns(patterns); + // #ifdef OHOS_DEVTOOLS + if (adaptForOhos) { + return; + } + // #endif OHOS_DEVTOOLS void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls'); } diff --git a/front_end/panels/network/RequestHeadersView.ts b/front_end/panels/network/RequestHeadersView.ts index f1422d4aafbc271caf06c6b20edfc8dc48b0a9b8..17f0a4dfbfb0f30c87809ee05301d1604c4d54cb 100644 --- a/front_end/panels/network/RequestHeadersView.ts +++ b/front_end/panels/network/RequestHeadersView.ts @@ -630,10 +630,17 @@ export class RequestHeadersView extends UI.Widget.VBox { cautionElement.createChild('div', 'caution').textContent = cautionText; const cautionTreeElement = new UI.TreeOutline.TreeElement(cautionElement); - cautionElement.createChild('div', 'learn-more') - .appendChild(UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/network/reference/#provisional-headers', - i18nString(UIStrings.learnMore))); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + cautionElement.createChild('div', 'learn-more') + .appendChild(UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/network/reference/#provisional-headers', + i18nString(UIStrings.learnMore))); + } + // #endif OHOS_DEVTOOLS headersTreeElement.appendChild(cautionTreeElement); } diff --git a/front_end/panels/network/RequestTimingView.ts b/front_end/panels/network/RequestTimingView.ts index 197ed29a2ebfefe1fab7a20fc1de0ab488ad5a54..a606d2c2f754e978be7c287bfc59f844b467228b 100644 --- a/front_end/panels/network/RequestTimingView.ts +++ b/front_end/panels/network/RequestTimingView.ts @@ -465,9 +465,16 @@ export class RequestTimingView extends UI.Widget.VBox { const footer = tableElement.createChild('tr', 'network-timing-footer'); const note = (footer.createChild('td') as HTMLTableCellElement); note.colSpan = 1; - note.appendChild(UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/network/reference/#timing-explanation', - i18nString(UIStrings.explanation))); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + note.appendChild(UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/network/reference/#timing-explanation', + i18nString(UIStrings.explanation))); + } + // #endif OHOS_DEVTOOLS footer.createChild('td'); UI.UIUtils.createTextChild(footer.createChild('td'), i18n.TimeUtilities.secondsToString(totalDuration, true)); @@ -490,10 +497,19 @@ export class RequestTimingView extends UI.Widget.VBox { const information = (informationRow.createChild('td') as HTMLTableCellElement); information.colSpan = 3; - const link = UI.XLink.XLink.create( - 'https://web.dev/custom-metrics/#server-timing-api', i18nString(UIStrings.theServerTimingApi)); - information.appendChild( - i18n.i18n.getFormatLocalizedString(str_, UIStrings.duringDevelopmentYouCanUseSToAdd, {PH1: link})); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + const theServerTimingApi = i18nString(UIStrings.theServerTimingApi); + information.appendChild( + i18n.i18n.getFormatLocalizedString(str_, UIStrings.duringDevelopmentYouCanUseSToAdd, {PH1: theServerTimingApi})); + } else { + const link = UI.XLink.XLink.create( + 'https://web.dev/custom-metrics/#server-timing-api', i18nString(UIStrings.theServerTimingApi)); + information.appendChild( + i18n.i18n.getFormatLocalizedString(str_, UIStrings.duringDevelopmentYouCanUseSToAdd, {PH1: link})); + } + // #endif OHOS_DEVTOOLS return tableElement; } diff --git a/front_end/panels/network/components/RequestHeaderSection.ts b/front_end/panels/network/components/RequestHeaderSection.ts index afd9f48e845a021bfd8a88e4a6558d69bdaef88f..bc4a65c34633373893457419301f906c77acb40b 100644 --- a/front_end/panels/network/components/RequestHeaderSection.ts +++ b/front_end/panels/network/components/RequestHeaderSection.ts @@ -105,6 +105,27 @@ export class RequestHeaderSection extends HTMLElement { } // Disabled until https://crbug.com/1079231 is fixed. // clang-format off + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return html` +
+
+
+ <${IconButton.Icon.Icon.litTagName} class="inline-icon" .data=${{ + iconName: 'warning-filled', + color: 'var(--icon-warning)', + width: '16px', + height: '16px', + } as IconButton.Icon.IconData}> + + ${cautionText} +
+
+
+ `; + } + // #endif OHOS_DEVTOOLS return html`
diff --git a/front_end/panels/network/components/RequestHeadersView.ts b/front_end/panels/network/components/RequestHeadersView.ts index 13bc192065d342a113a9ffbe2009a8a8a670045d..7eb7ad4db993d374b1de199955e273f42a2a9c11 100644 --- a/front_end/panels/network/components/RequestHeadersView.ts +++ b/front_end/panels/network/components/RequestHeadersView.ts @@ -289,6 +289,16 @@ export class RequestHeadersComponent extends HTMLElement { // Disabled until https://crbug.com/1079231 is fixed. // clang-format off + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return html` + + ${fileIcon}${i18nString(UIStrings.headerOverrides)} + + `; + } + // #endif OHOS_DEVTOOLS return html` <${IconButton.Icon.Icon.litTagName} class="inline-icon" .data=${{ diff --git a/front_end/panels/network/network-meta.ts b/front_end/panels/network/network-meta.ts index a4e853b63c58a3a8cab472e648622179cf50b818..923b594dc72ae5d5180e2fa36672a1022b9eaa7b 100644 --- a/front_end/panels/network/network-meta.ts +++ b/front_end/panels/network/network-meta.ts @@ -11,6 +11,10 @@ import * as UI from '../../ui/legacy/legacy.js'; import type * as Network from './network.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Command for showing the 'Network' tool @@ -139,18 +143,24 @@ UI.ViewManager.registerViewExtension({ }, }); -UI.ViewManager.registerViewExtension({ - location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, - id: 'network.blocked-urls', - commandPrompt: i18nLazyString(UIStrings.showNetworkRequestBlocking), - title: i18nLazyString(UIStrings.networkRequestBlocking), - persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, - order: 60, - async loadView() { - const Network = await loadNetworkModule(); - return Network.BlockedURLsPane.BlockedURLsPane.instance(); - }, -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb does't support network request blocking. +} else { + UI.ViewManager.registerViewExtension({ + location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, + id: 'network.blocked-urls', + commandPrompt: i18nLazyString(UIStrings.showNetworkRequestBlocking), + title: i18nLazyString(UIStrings.networkRequestBlocking), + persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, + order: 60, + async loadView() { + const Network = await loadNetworkModule(); + return Network.BlockedURLsPane.BlockedURLsPane.instance(); + }, + }); +} +// #endif OHOS_DEVTOOLS UI.ViewManager.registerViewExtension({ location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, diff --git a/front_end/panels/sensors/sensors-meta.ts b/front_end/panels/sensors/sensors-meta.ts index 0a90cf258b81458e1f3149904ca14d69fd2c01c5..cc3506ebebd13aabdd6ac690edc27fb4b0238ac5 100644 --- a/front_end/panels/sensors/sensors-meta.ts +++ b/front_end/panels/sensors/sensors-meta.ts @@ -8,6 +8,9 @@ import * as UI from '../../ui/legacy/legacy.js'; import type * as Sensors from './sensors.js'; import * as i18n from '../../core/i18n/i18n.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS const UIStrings = { /** * @description Title of the Sensors tool. The sensors tool contains GPS, orientation sensors, touch @@ -106,26 +109,32 @@ async function loadEmulationModule(): Promise { return loadedSensorsModule; } -UI.ViewManager.registerViewExtension({ - location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, - commandPrompt: i18nLazyString(UIStrings.showSensors), - title: i18nLazyString(UIStrings.sensors), - id: 'sensors', - persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, - order: 100, - async loadView() { - const Sensors = await loadEmulationModule(); - return Sensors.SensorsView.SensorsView.instance(); - }, - tags: [ - i18nLazyString(UIStrings.geolocation), - i18nLazyString(UIStrings.timezones), - i18nLazyString(UIStrings.locale), - i18nLazyString(UIStrings.locales), - i18nLazyString(UIStrings.accelerometer), - i18nLazyString(UIStrings.deviceOrientation), - ], -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb does't support network request sensors. +} else { + UI.ViewManager.registerViewExtension({ + location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, + commandPrompt: i18nLazyString(UIStrings.showSensors), + title: i18nLazyString(UIStrings.sensors), + id: 'sensors', + persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, + order: 100, + async loadView() { + const Sensors = await loadEmulationModule(); + return Sensors.SensorsView.SensorsView.instance(); + }, + tags: [ + i18nLazyString(UIStrings.geolocation), + i18nLazyString(UIStrings.timezones), + i18nLazyString(UIStrings.locale), + i18nLazyString(UIStrings.locales), + i18nLazyString(UIStrings.accelerometer), + i18nLazyString(UIStrings.deviceOrientation), + ], + }); +} +// #endif OHOS_DEVTOOLS UI.ViewManager.registerViewExtension({ location: UI.ViewManager.ViewLocationValues.SETTINGS_VIEW, diff --git a/front_end/panels/settings/KeybindsSettingsTab.ts b/front_end/panels/settings/KeybindsSettingsTab.ts index f3137f9de598500acb76bce9b81729c0df43e367..39bede0d24152c20fdede75142feae981050aff3 100644 --- a/front_end/panels/settings/KeybindsSettingsTab.ts +++ b/front_end/panels/settings/KeybindsSettingsTab.ts @@ -109,10 +109,17 @@ export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListContro UI.ARIAUtils.setAccessibleName(this.list.element, i18nString(UIStrings.keyboardShortcutsList)); const footer = this.contentElement.createChild('div'); footer.classList.add('keybinds-footer'); - const docsLink = UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/shortcuts/', i18nString(UIStrings.FullListOfDevtoolsKeyboard)); - docsLink.classList.add('docs-link'); - footer.appendChild(docsLink); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const docsLink = UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/shortcuts/', i18nString(UIStrings.FullListOfDevtoolsKeyboard)); + docsLink.classList.add('docs-link'); + footer.appendChild(docsLink); + } + // #endif OHOS_DEVTOOLS footer.appendChild(UI.UIUtils.createTextButton(i18nString(UIStrings.RestoreDefaultShortcuts), () => { userShortcutsSetting.set([]); keybindsSetSetting.set(UI.ShortcutRegistry.DefaultShortcutSetting); diff --git a/front_end/panels/settings/SettingsScreen.ts b/front_end/panels/settings/SettingsScreen.ts index 212d350eb51e91d005028f0f2841f0e7bda5efa3..32c604bc7c4a6b1fc89e25882f0e2098288909be 100644 --- a/front_end/panels/settings/SettingsScreen.ts +++ b/front_end/panels/settings/SettingsScreen.ts @@ -554,6 +554,12 @@ export class ActionDelegate implements UI.ActionRegistration.ActionDelegate { void SettingsScreen.showSettingsScreen({focusTabHeader: true} as ShowSettingsScreenOptions); return true; case 'settings.documentation': + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + return true; + } + // #endif OHOS_DEVTOOLS Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(UI.UIUtils.addReferrerToURL( 'https://developer.chrome.com/docs/devtools/' as Platform.DevToolsPath.UrlString)); return true; diff --git a/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts b/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts index 975fd3db4ea38c51b474ee3b62ab15bb6e80bb19..577a1fb596ca2b67d3398b0a3e0ec180b62cede9 100644 --- a/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +++ b/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts @@ -728,7 +728,9 @@ export class UserAgentClientHintsForm extends HTMLElement { // clang-format on // clang-format off - const output = LitHtml.html` + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + let output = LitHtml.html`
`; + if (adaptForOhos) { + output = LitHtml.html` +
+
+ <${IconButton.Icon.Icon.litTagName} + class=${this.#isFormOpened ? 'rotate-icon' : ''} + .data=${{ + color: 'var(--icon-default)', + iconName: 'triangle-right', + width: '14px', + } as IconButton.Icon.IconData} + > + ${i18nString(UIStrings.title)} +
+
+ ${useragentSection} + ${fullVersionListSection} + ${fullBrowserInput} + ${platformSection} + ${architectureInput} + ${deviceModelSection} + ${submitButton} +
+
+
+ `; + } + // #endif OHOS_DEVTOOLS // clang-format on LitHtml.render(output, this.#shadow, {host: this}); } diff --git a/front_end/panels/settings/settings-meta.ts b/front_end/panels/settings/settings-meta.ts index 3c221d04c7716f957d627d9cf66416752b5af915..0bb2b2c74779d479c779e08871859cbf47c7fd2e 100644 --- a/front_end/panels/settings/settings-meta.ts +++ b/front_end/panels/settings/settings-meta.ts @@ -10,6 +10,10 @@ import * as UI from '../../ui/legacy/legacy.js'; import type * as Settings from './settings.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Text for keyboard shortcuts @@ -114,41 +118,47 @@ UI.ViewManager.registerViewExtension({ }, }); -UI.ActionRegistration.registerActionExtension({ - category: UI.ActionRegistration.ActionCategory.SETTINGS, - actionId: 'settings.show', - title: i18nLazyString(UIStrings.settings), - async loadActionDelegate() { - const Settings = await loadSettingsModule(); - return Settings.SettingsScreen.ActionDelegate.instance(); - }, - iconClass: UI.ActionRegistration.IconClass.LARGEICON_SETTINGS_GEAR, - bindings: [ - { - shortcut: 'F1', - keybindSets: [ - UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, - ], +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb does't support settings. +} else { + UI.ActionRegistration.registerActionExtension({ + category: UI.ActionRegistration.ActionCategory.SETTINGS, + actionId: 'settings.show', + title: i18nLazyString(UIStrings.settings), + async loadActionDelegate() { + const Settings = await loadSettingsModule(); + return Settings.SettingsScreen.ActionDelegate.instance(); }, - { - shortcut: 'Shift+?', - }, - { - platform: UI.ActionRegistration.Platforms.WindowsLinux, - shortcut: 'Ctrl+,', - keybindSets: [ - UI.ActionRegistration.KeybindSet.VS_CODE, - ], - }, - { - platform: UI.ActionRegistration.Platforms.Mac, - shortcut: 'Meta+,', - keybindSets: [ - UI.ActionRegistration.KeybindSet.VS_CODE, - ], - }, - ], -}); + iconClass: UI.ActionRegistration.IconClass.LARGEICON_SETTINGS_GEAR, + bindings: [ + { + shortcut: 'F1', + keybindSets: [ + UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, + ], + }, + { + shortcut: 'Shift+?', + }, + { + platform: UI.ActionRegistration.Platforms.WindowsLinux, + shortcut: 'Ctrl+,', + keybindSets: [ + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + { + platform: UI.ActionRegistration.Platforms.Mac, + shortcut: 'Meta+,', + keybindSets: [ + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + ], + }); +} +// #endif OHOS_DEVTOOLS UI.ActionRegistration.registerActionExtension({ category: UI.ActionRegistration.ActionCategory.SETTINGS, @@ -160,31 +170,38 @@ UI.ActionRegistration.registerActionExtension({ }, }); -UI.ActionRegistration.registerActionExtension({ - category: UI.ActionRegistration.ActionCategory.SETTINGS, - actionId: 'settings.shortcuts', - title: i18nLazyString(UIStrings.shortcuts), - async loadActionDelegate() { - const Settings = await loadSettingsModule(); - return Settings.SettingsScreen.ActionDelegate.instance(); - }, - bindings: [ - { - platform: UI.ActionRegistration.Platforms.WindowsLinux, - shortcut: 'Ctrl+K Ctrl+S', - keybindSets: [ - UI.ActionRegistration.KeybindSet.VS_CODE, - ], - }, - { - platform: UI.ActionRegistration.Platforms.Mac, - shortcut: 'Meta+K Meta+S', - keybindSets: [ - UI.ActionRegistration.KeybindSet.VS_CODE, - ], +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb doesn't support shortcuts. +} else { + UI.ActionRegistration.registerActionExtension({ + category: UI.ActionRegistration.ActionCategory.SETTINGS, + actionId: 'settings.shortcuts', + title: i18nLazyString(UIStrings.shortcuts), + async loadActionDelegate() { + const Settings = await loadSettingsModule(); + return Settings.SettingsScreen.ActionDelegate.instance(); }, - ], -}); + bindings: [ + { + platform: UI.ActionRegistration.Platforms.WindowsLinux, + shortcut: 'Ctrl+K Ctrl+S', + keybindSets: [ + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + { + platform: UI.ActionRegistration.Platforms.Mac, + shortcut: 'Meta+K Meta+S', + keybindSets: [ + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + ], + }); +} +// #endif OHOS_DEVTOOLS + UI.ViewManager.registerLocationResolver({ name: UI.ViewManager.ViewLocationValues.SETTINGS_VIEW, @@ -209,11 +226,17 @@ Common.Revealer.registerRevealer({ destination: undefined, }); -UI.ContextMenu.registerItem({ - location: UI.ContextMenu.ItemLocation.MAIN_MENU_FOOTER, - actionId: 'settings.shortcuts', - order: undefined, -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb doesn't support shortcuts. +} else { + UI.ContextMenu.registerItem({ + location: UI.ContextMenu.ItemLocation.MAIN_MENU_FOOTER, + actionId: 'settings.shortcuts', + order: undefined, + }); +} +// #endif OHOS_DEVTOOLS UI.ContextMenu.registerItem({ location: UI.ContextMenu.ItemLocation.MAIN_MENU_HELP_DEFAULT, diff --git a/front_end/panels/sources/SourcesNavigator.ts b/front_end/panels/sources/SourcesNavigator.ts index 243072afc257acdf0abf40ae6b78f02d41fbeeb1..0bfbab22655ccfeb0165c7281df8c933c00cb858 100644 --- a/front_end/panels/sources/SourcesNavigator.ts +++ b/front_end/panels/sources/SourcesNavigator.ts @@ -170,12 +170,20 @@ export class FilesNavigatorView extends NavigatorView { super(); const placeholder = new UI.EmptyWidget.EmptyWidget(''); this.setPlaceholder(placeholder); - placeholder.appendParagraph().appendChild(UI.Fragment.html` -
${i18nString(UIStrings.syncChangesInDevtoolsWithThe)}

- ${ - UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/workspaces/', i18nString(UIStrings.learnMoreAboutWorkspaces))} - `); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.syncChangesInDevtoolsWithThe)}
`); + } else { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.syncChangesInDevtoolsWithThe)}

+ ${ + UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/workspaces/', i18nString(UIStrings.learnMoreAboutWorkspaces))} + `); + } + // #endif OHOS_DEVTOOLS const toolbar = new UI.Toolbar.Toolbar('navigator-toolbar'); void toolbar.appendItemsAtLocation('files-navigator-toolbar').then(() => { @@ -213,12 +221,20 @@ export class OverridesNavigatorView extends NavigatorView { super(); const placeholder = new UI.EmptyWidget.EmptyWidget(''); this.setPlaceholder(placeholder); - placeholder.appendParagraph().appendChild(UI.Fragment.html` -
${i18nString(UIStrings.overridePageAssetsWithFilesFromA)}

- ${ - UI.XLink.XLink.create( - 'https://developers.google.com/web/updates/2018/01/devtools#overrides', i18nString(UIStrings.learnMore))} - `); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.overridePageAssetsWithFilesFromA)}
`); + } else { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.overridePageAssetsWithFilesFromA)}

+ ${ + UI.XLink.XLink.create( + 'https://developers.google.com/web/updates/2018/01/devtools#overrides', i18nString(UIStrings.learnMore))} + `); + } + // #endif OHOS_DEVTOOLS this.toolbar = new UI.Toolbar.Toolbar('navigator-toolbar'); @@ -305,10 +321,18 @@ export class ContentScriptsNavigatorView extends NavigatorView { super(); const placeholder = new UI.EmptyWidget.EmptyWidget(''); this.setPlaceholder(placeholder); - placeholder.appendParagraph().appendChild(UI.Fragment.html` -
${i18nString(UIStrings.contentScriptsServedByExtensions)}

- ${UI.XLink.XLink.create('https://developer.chrome.com/extensions/content_scripts', i18nString(UIStrings.learnMore))} - `); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.contentScriptsServedByExtensions)}
`); + } else { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.contentScriptsServedByExtensions)}

+ ${UI.XLink.XLink.create('https://developer.chrome.com/extensions/content_scripts', i18nString(UIStrings.learnMore))} + `); + } + // #endif OHOS_DEVTOOLS } static instance(opts: { @@ -334,12 +358,20 @@ export class SnippetsNavigatorView extends NavigatorView { super(); const placeholder = new UI.EmptyWidget.EmptyWidget(''); this.setPlaceholder(placeholder); - placeholder.appendParagraph().appendChild(UI.Fragment.html` -
${i18nString(UIStrings.createAndSaveCodeSnippetsFor)}

- ${ - UI.XLink.XLink.create( - 'https://developer.chrome.com/docs/devtools/javascript/snippets/', i18nString(UIStrings.learnMore))} - `); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.createAndSaveCodeSnippetsFor)}
`); + } else { + placeholder.appendParagraph().appendChild(UI.Fragment.html` +
${i18nString(UIStrings.createAndSaveCodeSnippetsFor)}

+ ${ + UI.XLink.XLink.create( + 'https://developer.chrome.com/docs/devtools/javascript/snippets/', i18nString(UIStrings.learnMore))} + `); + } + // #endif OHOS_DEVTOOLS const toolbar = new UI.Toolbar.Toolbar('navigator-toolbar'); const newButton = diff --git a/front_end/panels/sources/SourcesView.ts b/front_end/panels/sources/SourcesView.ts index f2659f3745fb93a66cbf514d2c51837135e24879..33e40620c9b96bcc5dbdb88ce0dffebeee6b7812 100644 --- a/front_end/panels/sources/SourcesView.ts +++ b/front_end/panels/sources/SourcesView.ts @@ -25,6 +25,10 @@ import { } from './TabbedEditorContainer.js'; import {Events as UISourceCodeFrameEvents, UISourceCodeFrame} from './UISourceCodeFrame.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Text to open a file @@ -145,12 +149,21 @@ export class SourcesView extends Common.ObjectWrapper.eventMixin - LitHtml.html` - ${this.#renderApplyToRow(headerOverride.applyTo, blockIndex)} - ${headerOverride.headers.map((header, headerIndex) => - LitHtml.html` - ${this.#renderHeaderRow(header, blockIndex, headerIndex)} - `, - )} - `, - )} - <${Buttons.Button.Button.litTagName} .variant=${Buttons.Button.Variant.SECONDARY} class="add-block"> - ${i18nString(UIStrings.addOverrideRule)} - -
- ${i18nString(UIStrings.learnMore)} -
- `, this.#shadow, {host: this}); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + LitHtml.render(LitHtml.html` + ${this.#headerOverrides.map((headerOverride, blockIndex) => + LitHtml.html` + ${this.#renderApplyToRow(headerOverride.applyTo, blockIndex)} + ${headerOverride.headers.map((header, headerIndex) => + LitHtml.html` + ${this.#renderHeaderRow(header, blockIndex, headerIndex)} + `, + )} + `, + )} + <${Buttons.Button.Button.litTagName} .variant=${Buttons.Button.Variant.SECONDARY} class="add-block"> + ${i18nString(UIStrings.addOverrideRule)} + + `, this.#shadow, {host: this}); + } else { + LitHtml.render(LitHtml.html` + ${this.#headerOverrides.map((headerOverride, blockIndex) => + LitHtml.html` + ${this.#renderApplyToRow(headerOverride.applyTo, blockIndex)} + ${headerOverride.headers.map((header, headerIndex) => + LitHtml.html` + ${this.#renderHeaderRow(header, blockIndex, headerIndex)} + `, + )} + `, + )} + <${Buttons.Button.Button.litTagName} .variant=${Buttons.Button.Variant.SECONDARY} class="add-block"> + ${i18nString(UIStrings.addOverrideRule)} + +
+ ${i18nString(UIStrings.learnMore)} +
+ `, this.#shadow, {host: this}); + } + // #endif OHOS_DEVTOOLS // clang-format on if (this.#focusElement) { diff --git a/front_end/panels/sources/sources-meta.ts b/front_end/panels/sources/sources-meta.ts index eee0bff5d88f7dae7108fea4d74aba6ddf25b270..769cd7751797b95cdb17e394d24c090dba772b8d 100644 --- a/front_end/panels/sources/sources-meta.ts +++ b/front_end/panels/sources/sources-meta.ts @@ -15,6 +15,10 @@ import * as UI from '../../ui/legacy/legacy.js'; import type * as Sources from './sources.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Command for showing the 'Sources' tool @@ -478,18 +482,25 @@ UI.ViewManager.registerViewExtension({ }, }); -UI.ViewManager.registerViewExtension({ - location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, - id: 'sources.quick', - commandPrompt: i18nLazyString(UIStrings.showQuickSource), - title: i18nLazyString(UIStrings.quickSource), - persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, - order: 1000, - async loadView() { - const Sources = await loadSourcesModule(); - return Sources.SourcesPanel.WrapperView.instance(); - }, -}); + +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb does't support quick source. +} else { + UI.ViewManager.registerViewExtension({ + location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, + id: 'sources.quick', + commandPrompt: i18nLazyString(UIStrings.showQuickSource), + title: i18nLazyString(UIStrings.quickSource), + persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, + order: 1000, + async loadView() { + const Sources = await loadSourcesModule(); + return Sources.SourcesPanel.WrapperView.instance(); + }, + }); +} +// #endif OHOS_DEVTOOLS UI.ViewManager.registerViewExtension({ id: 'sources.threads', diff --git a/front_end/panels/timeline/TimelineDetailsView.ts b/front_end/panels/timeline/TimelineDetailsView.ts index 4dc513c9fb3014216c320768b2674fbae0d00340..a019bd44451bec4f52672fcfbfdee32c0e0198a5 100644 --- a/front_end/panels/timeline/TimelineDetailsView.ts +++ b/front_end/panels/timeline/TimelineDetailsView.ts @@ -151,14 +151,21 @@ export class TimelineDetailsView extends UI.Widget.VBox { const isEstimate = estimated ? ` (${i18nString(UIStrings.estimated)})` : ''; const message = i18nString(UIStrings.totalBlockingTimeSmss, {PH1: time.toFixed(2), PH2: isEstimate}); - const warning = document.createElement('span'); - const clsLink = UI.XLink.XLink.create('https://web.dev/tbt/', i18nString(UIStrings.learnMore)); - // Prevent focus ring from being cut off. - clsLink.style.margin = '3px'; - warning.appendChild(clsLink); - - this.additionalMetricsToolbar.appendText(message); - this.additionalMetricsToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(warning)); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + this.additionalMetricsToolbar.appendText(message); + } else { + const warning = document.createElement('span'); + const clsLink = UI.XLink.XLink.create('https://web.dev/tbt/', i18nString(UIStrings.learnMore)); + // Prevent focus ring from being cut off. + clsLink.style.margin = '3px'; + warning.appendChild(clsLink); + + this.additionalMetricsToolbar.appendText(message); + this.additionalMetricsToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(warning)); + } + // #endif OHOS_DEVTOOLS } } diff --git a/front_end/panels/timeline/TimelinePanel.ts b/front_end/panels/timeline/TimelinePanel.ts index 52e3f7902463b5a098a59d4116405611aff8de10..d7ff0d28ef6ffef16982030ca2fefc50682ac098 100644 --- a/front_end/panels/timeline/TimelinePanel.ts +++ b/front_end/panels/timeline/TimelinePanel.ts @@ -46,6 +46,8 @@ import * as PerfUI from '../../ui/legacy/components/perf_ui/perf_ui.js'; import * as UI from '../../ui/legacy/legacy.js'; import * as MobileThrottling from '../mobile_throttling/mobile_throttling.js'; +import * as Bindings from '../../models/bindings/bindings.js'; + import historyToolbarButtonStyles from './historyToolbarButton.css.js'; import timelinePanelStyles from './timelinePanel.css.js'; import timelineStatusDialogStyles from './timelineStatusDialog.css.js'; @@ -657,6 +659,25 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod fileName = `Trace-${traceStart}.json` as Platform.DevToolsPath.RawPathString; } + // #ifdef OHOS_DEVTOOLS + const supportShowSaveFilePicker = false; + if (!supportShowSaveFilePicker) { + const stream = new Bindings.FileUtils.FileOutputStream(); + if (!await stream.open(fileName)) { + console.error(`open ${fileName} failed`); + return; + } + const formattedTraceIter = traceJsonGenerator(traceEvents, metadata); + const traceAsString = Array.from(formattedTraceIter).join(''); + const chunkSize = 100000; + for (let i = 0; i < traceAsString.length; i += chunkSize) { + const chunk = traceAsString.substr(i, chunkSize); + await stream.write(chunk); + } + void stream.close(); + return; + } + // #endif OHOS_DEVTOOLS try { const handler = await window.showSaveFilePicker({ suggestedName: fileName, @@ -1141,8 +1162,16 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( str_, UIStrings.clickTheReloadButtonSOrHitSTo, {PH1: reloadButton, PH2: reloadKey})); - centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( - str_, UIStrings.afterRecordingSelectAnAreaOf, {PH1: navigateNode, PH2: learnMoreNode})); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( + str_, UIStrings.afterRecordingSelectAnAreaOf, {PH1: navigateNode})); + } else { + centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( + str_, UIStrings.afterRecordingSelectAnAreaOf, {PH1: navigateNode, PH2: learnMoreNode})); + } + // #endif OHOS_DEVTOOLS if (isNode) { const previewSection = new PanelFeedback.PanelFeedback.PanelFeedback(); diff --git a/front_end/panels/webauthn/WebauthnPane.ts b/front_end/panels/webauthn/WebauthnPane.ts index ce6a5ae16f5594a753d345217f52354d48d24950..fcf7b2464ac6b45810adfd0c39afd3232d8d1901 100644 --- a/front_end/panels/webauthn/WebauthnPane.ts +++ b/front_end/panels/webauthn/WebauthnPane.ts @@ -520,14 +520,25 @@ export class WebauthnPaneImpl extends UI.Widget.VBox implements #createNewAuthenticatorSection(): void { this.#learnMoreView = this.contentElement.createChild('div', 'learn-more'); - this.#learnMoreView.appendChild(UI.Fragment.html` -
- ${i18nString(UIStrings.useWebauthnForPhishingresistant)}

- ${ - UI.XLink.XLink.create( - 'https://developers.google.com/web/updates/2018/05/webauthn', i18nString(UIStrings.learnMore))} -
- `); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + this.#learnMoreView.appendChild(UI.Fragment.html` +
+ ${i18nString(UIStrings.useWebauthnForPhishingresistant)} +
+ `); + } else { + this.#learnMoreView.appendChild(UI.Fragment.html` +
+ ${i18nString(UIStrings.useWebauthnForPhishingresistant)}

+ ${ + UI.XLink.XLink.create( + 'https://developers.google.com/web/updates/2018/05/webauthn', i18nString(UIStrings.learnMore))} +
+ `); + } + // #endif OHOS_DEVTOOLS this.#newAuthenticatorSection = this.contentElement.createChild('div', 'new-authenticator-container'); const newAuthenticatorTitle = diff --git a/front_end/third_party/lighthouse/report/bundle.js b/front_end/third_party/lighthouse/report/bundle.js index 5c6e81c3804469c8753f49c023cf530c6517ebaf..4c4bb9ea88d3a619fb5da578e40634490b071bbc 100644 --- a/front_end/third_party/lighthouse/report/bundle.js +++ b/front_end/third_party/lighthouse/report/bundle.js @@ -548,12 +548,19 @@ function createFooterComponent(dom) { const el5 = dom.createElement("b"); el5.append("Lighthouse"); const el6 = dom.createElement("span", "lh-footer__version"); - const el7 = dom.createElement("a", "lh-footer__version_issue"); - el7.setAttribute('href', 'https://github.com/GoogleChrome/Lighthouse/issues'); - el7.setAttribute('target', '_blank'); - el7.setAttribute('rel', 'noopener'); - el7.append("File an issue"); - el4.append(" "," Generated by ",el5," ",el6," | ",el7," "); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + el4.append(" "," Generated by ",el5," ",el6," "); + } else { + const el7 = dom.createElement("a", "lh-footer__version_issue"); + el7.setAttribute('href', 'https://github.com/GoogleChrome/Lighthouse/issues'); + el7.setAttribute('target', '_blank'); + el7.setAttribute('rel', 'noopener'); + el7.append("File an issue"); + el4.append(" "," Generated by ",el5," ",el6," | ",el7," "); + } + // #endif OHOS_DEVTOOLS el2.append(" ",el3," ",el4," "); el0.append(el2); return el0; @@ -1925,6 +1932,9 @@ class ReportUtils { const UIStrings = { /** Disclaimer shown to users below the metric values (First Contentful Paint, Time to Interactive, etc) to warn them that the numbers they see will likely change slightly the next time they run Lighthouse. */ varianceDisclaimer: 'Values are estimated and may vary. The [performance score is calculated](https://developer.chrome.com/docs/lighthouse/performance/performance-scoring/) directly from these metrics.', + // #ifdef OHOS_DEVTOOLS + varianceDisclaimerOhos: 'Values are estimated and may vary. The performance score is calculated directly from these metrics.', + // #endif OHOS_DEVTOOLS /** Text link pointing to an interactive calculator that explains Lighthouse scoring. The link text should be fairly short. */ calculatorLink: 'See calculator.', /** Label preceding a radio control for filtering the list of audits. The radio choices are various performance metrics (FCP, LCP, TBT), and if chosen, the audits in the report are hidden if they are not relevant to the selected metric. */ @@ -4226,14 +4236,23 @@ class PerformanceCategoryRenderer extends CategoryRenderer { if (element.querySelector('.lh-gauge__wrapper')) { const descriptionEl = this.dom.find('.lh-category-header__description', element); const estValuesEl = this.dom.createChildOf(descriptionEl, 'div', 'lh-metrics__disclaimer'); - const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer); - estValuesEl.append(disclaimerEl); - - // Add link to score calculator. - const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink'); - calculatorLink.target = '_blank'; - calculatorLink.textContent = strings.calculatorLink; - this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs)); + + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimerOhos); + estValuesEl.append(disclaimerEl); + } else { + const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer); + estValuesEl.append(disclaimerEl); + + // Add link to score calculator. + const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink'); + calculatorLink.target = '_blank'; + calculatorLink.textContent = strings.calculatorLink; + this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs)); + } + // #endif OHOS_DEVTOOLS } metricsGroupEl.classList.add('lh-audit-group--metrics'); @@ -4689,7 +4708,14 @@ class ReportRenderer { this._renderMetaBlock(report, footer); - this._dom.find('.lh-footer__version_issue', footer).textContent = Globals.strings.footerIssue; + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + this._dom.find('.lh-footer__version_issue', footer).textContent = Globals.strings.footerIssue; + } + // #endif OHOS_DEVTOOLS this._dom.find('.lh-footer__version', footer).textContent = report.lighthouseVersion; return footer; } @@ -5823,15 +5849,22 @@ class ReportUIFeatures { toggleInputEl.checked = true; } - const showTreemapApp = - this.json.audits['script-treemap-data'] && this.json.audits['script-treemap-data'].details; - if (showTreemapApp) { - this.addButton({ - text: Globals.strings.viewTreemapLabel, - icon: 'treemap', - onClick: () => openTreemap(this.json), - }); + // #ifdef OHOS_DEVTOOLS + const adaptForOhos = true; + if (adaptForOhos) { + // ohos doesn't support external links + } else { + const showTreemapApp = + this.json.audits['script-treemap-data'] && this.json.audits['script-treemap-data'].details; + if (showTreemapApp) { + this.addButton({ + text: Globals.strings.viewTreemapLabel, + icon: 'treemap', + onClick: () => openTreemap(this.json), + }); + } } + // #endif OHOS_DEVTOOLS if (this._opts.onViewTrace) { this.addButton({ diff --git a/front_end/ui/legacy/InspectorView.ts b/front_end/ui/legacy/InspectorView.ts index 2b0c6ec1f51a268fa59f099b5a69342841d99adf..e783288cb3bc5597422ac8bbb3759593f057ed90 100644 --- a/front_end/ui/legacy/InspectorView.ts +++ b/front_end/ui/legacy/InspectorView.ts @@ -193,6 +193,10 @@ export class InspectorView extends VBox implements ViewLocationResolver { // the Device mode button is not added and so the allocated space is smaller. const allocatedSpace = Root.Runtime.Runtime.queryParam(Root.Runtime.ConditionName.CAN_DOCK) ? '69px' : '41px'; this.tabbedPane.leftToolbar().element.style.minWidth = allocatedSpace; + // #ifdef OHOS_DEVTOOLS + this.tabbedPane.leftToolbar().element.style.minWidth = + Root.Runtime.Runtime.queryParam(Root.Runtime.ConditionName.USE_ORIGNAL) ? allocatedSpace : '41px'; + // #endif OHOS_DEVTOOLS this.tabbedPane.registerRequiredCSS(inspectorViewTabbedPaneStyles); this.tabbedPane.addEventListener(TabbedPaneEvents.TabSelected, this.tabSelected, this); this.tabbedPane.setAccessibleName(i18nString(UIStrings.panels)); @@ -494,7 +498,14 @@ export class InspectorView extends VBox implements ViewLocationResolver { } function getDisableLocaleInfoBarSetting(): Common.Settings.Setting { - return Common.Settings.Settings.instance().createSetting('disableLocaleInfoBar', false); + // #ifdef OHOS_DEVTOOLS + const disableLocaleInfoBarAsDefault = true; + if (disableLocaleInfoBarAsDefault) { + return Common.Settings.Settings.instance().createSetting('disableLocaleInfoBar', true); + } else { + return Common.Settings.Settings.instance().createSetting('disableLocaleInfoBar', false); + } + // #endif } function shouldShowLocaleInfobar(): boolean { diff --git a/front_end/ui/legacy/components/data_grid/DataGrid.ts b/front_end/ui/legacy/components/data_grid/DataGrid.ts index b2347e04401cfe00db1e0061b2b78e33ced74d42..f19ba0a2154abeae964e594dd6b7b47da5748bb9 100644 --- a/front_end/ui/legacy/components/data_grid/DataGrid.ts +++ b/front_end/ui/legacy/components/data_grid/DataGrid.ts @@ -1647,7 +1647,7 @@ export class DataGridNode { parent: DataGridNode|null; previousSibling: DataGridNode|null; nextSibling: DataGridNode|null; - disclosureToggleWidth: number; + #disclosureToggleHitBoxWidth: number = 20; selectable: boolean; isRoot: boolean; nodeAccessibleText: string; @@ -1670,7 +1670,6 @@ export class DataGridNode { this.parent = null; this.previousSibling = null; this.nextSibling = null; - this.disclosureToggleWidth = 10; this.selectable = true; @@ -2350,7 +2349,7 @@ export class DataGridNode { } const left = cell.getBoundingClientRect().left + this.leftPadding; - return event.pageX >= left && event.pageX <= left + this.disclosureToggleWidth; + return event.pageX >= left && event.pageX <= left + this.#disclosureToggleHitBoxWidth; } private attach(): void { diff --git a/front_end/ui/legacy/components/quick_open/CommandMenu.ts b/front_end/ui/legacy/components/quick_open/CommandMenu.ts index 443ee18c4364ce652b23814561c1c98e9e3a7cb5..067c1fb4aea4010b97c84eb50c8f6ee9d1ac6871 100644 --- a/front_end/ui/legacy/components/quick_open/CommandMenu.ts +++ b/front_end/ui/legacy/components/quick_open/CommandMenu.ts @@ -12,6 +12,10 @@ import * as UI from '../../legacy.js'; import {FilteredListWidget, Provider, registerProvider} from './FilteredListWidget.js'; import {QuickOpenImpl} from './QuickOpen.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** * @description Message to display if a setting change requires a reload of DevTools @@ -422,11 +426,17 @@ export class ShowActionDelegate implements UI.ActionRegistration.ActionDelegate } } -registerProvider({ - prefix: '>', - iconName: 'chevron-right', - iconWidth: '20px', - provider: () => Promise.resolve(new CommandMenuProvider()), - titlePrefix: (): Common.UIString.LocalizedString => i18nString(UIStrings.run), - titleSuggestion: (): Common.UIString.LocalizedString => i18nString(UIStrings.command), -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb doesn't support command. +} else { + registerProvider({ + prefix: '>', + iconName: 'chevron-right', + iconWidth: '20px', + provider: () => Promise.resolve(new CommandMenuProvider()), + titlePrefix: (): Common.UIString.LocalizedString => i18nString(UIStrings.run), + titleSuggestion: (): Common.UIString.LocalizedString => i18nString(UIStrings.command), + }); +} +// #endif OHOS_DEVTOOLS diff --git a/front_end/ui/legacy/components/quick_open/quick_open-meta.ts b/front_end/ui/legacy/components/quick_open/quick_open-meta.ts index 790a996a40acd04b03cd1e9820b437cbc13c9041..5f4a2bfe05c3d653af396d59ffb02dc1b1e1c9f2 100644 --- a/front_end/ui/legacy/components/quick_open/quick_open-meta.ts +++ b/front_end/ui/legacy/components/quick_open/quick_open-meta.ts @@ -7,6 +7,10 @@ import * as UI from '../../legacy.js'; import type * as QuickOpen from './quick_open.js'; +// #ifdef OHOS_DEVTOOLS +const adaptForOhos = true; +// #endif OHOS_DEVTOOLS + const UIStrings = { /** *@description Title of action that opens a file @@ -29,39 +33,45 @@ async function loadQuickOpenModule(): Promise { return loadedQuickOpenModule; } -UI.ActionRegistration.registerActionExtension({ - actionId: 'commandMenu.show', - category: UI.ActionRegistration.ActionCategory.GLOBAL, - title: i18nLazyString(UIStrings.runCommand), - async loadActionDelegate() { - const QuickOpen = await loadQuickOpenModule(); - return QuickOpen.CommandMenu.ShowActionDelegate.instance(); - }, - bindings: [ - { - platform: UI.ActionRegistration.Platforms.WindowsLinux, - shortcut: 'Ctrl+Shift+P', - keybindSets: [ - UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, - UI.ActionRegistration.KeybindSet.VS_CODE, - ], +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb doesn't support command. +} else { + UI.ActionRegistration.registerActionExtension({ + actionId: 'commandMenu.show', + category: UI.ActionRegistration.ActionCategory.GLOBAL, + title: i18nLazyString(UIStrings.runCommand), + async loadActionDelegate() { + const QuickOpen = await loadQuickOpenModule(); + return QuickOpen.CommandMenu.ShowActionDelegate.instance(); }, - { - platform: UI.ActionRegistration.Platforms.Mac, - shortcut: 'Meta+Shift+P', - keybindSets: [ - UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, - UI.ActionRegistration.KeybindSet.VS_CODE, - ], - }, - { - shortcut: 'F1', - keybindSets: [ - UI.ActionRegistration.KeybindSet.VS_CODE, - ], - }, - ], -}); + bindings: [ + { + platform: UI.ActionRegistration.Platforms.WindowsLinux, + shortcut: 'Ctrl+Shift+P', + keybindSets: [ + UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + { + platform: UI.ActionRegistration.Platforms.Mac, + shortcut: 'Meta+Shift+P', + keybindSets: [ + UI.ActionRegistration.KeybindSet.DEVTOOLS_DEFAULT, + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + { + shortcut: 'F1', + keybindSets: [ + UI.ActionRegistration.KeybindSet.VS_CODE, + ], + }, + ], + }); +} +// #endif OHOS_DEVTOOLS UI.ActionRegistration.registerActionExtension({ actionId: 'quickOpen.show', @@ -108,11 +118,17 @@ UI.ActionRegistration.registerActionExtension({ ], }); -UI.ContextMenu.registerItem({ - location: UI.ContextMenu.ItemLocation.MAIN_MENU_DEFAULT, - actionId: 'commandMenu.show', - order: undefined, -}); +// #ifdef OHOS_DEVTOOLS +if (adaptForOhos) { + // arkweb doesn't support command. +} else { + UI.ContextMenu.registerItem({ + location: UI.ContextMenu.ItemLocation.MAIN_MENU_DEFAULT, + actionId: 'commandMenu.show', + order: undefined, + }); +} +// #endif OHOS_DEVTOOLS UI.ContextMenu.registerItem({ location: UI.ContextMenu.ItemLocation.MAIN_MENU_DEFAULT, diff --git a/test/unittests/front_end/panels/network/NetworkLogView_test.ts b/test/unittests/front_end/panels/network/NetworkLogView_test.ts index 25ca0d49c9f6eed15e3a64b1977ad4ec4b54bbb7..2078250b61a899c5cebd3f0164f12929f1fffc76 100644 --- a/test/unittests/front_end/panels/network/NetworkLogView_test.ts +++ b/test/unittests/front_end/panels/network/NetworkLogView_test.ts @@ -155,6 +155,40 @@ describeWithMockConnection('NetworkLogView', () => { } }); + it('can import from HAR', async () => { + const URL_1 = 'http://example.com/' as Platform.DevToolsPath.UrlString; + const URL_2 = 'http://example.com/favicon.ico' as Platform.DevToolsPath.UrlString; + function makeHarEntry(url: Platform.DevToolsPath.UrlString) { + return { + request: {method: 'GET', url: url, headersSize: -1, bodySize: 0}, + response: {status: 0, content: {'size': 0, 'mimeType': 'x-unknown'}, headersSize: -1, bodySize: -1}, + startedDateTime: null, + time: null, + timings: {blocked: null, dns: -1, ssl: -1, connect: -1, send: 0, wait: 0, receive: 0}, + }; + } + const har = { + log: { + version: '1.2', + creator: {name: 'WebInspector', version: '537.36'}, + entries: [makeHarEntry(URL_1), makeHarEntry(URL_2)], + }, + }; + networkLogView.markAsRoot(); + networkLogView.show(document.body); + const blob = new Blob([JSON.stringify(har)], {type: 'text/plain'}); + const file = new File([blob], 'log.har'); + await networkLogView.onLoadFromFile(file); + await coordinator.done(); + + const rootNode = networkLogView.columns().dataGrid().rootNode(); + assert.deepEqual( + rootNode.children.map(n => (n as Network.NetworkDataGridNode.NetworkNode).request()?.url()), + [URL_1, URL_2]); + + networkLogView.detach(); + }); + it('shows summary toolbar with content', () => { target.setInspectedURL('http://example.com/' as Platform.DevToolsPath.UrlString); const request = createNetworkRequest('http://example.com/', {finished: true});