Closed Bug 1282099 Opened 4 years ago Closed 4 years ago

Update NetUtil.asyncFetch calls in chat/

Categories

(Chat Core :: General, defect)

defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
Instantbird 50

People

(Reporter: aleth, Assigned: abdelrahman)

Details

Attachments

(1 file, 1 obsolete file)

Error: NetUtil.jsm: asyncFetch() requires the channel to have one of the security flags set in the loadinfo (see nsILoadInfo). Please create channel using NetUtil.newChannel()
Source File: resource://gre/modules/NetUtil.jsm
Line: 158

Affects yahoo and xmpp.
No longer blocks: 955019
Assignee: nobody → ab
Status: NEW → ASSIGNED
Attachment #8765175 - Flags: review?(aleth)
Comment on attachment 8765175 [details] [diff] [review]
v1 - Update NetUtil.asyncFetch calls in chat/

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

Thanks.

::: chat/protocols/yahoo/yahoo-session.jsm
@@ +328,5 @@
>                                          .getTypeFromFile(file);
>      NetUtil.asyncFetch({
>          uri: NetUtil.newURI(file),
>          contentPolicyType: Ci.nsIContentPolicy.TYPE_IMAGE,
> +        securityFlags: Ci.nsILoadInfo.SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS,

Why was SEC_NORMAL a problem?

I'm not sure this instance of asyncFetch is actually going to cause an error?
Comment on attachment 8765175 [details] [diff] [review]
v1 - Update NetUtil.asyncFetch calls in chat/

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

::: chat/protocols/yahoo/yahoo-session.jsm
@@ +326,5 @@
>      let file = FileUtils.getFile("ProfD", [aFileName]);
>      let type = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
>                                          .getTypeFromFile(file);
>      NetUtil.asyncFetch({
>          uri: NetUtil.newURI(file),

While we are at it, let's replace this deprecated way of calling asyncFetch before it also throws an error:
http://searchfox.org/mozilla-central/source/netwerk/base/NetUtil.jsm#96

@@ +328,5 @@
>                                          .getTypeFromFile(file);
>      NetUtil.asyncFetch({
>          uri: NetUtil.newURI(file),
>          contentPolicyType: Ci.nsIContentPolicy.TYPE_IMAGE,
> +        securityFlags: Ci.nsILoadInfo.SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS,

ah, SEC_NORMAL is 0.
Attachment #8765175 - Flags: review?(aleth) → review-
(In reply to aleth [:aleth] from comment #3) 
> While we are at it, let's replace this deprecated way of calling asyncFetch
> before it also throws an error:
> http://searchfox.org/mozilla-central/source/netwerk/base/NetUtil.jsm#96

I think it's OK according to this line "- An options object that will be passed to NetUtil.newChannel.".

BTW, I used |newChannel| to keep it consistent with other calls in chat/ and passed file directly to it instead of passing URI according to comments [1] on it.

[1] http://searchfox.org/mozilla-central/source/netwerk/base/NetUtil.jsm#221
Attachment #8765175 - Attachment is obsolete: true
Attachment #8765332 - Flags: review?(aleth)
Attachment #8765332 - Flags: review?(aleth) → review+
(In reply to Abdelrhman Ahmed [:abdelrhman] from comment #4)
> I think it's OK according to this line "- An options object that will be
> passed to NetUtil.newChannel.".

Ah, yes you are right, it was OK as it was inside an object.
https://hg.mozilla.org/comm-central/rev/7ba75deff65a
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Thanks! Please also set the milestone/target when you resolve fixed.
Target Milestone: --- → Instantbird 50
You need to log in before you can comment on or make changes to this bug.