@@ -3984,7 +3984,37 @@ The <code>Initiatior</code> type represents the source of a network request.
3984
3984
<div algorithm>
3985
3985
To <dfn>get the initiator</dfn> given |request|:
3986
3986
3987
- 1. TODO
3987
+ 1. Let |type| be "<code> other</code> ".
3988
+
3989
+ 1. If |request| is a [=CORS Preflight Request=] , set |type| to
3990
+ "<code> preflight</code> ".
3991
+
3992
+ 1. TODO: Get the |type|. It's not quite clear how this ought to work; the CDP
3993
+ data depends on whether the navigation was kicked off by the parser or by
3994
+ script (so e.g. inserting an image from script causes the initiator to be
3995
+ "<code> script</code> "), but that doesn't correspond to anything in Fetch.
3996
+
3997
+ 1. If |request|'s [=request/initiator-type=] is "<code> fetch</code> " or
3998
+ "<code> xmlhttprequest</code> ":
3999
+
4000
+ 1. Let |stack trace| be the [=current stack trace=] .
4001
+
4002
+ 1. If |stack trace| has size of 1 or greater, let |line number| be value of the
4003
+ <code> lineNumber</code> field in |stack trace|[0] , and let |column number| be
4004
+ the value of the <code> columnNumber</code> field |stack trace|[0] . Otherwise
4005
+ let |line number| and |column number| be 0.
4006
+
4007
+ Otherwise, let |stack trace|, |column number|, and |line number| all be null.
4008
+
4009
+ TODO: Chrome includes the current parser position as column number / line
4010
+ number for parser-inserted resources.
4011
+
4012
+ 1. Return a [=map=] matching the <code> NetworkInitiator</code> production, with
4013
+ the |type| field set to "<code> type</code> ", the <code> columnNumber</code>
4014
+ field set to |column number| if it's not null, or omitted otherwise, the
4015
+ <code> lineNumber</code> field set to |line number| if it's not null, or
4016
+ omitted otherwise, the <code> stackTrace</code> field set to |stack trace| if
4017
+ it's not null, or omitted otherwise.
3988
4018
3989
4019
</div>
3990
4020
0 commit comments