Open Bug 1448045 Opened 2 years ago Updated 1 month ago

Can we remove the window.controllers shim?


(Core :: DOM: Core & HTML, task, P3)





(Reporter: bzbarsky, Unassigned)



(Keywords: site-compat)

But note bug 1010577, where removal did not go _that_ well last time.  But some of the relevant libraries got fixed since then, so maybe we can do better now...  We would need to at least check the sites that caused this shim to be put in place.
(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #0)
> Mike, have you seen any web compat issues reported due to nightly not having
> this shim?  This is the thing that adds a window.controllers and
> window.Controllers in beta-and-release only.

The only instance where it's shown up is, but it seems unrelated to the bug as reported (and I just confirmed that app still works in Nightly). AFAICT, the fallout for Nightly users has been minimal.

Since it was coming from ace.js, I see they updated their detection code in the following commit:

I'll ask our SV contractors to go over the sites from 1010577 and report back here. Leaving ni? to remember to do that.
Keywords: site-compat
Hello all,

We took a look on and came up with a list of sites that we thought needed testing to see if any of them log a "window.controllers/Controllers is deprecated. Do not use it for UA detection." message in the console.

Here are our findings:

#List of sites#

#Particularities# - displays a "Browser Unsupported" message on Nightly 61. - "Secure Connection Failed" on Nightly 61, "Unable to connect" on Release 59. - "404" page on both Nightly 61 and Release 59. - "We’re having trouble finding that site" page on both Nightly 61 and Release 59. - Could not open on both Nightly 61 and Release 59.

#window.controllers findings#
Only logs the "window.controllers/Controllers is deprecated. Do not use it for UA detection." message in the Console, on Firefox Release 59.
On Nightly 61, none of them log this message.

I don't know if we caught every site in question, but if we didn't we'll be happy to comb through Bugzilla again.
Flags: needinfo?(miket)
> On Nightly 61, none of them log this message.

Right, on Nightly 61 we hid Controllers entirely.

Looks like does in fact use Controllers and breaks if it's not present.  The use looks like this:

    if ((document.all || (window.fF_ && document.all instanceof window.fF_)) && !navigator.userAgent.match(/opera/i) && !navigator.appVersion.match(/mac/i)) {
      bb.A_ = true;
      bb.cd_ = "ie";
      /* etc */

    } else {
      if ((window['controllers'] || window['Controllers']) && parseInt(navigator.productSub, 10) > 20031001) {
        bb._T_ = true;
        bb.cd_ = 'gecko';
        bb._m_ = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('rv:') + 3, 4))
      } else {
        if (navigator.userAgent.match(/opera/i)) {
          bb._N_ = true;
          bb.cd_ = 'opera';
          bb._m_ = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf(/opera[ \/]/i) + 7, 5))
        } else {
          if (navigator.userAgent.match(/applewebkit/i)) {
            bb._E_ = true;
            bb.cd_ = 'webkit';
            bb._m_ = parseFloat(navigator.userAgent.match(/applewebkit\/([0-9\.]+)/i) [1]);
            bb.fG_ = navigator.userAgent.match(/AdobeAIR/) && !!window.runtime

and then later:

    if (!(bb.A_ || bb._T_ || bb._N_ || bb._E_)) {
      return bb.customFallback(1)

which is where the "unsupported" alert comes from.  So the only way to work with this site while dropping Controllers is to have either "webkit" or "opera" in the UA string (or have a non-falsy document.all, which no one does at this point).

Sergiu, thank you for digging through those!
Do we support per-origin UA overrides on Desktop? If so, this seems like a great use-case.
(In reply to Bobby Holley (:bholley) from comment #5)
> Do we support per-origin UA overrides on Desktop? If so, this seems like a
> great use-case.

I believe we do! 

(Or soon will... Dennis, is this possible today or do we need to wait for Bug 1386807 to land?)
Flags: needinfo?(dschubert)
> Dennis, is this possible today

We could do that right now, with our Version 1 source in all the browsers, and rolling out an update based on the old code. Do you want me to run some tests on the UA changes we need to make and propose an update to be rolled out?
Flags: needinfo?(dschubert)
Yes, please. Can you file a bug for that?
Flags: needinfo?(dschubert)
See Also: → 1452707
Done, bug 1452707. Will build the patch and push the XPI to QA as my first action tomorrow.
Flags: needinfo?(dschubert)
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Type: enhancement → task
You need to log in before you can comment on or make changes to this bug.