From dce1cc5e09127666282ae0aa8a05eba38df2e2a3 Mon Sep 17 00:00:00 2001 From: "mark a. foltz" Date: Tue, 10 Nov 2026 10:12:12 -0800 Subject: [PATCH] Fixes #379. Use the ModelContext's associated Document in its algorithms, so that when they are called on ModelContext objects associated with frameless documents created within an existing document, they reject correctly. --- index.bs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/index.bs b/index.bs index 68a80fe..9710d27 100644 --- a/index.bs +++ b/index.bs @@ -653,8 +653,8 @@ To unregister a tool given a {{ModelContext}} |mo availability, while the execution-time {{ModelContextExecuteToolOptions/signal}} controls the lifetime of an specific invocation. -1. Let |targetDocument| be |modelContext|'s [=relevant global object=]'s [=associated - Document|associated Document=]. +1. Let |targetDocument| be |modelContext|'s [=ModelContext/associated Document|associated + Document=]. 1. If |targetDocument| is not [=Document/fully active=], then return. @@ -702,7 +702,8 @@ Each {{Document}} object has an associated {{ModelContext}}ModelContext=] must be set to a [=new=] {{ModelContext}} object created in the -{{Document}}'s [=relevant realm=]. +{{Document}}'s [=relevant realm=], whose [=ModelContext/associated Document|associated +Document=] is set to the {{Document}}.
@@ -740,6 +741,10 @@ interface ModelContext : EventTarget { Each {{ModelContext}} object has an associated internal context, which is a [=model context=] [=struct=] created alongside the {{ModelContext}}. +Each {{ModelContext}} object has an associated {{Document}}, which is +the {{Document}} whose [=Document/associated ModelContext|associated ModelContext=] it +is. +
document.{{Document/modelContext}}.{{ModelContext/registerTool(tool, options)}}
@@ -790,7 +795,8 @@ The registerTool(tool, optionsDocument=]. +1. Let |tool owner| be [=this=]'s [=ModelContext/associated Document|associated + Document=]. 1. If |tool owner| is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}. @@ -930,7 +936,8 @@ The getTools(options) method steps 1. Let |global| be [=this=]'s [=relevant global object=]. -1. Let |toolRequestor| be |global|'s [=associated Document|associated Document=]. +1. Let |toolRequestor| be [=this=]'s [=ModelContext/associated Document|associated + Document=]. 1. If |toolRequestor| is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}. @@ -1059,8 +1066,8 @@ The getTools(options) method steps The executeTool(tool, inputObject, options) method steps are: -1. Let |callerDocument| be [=this=]'s [=relevant global object=]'s [=associated - Document|associated Document=]. +1. Let |callerDocument| be [=this=]'s [=ModelContext/associated Document|associated + Document=]. 1. If |callerDocument| is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.