@@ -175,14 +175,14 @@ static JS::ExecutionContext* top_most_script_having_execution_context(JS::VM& vm
175
175
}
176
176
177
177
// https://html.spec.whatwg.org/multipage/webappapis.html#prepare-to-run-a-callback
178
- void EnvironmentSettingsObject:: prepare_to_run_callback ()
178
+ void prepare_to_run_callback (JS::Realm& realm )
179
179
{
180
- auto & vm = global_object ().vm ();
180
+ auto & vm = realm. global_object ().vm ();
181
181
182
- // 1. Push settings onto the backup incumbent settings object stack.
182
+ // 1. Push realm onto the backup incumbent settings object stack.
183
183
// NOTE: The spec doesn't say which event loop's stack to put this on. However, all the examples of the incumbent settings object use iframes and cross browsing context communication to demonstrate the concept.
184
184
// This means that it must rely on some global state that can be accessed by all browsing contexts, which is the main thread event loop.
185
- HTML::main_thread_event_loop ().push_onto_backup_incumbent_settings_object_stack ({}, * this );
185
+ HTML::main_thread_event_loop ().push_onto_backup_incumbent_realm_stack (realm );
186
186
187
187
// 2. Let context be the topmost script-having execution context.
188
188
auto * context = top_most_script_having_execution_context (vm);
@@ -209,9 +209,10 @@ URL::URL EnvironmentSettingsObject::parse_url(StringView url)
209
209
}
210
210
211
211
// https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-a-callback
212
- void EnvironmentSettingsObject::clean_up_after_running_callback ()
212
+ // https://whatpr.org/html/9893/b8ea975...df5706b/webappapis.html#clean-up-after-running-a-callback
213
+ void clean_up_after_running_callback (JS::Realm const & realm)
213
214
{
214
- auto & vm = global_object ().vm ();
215
+ auto & vm = realm. global_object ().vm ();
215
216
216
217
// 1. Let context be the topmost script-having execution context.
217
218
auto * context = top_most_script_having_execution_context (vm);
@@ -220,12 +221,12 @@ void EnvironmentSettingsObject::clean_up_after_running_callback()
220
221
if (context)
221
222
context->skip_when_determining_incumbent_counter --;
222
223
223
- // 3. Assert: the topmost entry of the backup incumbent settings object stack is settings .
224
+ // 3. Assert: the topmost entry of the backup incumbent realm stack is realm .
224
225
auto & event_loop = HTML::main_thread_event_loop ();
225
- VERIFY (&event_loop.top_of_backup_incumbent_settings_object_stack () == this );
226
+ VERIFY (&event_loop.top_of_backup_incumbent_realm_stack () == &realm );
226
227
227
- // 4. Remove settings from the backup incumbent settings object stack.
228
- event_loop.pop_backup_incumbent_settings_object_stack ({} );
228
+ // 4. Remove realm from the backup incumbent realm stack.
229
+ event_loop.pop_backup_incumbent_realm_stack ( );
229
230
}
230
231
231
232
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-script
@@ -285,8 +286,9 @@ void EnvironmentSettingsObject::disallow_further_import_maps()
285
286
verify_cast<Window>(global).set_import_maps_allowed (false );
286
287
}
287
288
288
- // https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object
289
- EnvironmentSettingsObject& incumbent_settings_object ()
289
+ // https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-realm
290
+ // https://whatpr.org/html/9893/b8ea975...df5706b/webappapis.html#concept-incumbent-realm
291
+ JS::Realm& incumbent_realm ()
290
292
{
291
293
auto & event_loop = HTML::main_thread_event_loop ();
292
294
auto & vm = event_loop.vm ();
@@ -297,22 +299,24 @@ EnvironmentSettingsObject& incumbent_settings_object()
297
299
// 2. If context is null, or if context's skip-when-determining-incumbent counter is greater than zero, then:
298
300
if (!context || context->skip_when_determining_incumbent_counter > 0 ) {
299
301
// 1. Assert: the backup incumbent settings object stack is not empty.
300
- // NOTE: If this assertion fails, it's because the incumbent settings object was used with no involvement of JavaScript.
301
- VERIFY (!event_loop.is_backup_incumbent_settings_object_stack_empty ());
302
+ // 1. Assert: the backup incumbent realm stack is not empty.
303
+ // NOTE: If this assertion fails, it's because the incumbent realm was used with no involvement of JavaScript.
304
+ VERIFY (!event_loop.is_backup_incumbent_realm_stack_empty ());
302
305
303
- // 2. Return the topmost entry of the backup incumbent settings object stack.
304
- return event_loop.top_of_backup_incumbent_settings_object_stack ();
306
+ // 2. Return the topmost entry of the backup incumbent realm stack.
307
+ return event_loop.top_of_backup_incumbent_realm_stack ();
305
308
}
306
309
307
- // 3. Return context's Realm component's settings object .
308
- return Bindings::host_defined_environment_settings_object ( *context->realm ) ;
310
+ // 3. Return context's Realm component.
311
+ return *context->realm ;
309
312
}
310
313
311
- // https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-realm
312
- JS::Realm& incumbent_realm ()
314
+ // https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object
315
+ // https://whatpr.org/html/9893/b8ea975...df5706b/webappapis.html#incumbent-settings-object
316
+ EnvironmentSettingsObject& incumbent_settings_object ()
313
317
{
314
- // Then, the incumbent Realm is the Realm of the incumbent settings object.
315
- return incumbent_settings_object (). realm ( );
318
+ // FIXME: Then, the incumbent settings object is the incumbent realm's principal realm settings object.
319
+ return Bindings::host_defined_environment_settings_object ( incumbent_realm () );
316
320
}
317
321
318
322
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-global
0 commit comments