Closed Bug 1813197 Opened 1 year ago Closed 11 months ago

Use moz-support-link in the setButtons functions in notificationbox.js

Categories

(Toolkit :: UI Widgets, task)

task

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: tgiles, Assigned: tgiles)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

(Whiteboard: [recomp])

Attachments

(3 files, 1 obsolete file)

In notificationbox.js, there are two functions named setButtons. These functions have some logic that can be handled by the moz-support-link. You can get a test notification by running the following snippet in the browser toolbox:

let box = gNotificationBox;
box.appendNotification(
"infobar-testone-value",
{
  label: "Test message",
  priority: box.PRIORITY_INFO_HIGH,
},
[
  {
    label: "testButton",
    supportPage: "dnt"
  }
]
);

However, I don't know if we can use HTML elements in this context or not. I've tried to insert <html:a> via both document.createElement and document.createXULElement and that doesn't seem to work. I've also tried inserting just the anchor <a> with those create APIs but then I can't actually navigate to the href that is in the link. I'm not sure what is preventing navigation, I thought it was the handleEvent function in the notificationbox code, but the navigation occurs before the click event is handled by notificationbox.

Hmm, it seems like this might be more complicated then I originally thought. So in this case, the XUL text-link is implemented in text.js and has an open function for handling links. It looks like this open function is handling security as well as handing the href off to other potential applications to open the link. I'm not sure if we need to do this for the moz-support-link cases, but I'd figure I would note it. I'm still not sure why the html anchor element doesn't work as expected in the notification box.

Whiteboard: [fidefe-reusable-components-ms1] → [fidefe-reusable-components-ms2]
Assignee: nobody → tgiles
Status: NEW → ASSIGNED

This allows the moz-support-link to be used in the notificationbox
global popup when the appendNotification call uses the supportPage
parameter. The existing behavior of creating a XUL text-link
label is kept intact when not using the supportPage parameter.

Since the decoderDoctor test uses a SUMO support link, the test needed
to be updated to accomodate this change. We are also able to remove
some usage of .properties strings in this test due to the Fluent
support of the moz-support-link.

Depends on D173880

Since test_notificationbox.xhtml has tasks that use SUMO support links,
this also needed to be updated so that the correct label text was
tested.

Depends on D173881

Attachment #9325543 - Attachment description: Bug 1813197 - add moz-support-link to notificationbox.js r=mstriemer,hjones → Bug 1813197 - Add moz-support-link to notificationbox.js r=mstriemer,hjones

To prevent regressions when calling the appendNotification function,
we add two tests for XUL buttons. These tests ensure that the button
label is set correctly when using the "label" or "l10n-id" parameters.

Depends on D173882

Attachment #9325545 - Attachment is obsolete: true
Pushed by tgiles@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a326217c9777
Add moz-support-link to notificationbox.js r=mstriemer,hjones
https://hg.mozilla.org/integration/autoland/rev/2733bac6a707
Fix regressions in decoderDoctor after adding moz-support-link to notificationbox. r=mstriemer,kinetik,media-playback-reviewers
https://hg.mozilla.org/integration/autoland/rev/d43f4360487b
Add tests for appending buttons with label or l10n-id. r=mstriemer
Regressions: 1830933

Backed out for causing mochitest failures on browser_decoderDoctor.js

Backout link

Push with failures

Failure log

Flags: needinfo?(tgiles)
Pushed by tgiles@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4b86d9195fe5
Add moz-support-link to notificationbox.js r=mstriemer,hjones
https://hg.mozilla.org/integration/autoland/rev/c8de74393402
Fix regressions in decoderDoctor after adding moz-support-link to notificationbox. r=mstriemer,kinetik,media-playback-reviewers
https://hg.mozilla.org/integration/autoland/rev/e1b12e3a90f8
Add tests for appending buttons with label or l10n-id. r=mstriemer

Backed out for causing mochitest-browser-media failures on browser_decoderDoctor.js.

[task 2023-05-08T20:46:42.679Z] 20:46:42     INFO - TEST-START | dom/media/doctor/test/browser/browser_decoderDoctor.js
[task 2023-05-08T20:46:42.682Z] 20:46:42     INFO - GECKO(5030) | Chrome file doesn't exist: /builds/worker/workspace/build/tests/mochitest/browser/dom/media/doctor/test/browser/head.js
[task 2023-05-08T20:46:42.698Z] 20:46:42     INFO - GECKO(5030) | [Child 5192: Main Thread]: I/DocShellAndDOMWindowLeak ++DOCSHELL 7fb73dc33800 == 1 [pid = 5192] [id = 0]
[task 2023-05-08T20:46:42.698Z] 20:46:42     INFO - GECKO(5030) | [Child 5192: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 1 (7fb742e63470) [pid = 5192] [serial = 1] [outer = 0]
[task 2023-05-08T20:46:42.703Z] 20:46:42     INFO - GECKO(5030) | [Child 5192: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 2 (7fb73dc34000) [pid = 5192] [serial = 2] [outer = 7fb742e63470]
[task 2023-05-08T20:46:43.361Z] 20:46:43     INFO - GECKO(5030) | [Child 5218, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-05-08T20:46:43.363Z] 20:46:43     INFO - GECKO(5030) | [Child 5218, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-05-08T20:46:43.366Z] 20:46:43     INFO - GECKO(5030) | JavaScript error: resource://gre/modules/XULStore.sys.mjs, line 60: Error: Can't find profile directory.
[task 2023-05-08T20:46:43.367Z] 20:46:43     INFO - GECKO(5030) | [Child 5218, Main Thread] WARNING: '!mLocalStore', file /builds/worker/checkouts/gecko/dom/xul/XULPersist.cpp:146
[task 2023-05-08T20:46:43.510Z] 20:46:43     INFO - GECKO(5030) | [Child 5192: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 3 (7fb73dc37000) [pid = 5192] [serial = 3] [outer = 7fb742e63470]
[task 2023-05-08T20:46:44.678Z] 20:46:44     INFO - TEST-INFO | started process screentopng
[task 2023-05-08T20:46:45.181Z] 20:46:45     INFO - TEST-INFO | screentopng: exit 0
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - Buffered messages logged at 20:46:42
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - Entering test bound test_platform_decoder_not_found
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - Buffered messages logged at 20:46:43
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - Console message: [JavaScript Error: "Error: Can't find profile directory." {file: "resource://gre/modules/XULStore.sys.mjs" line: 60}]
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - load@resource://gre/modules/XULStore.sys.mjs:60:15
[task 2023-05-08T20:46:45.183Z] 20:46:45     INFO - XULStore@resource://gre/modules/XULStore.sys.mjs:17:10
[task 2023-05-08T20:46:45.184Z] 20:46:45     INFO - 
[task 2023-05-08T20:46:45.184Z] 20:46:45     INFO - Buffered messages logged at 20:46:44
[task 2023-05-08T20:46:45.184Z] 20:46:45     INFO - Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "https://example.org/" line: 0}]
[task 2023-05-08T20:46:45.184Z] 20:46:45     INFO - TEST-PASS | dom/media/doctor/test/browser/browser_decoderDoctor.js | Got decoder-doctor-notification notification - 
[task 2023-05-08T20:46:45.185Z] 20:46:45     INFO - Buffered messages finished
[task 2023-05-08T20:46:45.197Z] 20:46:45     INFO - TEST-UNEXPECTED-FAIL | dom/media/doctor/test/browser/browser_decoderDoctor.js | Uncaught exception in test bound test_platform_decoder_not_found - at chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:112 - TypeError: can't access property "textContent", link is null
[task 2023-05-08T20:46:45.197Z] 20:46:45     INFO - Stack trace:
[task 2023-05-08T20:46:45.197Z] 20:46:45     INFO - test_decoder_doctor_notification/create_tab_and_test/</<@chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:112:19
[task 2023-05-08T20:46:45.199Z] 20:46:45     INFO - waitForMutationCondition@resource://testing-common/BrowserTestUtils.sys.mjs:1622:9
[task 2023-05-08T20:46:45.199Z] 20:46:45     INFO - test_decoder_doctor_notification/create_tab_and_test/<@chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:109:34
[task 2023-05-08T20:46:45.199Z] 20:46:45     INFO - async*withNewTab@resource://testing-common/BrowserTestUtils.sys.mjs:150:22
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - async*create_tab_and_test@chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:30:28
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - test_decoder_doctor_notification@chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:177:9
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - test_platform_decoder_not_found@chrome://mochitests/content/browser/dom/media/doctor/test/browser/browser_decoderDoctor.js:232:9
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - handleTask@chrome://mochikit/content/browser-test.js:1133:26
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - _runTaskBasedTest@chrome://mochikit/content/browser-test.js:1205:18
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - Tester_execTest@chrome://mochikit/content/browser-test.js:1347:14
[task 2023-05-08T20:46:45.200Z] 20:46:45     INFO - nextTest/<@chrome://mochikit/content/browser-test.js:1122:14
[task 2023-05-08T20:46:45.201Z] 20:46:45     INFO - SimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1056:13
[task 2023-05-08T20:46:45.202Z] 20:46:45     INFO - Leaving test bound test_platform_decoder_not_found
[task 2023-05-08T20:46:45.202Z] 20:46:45     INFO - Entering test bound test_cannot_initialize_pulseaudio
[task 2023-05-08T20:46:45.203Z] 20:46:45     INFO - GECKO(5030) | [Child 5206: Main Thread]: I/DocShellAndDOMWindowLeak ++DOCSHELL 7f8e0da35000 == 1 [pid = 5206] [id = 0]
<...>
Flags: needinfo?(tgiles)
Flags: needinfo?(tgiles)
Pushed by tgiles@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bb4bcd3e8076
Add moz-support-link to notificationbox.js r=mstriemer,hjones
https://hg.mozilla.org/integration/autoland/rev/a546aa17f1ff
Fix regressions in decoderDoctor after adding moz-support-link to notificationbox. r=mstriemer,kinetik,media-playback-reviewers
https://hg.mozilla.org/integration/autoland/rev/7bb9f4ab002c
Add tests for appending buttons with label or l10n-id. r=mstriemer

Third time is the charm, I hope. Got Try to agree with me so hopefully the patches stick this time.

Flags: needinfo?(tgiles)
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Whiteboard: [fidefe-reusable-components-ms2] → [recomp]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: