Bug 91964 - Add "webkitBackgroundRequest" property to XMLHttpRequest
Summary: Add "webkitBackgroundRequest" property to XMLHttpRequest
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-23 00:03 PDT by Sean Wang
Modified: 2012-08-06 00:52 PDT (History)
10 users (show)

See Also:


Attachments
patch (9.80 KB, patch)
2012-07-23 00:58 PDT, Sean Wang
ap: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Wang 2012-07-23 00:03:35 PDT
When the page is doing an interruptable background XHR, such as the Instant fast searching, or when the XHR is from an extension, we may allow the request failing quietly other than having it popping up a dialog such as the authentication dialogs. We may want to indicate the XMLHttpRequest running on the background mode explicitly.
Comment 1 Sean Wang 2012-07-23 00:58:44 PDT
Created attachment 153748 [details]
patch

Mozilla have added a property "mozBackgroundRequest"

Some discussions from mozilla and chromium.
https://developer.mozilla.org/en/xmlhttprequest
https://bugzilla.mozilla.org/show_bug.cgi?id=383430
http://code.google.com/p/chromium/issues/detail?id=31582
Comment 2 Joe Mason 2012-07-23 05:44:03 PDT
Comment on attachment 153748 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=153748&action=review

> Source/WebCore/ChangeLog:10
> +        When set thewebkitBackgournd property to true, the XHR should not popup dialogs, it can fail

Typo: should be "the webkitBackground".  Also the commit message should always talk about "webkitBackgroundRequest" since that's the full name of the property.

> Source/WebCore/ChangeLog:15
> +        supported by some platforms which is needed by the new tests.

We should still write tests, and just skip them on platforms that don't support setHandlesAuthenticationChallenges

> Source/WebCore/ChangeLog:24
> +        * platform/network/blackberry/NetworkJob.cpp:

I think the BlackBerry-specific part of this should be in a separate patch.
Comment 3 Alexey Proskuryakov 2012-07-23 09:24:30 PDT
This is a new feature, and as such needs to be discussed on webkit-dev first.

I personally think that we shouldn't implement this feature unless it makes its way to the spec. It's a very specialized handling of a rare edge case - if people want more control over authentication, it should not be through "background request".

Besides, it's up to debate whether XHR should ever be allowed to display authentication dialogs anyway.

> Mozilla have added a property "mozBackgroundRequest"

Note this: "Requires elevated privileges to access." And these requests have different semantics in that they are not associated with a frame.
Comment 4 Adam Barth 2012-07-23 09:25:20 PDT
Comment on attachment 153748 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=153748&action=review

I'm not sure I understand the use case.  We should just stop XMLHttpRequest from poping up HTTP auth dialogs all the time.

> Source/WebCore/platform/network/ResourceRequestBase.h:194
> +        bool m_loadInBackground : 1;

You can't add state to ResourceRequestBase that can't be represented in an NSURLRequest.  Yes, that's lame, but it's a current design constraint.
Comment 5 Liam Quinn 2012-07-31 14:49:54 PDT
(In reply to comment #4)
> We should just stop XMLHttpRequest from poping up HTTP auth dialogs all the time.

That sounds reasonable to me, but it does go against http://www.w3.org/TR/XMLHttpRequest/, which says "If authentication fails, XMLHttpRequest origin and the request URL are same origin, Authorization is not in the list of author request headers, request username is null, and request password is null, user agents should prompt the end user for their username and password."

Current versions of Chrome, Firefox, and Opera all prompt the user on a 401 from XHR. Safari does not.
Comment 6 Alexey Proskuryakov 2012-07-31 14:53:17 PDT
Are you testing with a synchronous request? With regular async ones, Safari does prompt too.
Comment 7 Liam Quinn 2012-07-31 14:59:26 PDT
(In reply to comment #6)
> Are you testing with a synchronous request? With regular async ones, Safari does prompt too.

Yes, you're right. I was testing with a synchronous request. With async, Safari does indeed prompt.
Comment 8 Charles Wei 2012-08-06 00:52:50 PDT
Let's just fail the HTTP authentication for the XHR and other sub-resources instead of prompting the user for credentials, if there's no credentials stored for the resource.