Tab Utilities Phoenix Compatibility

This board is for discussions, bug reports, etc. for pre-releases of the v28 milestone building on UXP.

Moderator: satrow

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-05-28, 13:13

Hi everyone,

I'm stux, and for lack of a better term, I'm the "maintainer" of Tab Utilities Phoenix (TUP). I am currently working on getting TUP up an running on UXP/PM 28a2. I am writing this post because I need help debugging and addressing issues I've run into during testing. Here are the details of my issues:
  • I have merged all the latest changes from the Tab Utilities Fixed (TUF) addon into TUP. This provides FF 52ESR compatibility.
  • I have tested both the new, merged version of TUP and the latest TUF in both PM 28a2 and FF52, and as a result: both addons worked on FF 52, but failed to work properly on PM28.
  • Looking at the Browser console there are several errors related to unknown/missing objects such as: "PlacesViewBase.prototype.place", "BrowserSearch", "gBrowser.updatePinnedTabsBar()"; details will be posted later.
The reason I'm making this post is that despite having maintained TUP for several years now (5 years already!?) my knowledge of XUL/js development is still limited. I've been lucky enough to be able to merge in fixes contributed by other developers but it seems my luck has run out! :thumbdown: This makes is hard for me to track down the cause(s) of these issues and make appropriate resolutions: (are these UXP bugs or do they need workarounds?) My current development background is mainly C#/Java and T-SQL so I feel somewhat lost when it comes to some of Javascript's features, so please be patient with me! I also work full time, which makes it harder to devote as much time to the project as I'd like!

Going forward, here are my goals:
  • I will try to create a github repository for TUP in the near future. I'm more familiar with SVN so this is another learning curve. Until then I will pastebin source code snippets individually.
  • I'll also post a link to the development XPI later today or tomorrow if anyone would like to try it.
  • I want to address each of these errors one at a time on separate posts. I won't bring up the next error until either the current issue is either fixed or a UXP issue has to be filed on github.
  • If I'm successful setting up github, issue discussion can be moved there.
Thanks again everyone for your time, help and patience. I'm hoping these issues can be resolved easily and TUP is back to working order on UXP soon! :D

--stux

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1780
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Tab Utilities Phoenix Compatibility

Unread post by JustOff » 2018-05-28, 13:42

I'll be happy to help you as much as I can, and having the sources on GitHub would be extremely useful for this.
Here are the add-ons I made in a spare time. That was fun!

GMforker
Astronaut
Astronaut
Posts: 537
Joined: 2015-08-27, 06:29
Location: Czech Republic

Re: Tab Utilities Phoenix Compatibility

Unread post by GMforker » 2018-05-28, 19:25


stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-05-29, 03:44

JustOff wrote:I'll be happy to help you as much as I can, and having the sources on GitHub would be extremely useful for this.
GMforker wrote:See UXP pull 404.
Thanks for your help JustOff! With the help of Stack Overflow and some online guides, I was able to figure out how to create a repository for Tab Utilties Phoenix (and abuse git for hosting the XPI files).
The links are as follows: Thanks GMforker for posting the link to that UXP Pull request! It looks like many of these issues may be caused by that! I'm strongly considering waiting until the next alpha release is made available before posting the actual errors. I'm also tired tonight. :coffee: Thanks again everyone for your help!

EDIT: I forgot to include the TUP 2.1 branch url.

--stux
Last edited by stux2000 on 2018-05-29, 03:49, edited 1 time in total.

User avatar
back2themoon
Board Warrior
Board Warrior
Posts: 1448
Joined: 2012-08-19, 20:32

Re: Tab Utilities Phoenix Compatibility

Unread post by back2themoon » 2018-06-10, 10:59

I haven't tested much but it seems Tab Utilities Phoenix 2.0.4 now works just fine in Pale Moon 28.0.0a4. :thumbup:

update: although there are several related errors in the Error Console.
Untitled.png
Last edited by back2themoon on 2018-06-10, 11:05, edited 2 times in total.
Safe Mode / clean profile info: Help/Restart in Safe Mode
Information to include when asking for support - How to apply user agent overrides
How to download videos

Windows 10 Pro • Pale Moon x64 • Interlink x86 • Emsisoft Anti-Malware

GMforker
Astronaut
Astronaut
Posts: 537
Joined: 2015-08-27, 06:29
Location: Czech Republic

Re: Tab Utilities Phoenix Compatibility

Unread post by GMforker » 2018-06-10, 11:58

