Closed Bug 1130924 Opened 10 years ago Closed 9 years ago

Add method of chrome only settings to fetch API

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: marcosc, Assigned: marcosc)

References

Details

Attachments

(2 files)

> I think it might be easier to add a 3-arg form of fetch(), where the 3rd arg is a dictionary of chrome only settings. Then make the 3-arg form [ChromeOnly]. That way fetch could directly override some settings of Request.
Depends on: dom-fetch-api
OS: Mac OS X → All
Hardware: x86 → All
You can't have different exposure settings on different overloads, unfortunately.  That is, you can't mark one overload as [ChromeOnly].

Which is good, because doing it that way would mean that the chrome-only version constrained the way the API can evolve, no?

We may want a [ChromeOnly] function with a different name that takes the settings dictionary in question....
(In reply to Boris Zbarsky [:bz] from comment #1)
> You can't have different exposure settings on different overloads,
> unfortunately.  That is, you can't mark one overload as [ChromeOnly].
> 
> Which is good, because doing it that way would mean that the chrome-only
> version constrained the way the API can evolve, no?

Yeah, I was thinking the same. 

> We may want a [ChromeOnly] function with a different name that takes the
> settings dictionary in question....

Sounds good. Will do that.
Summary: Add dictionary of chrome only settings to fetch API → Add method of chrome only settings to fetch API
Blocks: 1083410
Assignee: nobody → mcaceres
So I've managed to implement the method, but I think nsCORSListenerProxy is intervening (blocking requests explicitly marked as "no-cors"). It FailWithNetworkError() on line 620 in the "OnStartRequest" method. 

Any guidance on how to proceed would be appreciated.
Flags: needinfo?(nsm.nikhil)
Also, I was thinking we can then also dump `setContext()` before anyone it in favor of this more extensbile solution.
Comment on attachment 8566384 [details] [diff] [review]
0001-Bug-1130924-Add-method-of-chrome-only-settings-to-fe.patch

Review of attachment 8566384 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/fetch/FetchDriver.cpp
@@ +278,5 @@
> +    bool corsFlag = true;
> +    if (mRequest->Mode() == RequestMode::No_cors){ 
> +      corsFlag = false;
> +    }
> +    return HttpFetch(corsFlag);

Why did you change this block? As in, I don't understand the intent.
Could you describe the situation or add a small test case where the fetch failed? What was the request, from which page/chrome was it called?
Flags: needinfo?(nsm.nikhil)
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #5)
> Comment on attachment 8566384 [details] [diff] [review]
> 0001-Bug-1130924-Add-method-of-chrome-only-settings-to-fe.patch
> 
> Review of attachment 8566384 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/fetch/FetchDriver.cpp
> @@ +278,5 @@
> > +    bool corsFlag = true;
> > +    if (mRequest->Mode() == RequestMode::No_cors){ 
> > +      corsFlag = false;
> > +    }
> > +    return HttpFetch(corsFlag);
> 
> Why did you change this block? As in, I don't understand the intent.

IIRC, you had it set to always be "true". That would mean that overriding with "no-cors" would do nothing.
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #6)
> Could you describe the situation or add a small test case where the fetch
> failed? What was the request, from which page/chrome was it called?

Will send a patch with the tests in a bit (in the middle of building :)), but it's basically this: 

```
  var url = "http://test1.example.org:80/tests/dom/tests/mochitest/fetch/fetch_chrome_helper.html";
  var r = new w.Request(url);
  r.overrideSettings({mode: "no-cors"});
  w.fetch(r).then(res=> console.log(res), (err)=> console.log(err)); 
```

That gives shows me a "blocked by CORS" error in the JS console.
These are the tests thus far...
Depends on: 1134533
Might not need this particular functionality after all (as we might just force CORS by default)... I'll reopen depending on what happens with the web manifest spec.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Blocks: 1162729
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: