|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | | -import * as Common from '../../core/common/common.js'; |
6 | 5 | import * as ProtocolClient from '../../core/protocol_client/protocol_client.js'; |
7 | 6 | import * as Root from '../../core/root/root.js'; |
8 | 7 | import * as SDK from '../../core/sdk/sdk.js'; |
9 | 8 | import type * as Protocol from '../../generated/protocol.js'; |
10 | 9 | import { |
11 | 10 | createTarget, |
12 | 11 | stubNoopSettings, |
13 | | - updateHostConfig, |
14 | 12 | } from '../../testing/EnvironmentHelpers.js'; |
15 | 13 | import {expectCall} from '../../testing/ExpectStubCall.js'; |
16 | 14 | import { |
17 | 15 | describeWithMockConnection, |
18 | 16 | setMockConnectionResponseHandler, |
19 | 17 | } from '../../testing/MockConnection.js'; |
20 | | -import * as UI from '../../ui/legacy/legacy.js'; |
| 18 | +import type * as UI from '../../ui/legacy/legacy.js'; |
21 | 19 |
|
22 | 20 | import * as InspectorMain from './inspector_main.js'; |
23 | 21 |
|
@@ -49,140 +47,9 @@ describeWithMockConnection('InspectorMainImpl', () => { |
49 | 47 | sinon.stub(ProtocolClient.ConnectionTransport.ConnectionTransport, 'setFactory'); |
50 | 48 | }); |
51 | 49 |
|
52 | | - describe('comparingBrowserSettingWithCookieControlSetting', () => { |
53 | | - // Before the tests, we need to add these settings to allow the InspectorMain.run to work |
54 | | - beforeEach(async () => { |
55 | | - Common.Settings.registerSettingExtension({ |
56 | | - settingName: 'auto-attach-to-created-pages', |
57 | | - settingType: Common.Settings.SettingType.BOOLEAN, |
58 | | - defaultValue: false, |
59 | | - }); |
60 | | - Common.Settings.registerSettingExtension({ |
61 | | - settingName: 'network.ad-blocking-enabled', |
62 | | - settingType: Common.Settings.SettingType.BOOLEAN, |
63 | | - defaultValue: false, |
64 | | - }); |
65 | | - Common.Settings.registerSettingExtension({ |
66 | | - settingName: 'emulate-page-focus', |
67 | | - settingType: Common.Settings.SettingType.BOOLEAN, |
68 | | - defaultValue: false, |
69 | | - }); |
70 | | - |
71 | | - const storage = Common.Settings.Settings.instance().localStorage; |
72 | | - Common.Settings.Settings.instance({ |
73 | | - forceNew: true, |
74 | | - syncedStorage: storage, |
75 | | - globalStorage: storage, |
76 | | - localStorage: storage, |
77 | | - settingRegistrations: Common.SettingRegistration.getRegisteredSettings() |
78 | | - }); |
79 | | - }); |
80 | | - |
81 | | - function setBrowserConfig( |
82 | | - thirdPartyCookieRestrictionEnabled?: boolean, thirdPartyCookieMetadataEnabled?: boolean, |
83 | | - thirdPartyCookieHeuristicsEnabled?: boolean, managedBlockThirdPartyCookies?: boolean|string) { |
84 | | - updateHostConfig({ |
85 | | - thirdPartyCookieControls: { |
86 | | - thirdPartyCookieRestrictionEnabled, |
87 | | - thirdPartyCookieHeuristicsEnabled, |
88 | | - thirdPartyCookieMetadataEnabled, |
89 | | - managedBlockThirdPartyCookies, |
90 | | - }, |
91 | | - devToolsPrivacyUI: {enabled: true} |
92 | | - }); |
93 | | - } |
94 | | - |
95 | | - function setDevtoolsCookieControls( |
96 | | - cookieControlOverrideEnabled?: boolean, gracePeriodMitigationEnabled?: boolean, |
97 | | - heuristicMitigationEnabled?: boolean) { |
98 | | - Common.Settings.Settings.instance().createSetting( |
99 | | - 'cookie-control-override-enabled', cookieControlOverrideEnabled); |
100 | | - Common.Settings.Settings.instance().createSetting( |
101 | | - 'grace-period-mitigation-disabled', !gracePeriodMitigationEnabled); |
102 | | - Common.Settings.Settings.instance().createSetting('heuristic-mitigation-disabled', !heuristicMitigationEnabled); |
103 | | - } |
104 | | - |
105 | | - it('does not show infobar when enterpirse is blocking third-party cookies', async () => { |
106 | | - const restrictThirdPartyCookies = true; |
107 | | - const gracePeriodEnabled = true; |
108 | | - const heuristicsEnabled = true; |
109 | | - const enterpriseBlocksThirdPartyCookies = true; |
110 | | - setBrowserConfig( |
111 | | - restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled, enterpriseBlocksThirdPartyCookies); |
112 | | - setDevtoolsCookieControls(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
113 | | - |
114 | | - const reloadRequiredInfobarSpy = |
115 | | - sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); |
116 | | - const inspectorMain = new InspectorMain.InspectorMain.InspectorMainImpl(); |
117 | | - await inspectorMain.run(); |
118 | | - |
119 | | - sinon.assert.notCalled(reloadRequiredInfobarSpy); |
120 | | - }); |
121 | | - |
122 | | - it('does not show infobar when control setting is undefined', async () => { |
123 | | - const restrictThirdPartyCookies = true; |
124 | | - const gracePeriodEnabled = true; |
125 | | - const heuristicsEnabled = true; |
126 | | - setBrowserConfig(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
127 | | - |
128 | | - const reloadRequiredInfobarSpy = |
129 | | - sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); |
130 | | - const inspectorMain = new InspectorMain.InspectorMain.InspectorMainImpl(); |
131 | | - await inspectorMain.run(); |
132 | | - |
133 | | - sinon.assert.notCalled(reloadRequiredInfobarSpy); |
134 | | - }); |
135 | | - |
136 | | - it('does not show infobar when control settings match browser settings', async () => { |
137 | | - const restrictThirdPartyCookies = true; |
138 | | - const gracePeriodEnabled = true; |
139 | | - const heuristicsEnabled = true; |
140 | | - setBrowserConfig(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
141 | | - setDevtoolsCookieControls(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
142 | | - |
143 | | - const reloadRequiredInfobarSpy = |
144 | | - sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); |
145 | | - const inspectorMain = new InspectorMain.InspectorMain.InspectorMainImpl(); |
146 | | - await inspectorMain.run(); |
147 | | - |
148 | | - sinon.assert.notCalled(reloadRequiredInfobarSpy); |
149 | | - }); |
150 | | - |
151 | | - it('shows infobar when cookie control override differs from browser setting', async () => { |
152 | | - const restrictThirdPartyCookies = true; |
153 | | - const gracePeriodEnabled = true; |
154 | | - const heuristicsEnabled = true; |
155 | | - setBrowserConfig(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
156 | | - setDevtoolsCookieControls(!restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
157 | | - |
158 | | - const reloadRequiredInfobarSpy = |
159 | | - sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); |
160 | | - const inspectorMain = new InspectorMain.InspectorMain.InspectorMainImpl(); |
161 | | - await inspectorMain.run(); |
162 | | - |
163 | | - sinon.assert.calledOnce(reloadRequiredInfobarSpy); |
164 | | - }); |
165 | | - |
166 | | - it('shows infobar when a mitigation override differs from browser setting', async () => { |
167 | | - const restrictThirdPartyCookies = true; |
168 | | - const gracePeriodEnabled = true; |
169 | | - const heuristicsEnabled = true; |
170 | | - setBrowserConfig(restrictThirdPartyCookies, gracePeriodEnabled, heuristicsEnabled); |
171 | | - setDevtoolsCookieControls(restrictThirdPartyCookies, !gracePeriodEnabled, heuristicsEnabled); |
172 | | - |
173 | | - const reloadRequiredInfobarSpy = |
174 | | - sinon.spy(UI.InspectorView.InspectorView.instance(), 'displayDebuggedTabReloadRequiredWarning'); |
175 | | - const inspectorMain = new InspectorMain.InspectorMain.InspectorMainImpl(); |
176 | | - await inspectorMain.run(); |
177 | | - |
178 | | - sinon.assert.calledOnce(reloadRequiredInfobarSpy); |
179 | | - }); |
180 | | - }); |
181 | | - |
182 | 50 | describe('withNoopSettings', () => { |
183 | 51 | beforeEach(() => { |
184 | 52 | stubNoopSettings(); |
185 | | - updateHostConfig({devToolsPrivacyUI: {enabled: false}}); |
186 | 53 | }); |
187 | 54 |
|
188 | 55 | it('continues only after primary page target is available', async () => { |
|
0 commit comments