Customize Titlebar - throws an error:

Code: Select all

missing ] after element list
See bug #1220564 (also https://forum.palemoon.org/viewtopic.ph ... 32#p142132)

Tab Utilities Phoenix - these are not critical errors (but hooking functions not easy - if it is to be done correctly).

And some things no longer exist, e.g.:

Code: Select all

FullScreen.mouseoverToggle
- see UXP commit ec3d61fb3133c8d44a823ce4e20906d6e22beb7b
Last edited by GMforker on 2018-06-10, 12:27, edited 2 times in total.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 24459
Joined: 2011-08-28, 17:27
Location: 58°2'16"N 14°58'31"E
Contact:

Re: Tab Utilities Phoenix Compatibility

Unread post by Moonchild » 2018-06-11, 08:59

The parentheses before/after formal parameters errors are things that should be fixed though.
"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne
Image

User avatar
back2themoon
Board Warrior
Board Warrior
Posts: 1448
Joined: 2012-08-19, 20:32

Re: Tab Utilities Phoenix Compatibility

Unread post by back2themoon » 2018-06-18, 11:43

I'm not sure whether browser.tabs.resize_immediately works as expected in PM28 on its own (it seems sometimes it does, others it doesn't), but I'm also not sure if TUP includes a similar option that might interfere with it...
Safe Mode / clean profile info: Help/Restart in Safe Mode
Information to include when asking for support - How to apply user agent overrides
How to download videos

Windows 10 Pro • Pale Moon x64 • Interlink x86 • Emsisoft Anti-Malware

User avatar
back2themoon
Board Warrior
Board Warrior
Posts: 1448
Joined: 2012-08-19, 20:32

Re: Tab Utilities Phoenix Compatibility

Unread post by back2themoon » 2018-06-25, 17:56

Most probably browser.tabs.resize_immediately=true is indeed being blocked by TUP in PM28, unless I'm missing a specific option for that in TUP. Disabling TUP makes it work again.
Last edited by back2themoon on 2018-06-25, 17:56, edited 1 time in total.
Safe Mode / clean profile info: Help/Restart in Safe Mode
Information to include when asking for support - How to apply user agent overrides
How to download videos

Windows 10 Pro • Pale Moon x64 • Interlink x86 • Emsisoft Anti-Malware

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-06-25, 21:59

Hi everyone, sorry for the wait. I'm posting this in hopes of getting assistance in resolving these hook and other errors that are shown
in the console. Hopefully the will resolve the missing tab grouping notch issue as well as back2themoon's issue. I haven't quite been getting the same errors posted above. Instead, after updating to (alpha 4) and now (beta 1), I've seen these three errors (truncated):

Code: Select all

Failed to hook PlacesViewBase.prototype.place
---
TU_hookSetter@chrome://tabutils/content/tulib.js:58:72
arrowscrollbox_XBL_Constructor@chrome://tabutils/content/tabutils.xml:104:11 

Code: Select all

Failed to hook FullScreen.mouseoverToggle
---
TU_hookCode@chrome://tabutils/content/tulib.js:28:72
tabutils._verticalTabs@chrome://tabutils/content/tabutils-vt.js:31:3 

Code: Select all

Failed to hook gSessionHistoryObserver.observe
---
TU_hookCode@chrome://tabutils/content/tulib.js:28:72
tabutils._undoCloseTabButton@chrome://tabutils/content/tabutils.js:2897:3 
I also saw this error in the error console:

Code: Select all

Timestamp: 6/25/2018 5:14:58 PM
Error: A promise chain failed to handle a rejection. Did you forget to '.catch', or did you forget to 'return'?
See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise

Date: Mon Jun 25 2018 17:14:57 GMT-0400 (Eastern Standard Time)
Full Message: ReferenceError: aCurrentBrowser is not defined
Full Stack: openLinkIn@chrome://tabutils/content/tulib.js line 105 > eval:155:5
openUILinkIn@chrome://tabutils/content/tulib.js line 105 > eval:24:11
loadCurrent@chrome://tabutils/content/tulib.js line 105 > eval:72:21
continueOperation@chrome://tabutils/content/tulib.js line 105 > eval:115:17
handleCommand/<@chrome://tabutils/content/tulib.js line 105 > eval:34:17
_canonizeURL/<@chrome://browser/content/urlbarBindings.xml:415:13
process@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:932:23
walkerLoop@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:813:7
scheduleWalkerLoop/<@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:747:11

Source File: chrome://tabutils/content/tulib.js line 105 > eval
Line: 155
Source Code:
155
I could use some help learning how to debug these issues. There are parts of javascript that read like perl to me. I'd like to start with the PlacesViewBase.prototype.place error and work on the rest one at a time. They link to tulib.js line 58 and tabutils.xml line 104 the latter of which has the following code:

Code: Select all

TU_hookSetter("PlacesViewBase.prototype.place", /.*executeQueries[\s\S]*addObserver.*/, "try {$&} catch (e) {}");  //Fx 4.0
Ideally, I'd like to know what is this doing? Just from the name I'm assuming that it's hooking to some event handler by replacing its own function call using reflection. I think? To me the second option looks like perl regex, but I can't tell what's being replaced by what. I think clarifying this would be a good starting point for me. Or documentation that I can read that explains the specific syntax above would also help.

Finally :
Most probably browser.tabs.resize_immediately=true is indeed being blocked by TUP in PM28, unless I'm missing a specific option for that in TUP. Disabling TUP makes it work again.
There are two possibilities I can think of: either the failed hooks above are breaking something or the "Tab Width" option (under "Appearance/Tabs") is interfering with that. Unless it worked in PM 27?

Anyway, thanks everyone for your help and patience!

-stux

User avatar
back2themoon
Board Warrior
Board Warrior
Posts: 1448
Joined: 2012-08-19, 20:32

Re: Tab Utilities Phoenix Compatibility

Unread post by back2themoon » 2018-06-25, 22:09

stux2000 wrote:
Most probably browser.tabs.resize_immediately=true is indeed being blocked by TUP in PM28, unless I'm missing a specific option for that in TUP. Disabling TUP makes it work again.
There are two possibilities I can think of: either the failed hooks above are breaking something or the "Tab Width" option (under "Appearance/Tabs") is interfering with that. Unless it worked in PM 27?
i don't think I've changed Tab Width, it's 100 to 250px. On PM27 browser.tabs.resize_immediately works.
Safe Mode / clean profile info: Help/Restart in Safe Mode
Information to include when asking for support - How to apply user agent overrides
How to download videos

Windows 10 Pro • Pale Moon x64 • Interlink x86 • Emsisoft Anti-Malware

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-06-25, 23:18

back2themoon wrote:i don't think I've changed Tab Width, it's 100 to 250px. On PM27 browser.tabs.resize_immediately works.
Then I'll have to see if resolving the tab hooks resolves that issue. BTW, what does this option do, so I know what to test? I see that it's turned off by default.

User avatar
back2themoon
Board Warrior
Board Warrior
Posts: 1448
Joined: 2012-08-19, 20:32

Re: Tab Utilities Phoenix Compatibility

Unread post by back2themoon » 2018-06-25, 23:34

Ok I'm sorry, problem solved and there's no PM28 issue. I was almost certain there was an option for this in TUP, I just couldn't locate it again. It's extensions.tabutils.delayResizing. All the details are here.

I guess it's not really necessary since Pale Moon already includes this (TUPs setting overrides PMs)
Last edited by back2themoon on 2018-06-25, 23:36, edited 3 times in total.
Safe Mode / clean profile info: Help/Restart in Safe Mode
Information to include when asking for support - How to apply user agent overrides
How to download videos

Windows 10 Pro • Pale Moon x64 • Interlink x86 • Emsisoft Anti-Malware

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1780
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Tab Utilities Phoenix Compatibility

Unread post by JustOff » 2018-06-26, 18:41

stux2000 wrote:I could use some help learning how to debug these issues. There are parts of javascript that read like perl to me. I'd like to start with the PlacesViewBase.prototype.place error and work on the rest one at a time. They link to tulib.js line 58 and tabutils.xml line 104 the latter of which has the following code:

Code: Select all

TU_hookSetter("PlacesViewBase.prototype.place", /.*executeQueries[\s\S]*addObserver.*/, "try {$&} catch (e) {}");  //Fx 4.0
Ideally, I'd like to know what is this doing? Just from the name I'm assuming that it's hooking to some event handler by replacing its own function call using reflection. I think? To me the second option looks like perl regex, but I can't tell what's being replaced by what. I think clarifying this would be a good starting point for me. Or documentation that I can read that explains the specific syntax above would also help.
TU_hookSetter tries to change the setter of the place property of the PlacesViewBase object using a dirty hack (Function.prototype.toString() + JS regex + eval()).

Here is the source it works on:

Code: Select all

   set place(val) {
     this._place = val;

     let history = PlacesUtils.history;
     let queries = { }, options = { };
     history.queryStringToQueries(val, queries, { }, options);
     if (!queries.value.length)
       queries.value = [history.getNewQuery()];

     let result = history.executeQueries(queries.value, queries.value.length,
                                         options.value);
     result.addObserver(this, false);
     return val;
   },
And after the replace it becomes:

Code: Select all

function set place(val) {
    this._place = val;

    let history = PlacesUtils.history;
    let queries = { }, options = { };
    history.queryStringToQueries(val, queries, { }, options);
    if (!queries.value.length)
      queries.value = [history.getNewQuery()];

try {    let result = history.executeQueries(queries.value, queries.value.length,
                                        options.value);
    result.addObserver(this, false);} catch (e) {}
    return val;
  }
The actual error thrown in eval() is "missing ( before formal parameters", because such calls aren't allowed by the modern JS engine.

PS: The same is observed with Tab Utilities Fixed in Firefox ESR 52; perhaps it's not so important, I didn't dig deeper.
Here are the add-ons I made in a spare time. That was fun!

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-08-05, 18:00

I'm Sorry for the very late reply. RL can be difficult at times. :( Instead of my original piecemeal plan, I'll list my known issues here and split the post into sections. The section that's of most importance is probably section IV.


SECTION I.

Thanks Justoff for explaining how the hooking process works in detail! I've wanted to cleanup and refactor this code since I created this fork. This gives me a clearer understanding of what it's doing, especially the ugly hax, and it's one more thing to refactor down the road in future releases.
JustOff wrote:The actual error thrown in eval() is "missing ( before formal parameters", because such calls aren't allowed by the modern JS engine.
If you don't mind me asking, can you elaborate a little more about what it is that is no longer allowed by eval()? (I'm guessing it's for security reasons?) My understanding is that line 105 is basically doing this:

Code: Select all

return eval("(function set place(val) {
    this._place = val;

    let history = PlacesUtils.history;
    let queries = { }, options = { };
    history.queryStringToQueries(val, queries, { }, options);
    if (!queries.value.length)
      queries.value = [history.getNewQuery()];

try {    let result = history.executeQueries(queries.value, queries.value.length,
                                        options.value);
    result.addObserver(this, false);} catch (e) {}
    return val;
  })");
And the returned function then overrides the original setter. I tried searching for the error and from a stack overflow answer it seems that the error refers to the function definition itself: the (val) segment which to me seems like valid javascript. So I'm not sure what the error is referring to.


SECTION II.
The next error I saw was:

Code: Select all

Failed to hook FullScreen.mouseoverToggle
and it originates on line 31 of tabutils-vt.js. As I understand it (or at least try to remember correctly), FullScreen.mouseoverToggle was deprecated and a different function needs to be used? I tried searching for the github issue where this was reported but I couldn't find it. Some guidance as to what to use instead would be helpful. I suspect this would only affect vertical tabs on full-screen mode (I'll test that soon) but it's something that probably needs to be addressed.

SECTION III.
The third error I encountered was:

Code: Select all

Failed to hook gSessionHistoryObserver.observe
This is called from line 2897 and it seems to add a call to "tabutils.updateUndoCloseTabCommand();" at the end of this code. So, is this the same eval() issue as in Section I?

SECTION IV.
Okay, so this section will cover the major issue that I'm having with tab groups: normally, tab group tabs have a notch that lets you expand/contract the tab group. However, this notch is missing and cannot be used to expand/contract each group. Everything else works (the functionality can be accessed via menu), so it's just the notch that's missing. I think that this notch is the "tab-twisty" element in the tabutils.xml file. The twisty is present and working in FF 52. I did a search for the tab-twisty term and found a CSS file that points to "chrome://global/skin/tree/twisty.svg". Searching for that file on xref and github yields many hits, including this reference, so I'm assuming that the file should be there. I am running Windows 7 so is it possible that "twisty-preWin10.svg" (as referenced in the last link) is missing? I should test this on Linux when I get a chance! (I need to rebuild my VM before I can do that.)

SECTION V.
Okay, so here I'm listing the two minor issues that are kind of small annoyances but not showstoppers:
  • The number that indicates how many tabs are in a tab group is now displayed on the left side of the tab instead of the right. I suspect this is a change that was deliberately made by TUF.
  • When first loading pale moon (and you have a lot of tabs and tab groups) the tabs seem to jitter while the tabs are being grouped.
These can be dealt with later are not a high priority.

Okay, that's it for now. Thank you for any help that you guys can provide and again, sorry for the late response!

-stux

User avatar
Lootyhoof
Themeist
Themeist
Posts: 1277
Joined: 2012-02-09, 23:35
Location: United Kingdom

Re: Tab Utilities Phoenix Compatibility

Unread post by Lootyhoof » 2018-08-05, 18:36

stux2000 wrote:Okay, so this section will cover the major issue that I'm having with tab groups: normally, tab group tabs have a notch that lets you expand/contract the tab group. However, this notch is missing and cannot be used to expand/contract each group. Everything else works (the functionality can be accessed via menu), so it's just the notch that's missing. I think that this notch is the "tab-twisty" element in the tabutils.xml file. The twisty is present and working in FF 52. I did a search for the tab-twisty term and found a CSS file that points to "chrome://global/skin/tree/twisty.svg". Searching for that file on xref and github yields many hits, including this reference, so I'm assuming that the file should be there. I am running Windows 7 so is it possible that "twisty-preWin10.svg" (as referenced in the last link) is missing? I should test this on Linux when I get a chance! (I need to rebuild my VM before I can do that.)
twisty-preWin10.svg is actually mapped to twisty.svg on Windows versions below Win10. These SVGs are only used on Windows though, not other platforms, so please don't rely on it (you'd also break many custom themes if you used that, anyway).

I'd always suggest extensions either:

1. Use standard widget types (so, if you used a tree each row that expands outward would get a twisty, styled as-intended by the theme in use).
2. If you can't do the above, use your own icons. This prevents any conflicts.

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-08-05, 19:31

Lootyhoof wrote: twisty-preWin10.svg is actually mapped to twisty.svg on Windows versions below Win10. These SVGs are only used on Windows though, not other platforms, so please don't rely on it (you'd also break many custom themes if you used that, anyway).

I'd always suggest extensions either:

1. Use standard widget types (so, if you used a tree each row that expands outward would get a twisty, styled as-intended by the theme in use).
2. If you can't do the above, use your own icons. This prevents any conflicts.
No, no, I think I raised a misunderstanding here in what I wrote: the CSS in tab utilities maps to twisty.svg, but it is not showing up. My theory was that maybe there was an issue in Windows 7 where maybe twisty-preWin10.svg wasn't mapped correctly to twisty.svg (there seemed to be a similar bug or bugs in previous alpha/beta UXP releases). So I am looking for the root cause of why my twisty isn't showing up! Also, I realized about 20 minutes ago that the twisty is probably used in the options and indeed, the certificates window uses it and shows up and works correctly, so it looks like my theory is incorrect. So i'm back to square one.

My other theory is: could it be related to the removal of lines 170-171 from the XML file? I can test it later (today or during the week as time allows) but I still think it's low probability since FF 52 works fine without it. Then again, it might be a UXP-specific issue. Other than trying things I don't have a good way of tracking down what the root cause of the twisty being missing might be. (And no relevant errors show up on the console.) So, any hints would be most welcome!
Last edited by stux2000 on 2018-08-05, 19:32, edited 1 time in total.

stux2000
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2013-09-20, 08:02
Location: United States

Re: Tab Utilities Phoenix Compatibility

Unread post by stux2000 » 2018-08-05, 21:15

stux2000 wrote: My other theory is: could it be related to the removal of lines 170-171 from the XML file? I can test it later (today or during the week as time allows) but I still think it's low probability since FF 52 works fine without it. Then again, it might be a UXP-specific issue. Other than trying things I don't have a good way of tracking down what the root cause of the twisty being missing might be. (And no relevant errors show up on the console.) So, any hints would be most welcome!
UPDATE: I just tested bringing back lines 170-171 above and it fixed the less-important tab count issue (Section V) but the tab twisty issue is still unresolved :(. I also tested to see if I could navigate to the closed twisty url itself (chrome://global/skin/tree/twisty.svg#clsd) in a browser tab and that worked fine in both PM 27 and PM 28 so it shouldn't be a problem with accessing the resource itself. One odd thing though: the closed twisty in TUP is filled in black, while the one in the url above is filled in white. But I doubt that is related to the twisty's unfortunate disappearance :( ...right?

Any ideas on how to track down the source of this problem would be most welcome!

-stux

Locked