@@ -171,6 +171,7 @@ void ScenarioServiceWorkerManager::GetAllServiceWorkerRegistrations()
171171 HRESULT error, ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
172172 workerRegistrationCollection) -> HRESULT
173173 {
174+ CHECK_FAILURE (error);
174175 UINT32 workersCount = 0 ;
175176 CHECK_FAILURE (workerRegistrationCollection->get_Count (&workersCount));
176177
@@ -217,10 +218,11 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()
217218
218219 if (dialog.confirmed )
219220 {
221+ std::wstring scope = dialog.input .c_str ();
220222 CHECK_FAILURE (m_serviceWorkerManager->GetServiceWorkerRegistrationsForScope (
221- dialog. input .c_str (),
223+ scope .c_str (),
222224 Callback<ICoreWebView2ExperimentalGetServiceWorkerRegistrationsCompletedHandler>(
223- [this ](
225+ [this , scope ](
224226 HRESULT error,
225227 ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
226228 workerRegistrationCollection) -> HRESULT
@@ -230,52 +232,34 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()
230232 CHECK_FAILURE (workerRegistrationCollection->get_Count (&workersCount));
231233
232234 std::wstringstream message{};
233- message << L" Number of service workers registered for the given scope: "
234- << workersCount << std::endl;
235+ message << L" Number of service workers registered for the scope ( "
236+ << scope. c_str () << " ) : " << workersCount << std::endl;
235237
236238 for (UINT32 i = 0 ; i < workersCount; i++)
237239 {
238- Microsoft::WRL::ComPtr<
239- ICoreWebView2ExperimentalServiceWorkerRegistration>
240+ ComPtr<ICoreWebView2ExperimentalServiceWorkerRegistration>
240241 serviceWorkerRegistration;
241242 CHECK_FAILURE (workerRegistrationCollection->GetValueAtIndex (
242243 i, &serviceWorkerRegistration));
243244
244- wil::com_ptr<ICoreWebView2ExperimentalServiceWorker> serviceWorker;
245+ wil::unique_cotaskmem_string scopeUri;
246+ CHECK_FAILURE (serviceWorkerRegistration->get_ScopeUri (&scopeUri));
247+
248+ wil::unique_cotaskmem_string origin;
249+ CHECK_FAILURE (serviceWorkerRegistration->get_Origin (&origin));
250+
251+ wil::unique_cotaskmem_string topLevelOrigin;
245252 CHECK_FAILURE (
246- serviceWorkerRegistration->get_ActiveServiceWorker (&serviceWorker));
247-
248- if (serviceWorker)
249- {
250- // Log that the service worker is activated.
251- }
252- else
253- {
254- CHECK_FAILURE (serviceWorkerRegistration->add_ServiceWorkerActivated (
255- Callback<
256- ICoreWebView2ExperimentalServiceWorkerActivatedEventHandler>(
257- [this ](
258- ICoreWebView2ExperimentalServiceWorkerRegistration*
259- sender,
260- ICoreWebView2ExperimentalServiceWorkerActivatedEventArgs*
261- args) -> HRESULT
262- {
263- wil::com_ptr<ICoreWebView2ExperimentalServiceWorker>
264- serviceWorker;
265- CHECK_FAILURE (
266- args->get_ActiveServiceWorker (&serviceWorker));
267-
268- // Log that the service worker is activated.
269- m_appWindow->AsyncMessageBox (
270- L" Service worker is activated" , L" Service worker" );
271-
272- return S_OK;
273- })
274- .Get (),
275- nullptr ));
276- }
253+ serviceWorkerRegistration->get_TopLevelOrigin (&topLevelOrigin));
254+
255+ message << L" ScopeUri: " << scopeUri.get () << std::endl;
256+ message << L" Origin: " << origin.get () << std::endl;
257+ message << L" TopLevelOrigin: " << topLevelOrigin.get () << std::endl;
277258 }
278259
260+ m_appWindow->AsyncMessageBox (
261+ std::move (message.str ()), L" Registered service workers for scope" );
262+
279263 return S_OK;
280264 })
281265 .Get ()));
0 commit comments