If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Setting image for toolbarbutton via .style.listStyleImage and via image="" attribute conflicts

RESOLVED INCOMPLETE

Status

()

Core
XUL
RESOLVED INCOMPLETE
3 years ago
a year ago

People

(Reporter: Enyby, Unassigned, NeedInfo)

Tracking

33 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Build ID: 20141106120505

Steps to reproduce:

I have object toolbarbutton in btn variable.
I want to change icon on it.
I have valid and worked image url in some_url variable.
I run code:
1. btn.image = some_url;
or
2. btn.style.listStyleImage = "url('" + some_url + "')";


Actual results:

Nothing changes.

Sometimes 1 variant work OR 2 variant work. If one is worked - other is do nothing.
Its behaivour still persistent on current browser run. If I restarted it - it may change. Or not.

Its annoying. Need deterministic behaviour.

Its be on FF 32.0.3 too.


Expected results:

Icon must be changed to new image, specified in some_url.
(Reporter)

Comment 1

3 years ago
Upd: Its be on FF 33.0.3 too. Not in "32.0.3". Its my mistake.

Comment 2

3 years ago
Could you attach a simple testcase showing the issue up, please.
Flags: needinfo?(Enyby)
Keywords: testcase-wanted
(Reporter)

Comment 3

3 years ago
Created attachment 8520818 [details]
bug_1096909@bugzilla.mozilla.org_v1.0.xpi - addon with test case

Test case for bug. It adddon add icon to toolbar. On click it increment counter and show it on button with prefix. prefix 's' for style method and 'i' for image method. 

code:
		if (bug_1096909.counter % 2 == 0) {
			btn.image = canvas.toDataURL("image/png");
		} else {
			btn.style.listStyleImage = "url('" + canvas.toDataURL("image/png") + "')";
		}

Style method worked only first time. Other time work only image method.
Flags: needinfo?(Enyby)
(Reporter)

Updated

3 years ago
Keywords: testcase-wanted

Comment 4

3 years ago
How do this add-on work? I installed it on FF34, I got an icon in the toolbar, but when I click, it opens a forum page....
(Reporter)

Comment 5

3 years ago
Created attachment 8522023 [details]
bug_1096909@bugzilla.mozilla.org_v1.0.xpi

My mistake. Uploaded wrong file.
Attachment #8520818 - Attachment is obsolete: true

Comment 6

3 years ago
My observation:
0) add-on installed: icon with number "4" on gray background
1) 1st click: background becomes blue and prefix "s1" displayed
2) 2nd click: prefix incremented to "i2"
3) 3rd click: nothing
4) 4th click: prefix incremented to "i4"
etc... (i6, i8, i10... i2n)

I tested with the old Firefox 17, same behaviour.

So what's wrong? What should I see?
(Reporter)

Comment 7

3 years ago
You should see next:
0) add-on installed: icon with number "4" on gray background
1) 1st click: background becomes blue and prefix "s1" displayed
2) 2nd click: prefix incremented to "i2"
3) 3rd click: prefix incremented to "s3"
4) 4th click: prefix incremented to "i4"
etc... (s5, i6, s7, i8, s9, i10... i2n, s(2n+1))



On click it increment counter and show it on button with prefix. prefix 's' for style method and 'i' for image method. 

code:
		if (bug_1096909.counter % 2 == 0) {
			btn.image = canvas.toDataURL("image/png"); // image method
		} else {
			btn.style.listStyleImage = "url('" + canvas.toDataURL("image/png") + "')"; // style method
		}

In some runs browser works only style method. But it rarely.

Comment 8

2 years ago
If someone decides to take a look, here's the XBL binding for the toolbarbutton:
http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/toolbarbutton.xml#12

As far as I can see, you're ending up setting both
1) <xul:image src=...> (via btn.image=...) - see http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/toolbarbutton.xml#12
2) <toolbarbutton style="list-style-image: ..."> (via btn.style)

I'm not sure how it's supposed to behave -- a reasonable behavior is for one of the ways always to have precedence over the other (as described in comment 6) - i.e. you probably shouldn't expect to see the results described in comment 7.

Are you saying that with the steps to reproduce from comment 6 you get different results from run to run? What other results do you get?
Component: Untriaged → XUL
Flags: needinfo?(Enyby)
Product: Firefox → Core
Summary: Setting image for toolbarbutton → Setting image for toolbarbutton via .style.listStyleImage and via image="" attribute conflicts

Comment 9

a year ago
There is no response for comment8 requested info. Closing this bug as resolved:incomplete.
Feel free to reopen if you encounter this issue on the current version.
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.