Closed Bug 961529 Opened 10 years ago Closed 10 years ago

[e10s] Run DOMLinkHandler code in content script

Categories

(Firefox :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED
Firefox 30

People

(Reporter: billm, Assigned: billm)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 2 obsolete files)

The DOMLinkHandler code handles favicons, RSS feeds, and browser search additions based on <link rel="whatever"> elements in the page. We need to handle the event in a content script and then notify the parent.

This is why favicons sometimes don't show up in e10s.
Attached patch utils-jsm (obsolete) — Splinter Review
The current code calls isValidFeed, which calls urlSecurityCheck. These functions aren't available in content scripts. To solve this, I moved some things into JSMs, which I think is a lot better than what we have now with these overlays.

This first patch moves urlSecurityCheck and a few other convenience functions into a new Utils.jsm.
Assignee: nobody → wmccloskey
Status: NEW → ASSIGNED
Attachment #8363374 - Flags: review?(felipc)
Attached patch feeds-jsmSplinter Review
This patch moves isValidFeed into Feeds.jsm.
Attachment #8363375 - Flags: review?(felipc)
Attached patch content-link-handler (obsolete) — Splinter Review
This patch moves DOMLinkHandler into a content script. Since I know you don't want to make content.js too big, I actually put the code in a new JSM, ContentLinkHandler.jsm.
Attachment #8363376 - Flags: review?(felipc)
Tryserver revealed two other places that call getLinkIconURI.
Attachment #8363376 - Attachment is obsolete: true
Attachment #8363376 - Flags: review?(felipc)
Attachment #8364540 - Flags: review?(felipc)
"Utils.jsm" is a little too generic, I think. I would prefer "BrowserUtils" (ala bug 655747).
I just realized that moving a security check to a content process is a bad idea. I guess to make this work right I'll need to figure out exactly what urlSecurityCheck does.
Comment on attachment 8364540 [details] [diff] [review]
content-link-handler v2

We decided that doing the security check in the parent doesn't offer any additional security since it still would be trusting the child to tell it the right principals.
Attachment #8364540 - Flags: review?(felipc)
Comment on attachment 8363376 [details] [diff] [review]
content-link-handler

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

::: browser/modules/ContentLinkHandler.jsm
@@ +17,5 @@
> +  "resource:///modules/Feeds.jsm");
> +XPCOMUtils.defineLazyModuleGetter(this, "Utils",
> +  "resource://gre/modules/Utils.jsm");
> +
> +let ContentLinkHandler = {

this.ContentLinkHandler =
Attachment #8363376 - Flags: review+
Comment on attachment 8363374 [details] [diff] [review]
utils-jsm

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

All nits, except for the isContentFrame function issue

::: toolkit/content/contentAreaUtils.js
@@ +37,5 @@
>  
> +// Expose everything in Utils.
> +Components.utils.import("resource://gre/modules/Utils.jsm");
> +for (let func in Utils)
> +  this[func] = Utils[func];

while this is clean, it makes it hard to grep the code and understand how it's getting called. So I prefer if we do the slightly verbose:

function urlSecurityCheck(aURL, aPrincipal, aFlags) {
 return Utils.urlSecurityCheck(aURL, aPrincipal, aFlags);
}

With this we can also add newer functions to Utils and they won't be unknowingly exposed here by mistake

::: toolkit/modules/Utils.jsm
@@ +1,3 @@
> +// This Source Code Form is subject to the terms of the Mozilla Public
> +// License, v. 2.0. If a copy of the MPL was not distributed with this
> +// file, You can obtain one at http://mozilla.org/MPL/2.0/.

(very nitpicky, but most .jsms I can find use /* */ for the license, so let's keep a consistent style)

@@ +9,5 @@
> +const {interfaces: Ci, utils: Cu} = Components;
> +
> +Cu.import("resource://gre/modules/Services.jsm");
> +
> +let Utils = {

this.Utils =

@@ +55,5 @@
> +  isContentFrame: function(aFocusedWindow) {
> +    if (!aFocusedWindow)
> +      return false;
> +
> +    return (aFocusedWindow.top == window.content);

hmm, this will not work in the context of the jsm anymore.  Can just function be kept in contentAreaUtils.js?  Otherwise we'll have to pass the window as a parameter..

Or if you can think of a way to fix this in an e10s compat way, even better :)

::: toolkit/modules/moz.build
@@ +43,5 @@
>      'Sqlite.jsm',
>      'Task.jsm',
>      'TelemetryTimestamps.jsm',
>      'Timer.jsm',
> +    'Utils.jsm',

Following Gavin's suggestion, let's name this something more specific. But since this is in toolkit, perhaps ContentAreaUtils.jsm (very creative..) is better than BrowserUtils.
Attachment #8363374 - Flags: review?(felipc)
Comment on attachment 8363375 [details] [diff] [review]
feeds-jsm

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

::: browser/modules/Feeds.jsm
@@ +8,5 @@
> +
> +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
> +
> +XPCOMUtils.defineLazyModuleGetter(this, "Utils",
> +                                  "resource://gre/modules/Utils.jsm");

(reminder to update this path with the new name from part 1)

@@ +12,5 @@
> +                                  "resource://gre/modules/Utils.jsm");
> +
> +const Ci = Components.interfaces;
> +
> +let Feeds = {

this.Feeds =
Attachment #8363375 - Flags: review?(felipc) → review+
Comment on attachment 8364540 [details] [diff] [review]
content-link-handler v2

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

(ops, wrong attachment before)

::: browser/modules/ContentLinkHandler.jsm
@@ +17,5 @@
> +  "resource:///modules/Feeds.jsm");
> +XPCOMUtils.defineLazyModuleGetter(this, "Utils",
> +  "resource://gre/modules/Utils.jsm");
> +
> +let ContentLinkHandler = {

this.ContentLinkHandler =
Attachment #8364540 - Flags: review?(felipc) → review+
Attached patch utils-jsm v2Splinter Review
I just took isContentFrame out of the module. Thanks for noticing that.

I named the module BrowserUtils because ContentAreaUtils is already used as a sort-of module name in other places (including contentAreaUtils.js), and I didn't want to add confusion.
Attachment #8363374 - Attachment is obsolete: true
Attachment #8372650 - Flags: review?(felipc)
Attachment #8372650 - Flags: review?(felipc) → review+
https://hg.mozilla.org/mozilla-central/rev/0f413d6ff704
https://hg.mozilla.org/mozilla-central/rev/639da97e1703
https://hg.mozilla.org/mozilla-central/rev/e6ea08c51560
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → Firefox 30
Keywords: verifyme
Status: RESOLVED → VERIFIED
Keywords: verifyme
There are still tests disabled on e10s with a note pointing to the dupe (bug 918663). Should those be re-enabled?
Flags: needinfo?(wmccloskey)
We're not running browser-chrome tests in e10s at all. I guess it's fine to remove the annotation, but it won't do anything right now.
Flags: needinfo?(wmccloskey)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: