Skip to content

Commit 7c0f66a

Browse files
committed
Update initiator algorithms
1 parent 34104f2 commit 7c0f66a

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

index.bs

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
212212
text: prompt; url: timers-and-user-prompts.html#dom-prompt
213213
text: remove a browsing context; url: browsers.html#bcg-remove
214214
text: report an error; url: webappapis.html#report-the-error
215+
text: resource; url: infrastructure.html#resources
215216
text: run the animation frame callbacks; url: imagebitmap-and-animations.html#run-the-animation-frame-callbacks
216217
text: same origin domain; url: browsers.html#same-origin-domain
217218
text: select an image source from a source set; url: images.html#select-an-image-source-from-a-source-set
@@ -5219,54 +5220,64 @@ To <dfn>deserialize header</dfn> given |protocol header|:
52195220

52205221
<pre class="cddl local-cddl">
52215222
network.Initiator = {
5222-
type: "parser" / "script" / "preflight" / "other",
5223+
type: text,
5224+
? isCorsPreflight: bool,
52235225
? columnNumber: js-uint,
52245226
? lineNumber: js-uint,
52255227
? stackTrace: script.StackTrace,
5226-
? request: network.Request
5228+
? url: text,
52275229
};
52285230
</pre>
52295231

52305232
The <code>network.Initiatior</code> type represents the source of a network
52315233
request.
52325234

5235+
Note: the purpose of the initiator in the spec is to be able to compute
5236+
the chain of resources that lead to a particular network request using
5237+
URLs and positions within resources.
5238+
52335239
<div algorithm>
52345240
To <dfn>get the initiator</dfn> given |request|:
52355241

5236-
1. Let |request id| be |request|'s [=request id=].
5242+
1. Let |type| be |request|'s [=request/initiator type=].
5243+
5244+
1. Let |is cors prefligt| be true, if |request| is a [=CORS-Preflight Request=], and false otherwise.
5245+
5246+
1. Let |stack trace| be the [=current stack trace=].
52375247

5238-
1. Let |type| be "<code>other</code>".
5248+
Issue: current stack trace might not always be available.
52395249

5240-
1. If |request| is a [=CORS-Preflight Request=], set |type| to
5241-
"<code>preflight</code>".
5250+
1. If |stack trace| has size of 1 or greater:
52425251

5243-
1. TODO: Get the |type|. It's not quite clear how this ought to work; the CDP
5244-
data depends on whether the navigation was kicked off by the parser or by
5245-
script (so e.g. inserting an image from script causes the initiator to be
5246-
"<code>script</code>"), but that doesn't correspond to anything in Fetch.
5252+
1. Let |url| be value of the <code>url<code> in |stack trace|[0].
52475253

5248-
1. If |request|'s [=request/initiator type=] is "<code>fetch</code>" or
5249-
"<code>xmlhttprequest</code>":
5254+
1. Let |line number| be value of the <code>lineNumber</code> field in
5255+
|stack trace|[0].
5256+
5257+
1. Let |column number| be the value of the <code>columnNumber</code>
5258+
field in |stack trace|[0].
5259+
5260+
1. Otherwise:
52505261

5251-
1. Let |stack trace| be the [=current stack trace=].
5262+
1. Let |stack trace| be null.
52525263

5253-
1. If |stack trace| has size of 1 or greater, let |line number| be value of the
5254-
<code>lineNumber</code> field in |stack trace|[0], and let |column number| be
5255-
the value of the <code>columnNumber</code> field in |stack trace|[0]. Otherwise
5256-
let |line number| and |column number| be 0.
5264+
Issue: TODO
52575265

5258-
Otherwise, let |stack trace|, |column number|, and |line number| all be null.
5266+
1. Let |url| be the URL of the [=resource=] that initiated |request|.
5267+
5268+
1. Let |column number| be the column number within the [=resource=] that initiated |request|.
52595269

5260-
TODO: Chrome includes the current parser position as column number / line
5261-
number for parser-inserted resources.
5270+
1. Let |line number| be the line number within the [=resource=] that initiated |request|.
52625271

5263-
1. Return a [=/map=] matching the <code>network.Initiator</code> production, with
5264-
the <code>type</code> field set to |type|, the <code>columnNumber</code>
5265-
field set to |column number| if it's not null, or omitted otherwise, the
5266-
<code>lineNumber</code> field set to |line number| if it's not null, or
5267-
omitted otherwise, the <code>stackTrace</code> field set to |stack trace| if
5268-
it's not null, or omitted otherwise, and the <code>request</code> field set
5269-
to |request id|.
5272+
1. Return a [=/map=] matching the <code>network.Initiator</code>
5273+
production, with the <code>type</code> field set to |type|, the
5274+
<code>isCorsPreflight</code> set to |is cors prefligt|, the
5275+
<code>columnNumber</code> field set to |column number| if it's not
5276+
null, or omitted otherwise, the <code>lineNumber</code> field set to
5277+
|line number| if it's not null, or omitted otherwise, the
5278+
<code>stackTrace</code> field set to |stack trace| if it's not null,
5279+
or omitted otherwise, and the <code>url</code> field set to |url| if
5280+
it's not null, or omitted otherwise.
52705281

52715282
</div>
52725283

0 commit comments

Comments
 (0)