Closed Bug 1774083 Opened 2 years ago Closed 2 years ago

Add Surrogate COM Server to handle native Windows notifications when Firefox is closed.

Categories

(Toolkit Graveyard :: Notifications and Alerts, enhancement, P3)

Unspecified
Windows
enhancement

Tracking

(firefox105 fixed)

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: nrishel, Assigned: nrishel)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [fidedi-notifications] )

Attachments

(5 files, 3 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

A COM server is necessary to receive notification activation events when Firefox has been closed.

A running instance of Firefox may not be the appropriate receiver of a notification which may be tied to a different profile. For this reason we need to route notification data.

The way to achieve this with the smallest code footprint is with a Surrogate COM Server, which allows us to implement a simple COM DLL instead of an executable (therefore allowing us to forego message loop handling).

Note: this is just a placeholder hack, will update this patch with a proper fix before landing.

Depends on D149180

Must be used with a COM Surrogate, only handles receiving the activation and immediately returning; in-memory handlers in the originating process will be triggered if they still exist automatically. r=nalexander

Depends on D149181

Attachment #9281099 - Attachment description: WIP: Bug 1774083 - Minimal COM server DLL for notification handling. → Bug 1774083 - Minimal COM server DLL for notification handling. r=nalexander
Status: NEW → ASSIGNED
Whiteboard: [fidedi-notifications]
Attachment #9281099 - Attachment description: Bug 1774083 - Minimal COM server DLL for notification handling. r=nalexander → Bug 1774083 - Part 1: Add notificationnecromancer.dll COM Server to handle Window's toast notifications. r=nalexander,Jamie

Adds program and profile paths to Windows toast notifications so that the COM server can reconstruct the origin in order to relaunch the application.

Depends on D149182

Adds a GUID to the notification's launch attribute too verify a timeout dismissed event doesn't remain in the Action Center.

Remove event hiding to allow notifications to be acted upon after the page or browser is closed.

Depends on D151740

Attachment #9281099 - Attachment description: Bug 1774083 - Part 1: Add notificationnecromancer.dll COM Server to handle Window's toast notifications. r=nalexander,Jamie → Bug 1774083 - Part 1: Add notificationserver.dll COM Server to handle Window's toast notifications. r=nalexander,Jamie
Attachment #9285346 - Attachment description: Bug 1774083 - Post 1: Manage Windows toast notifcation HSTRING handles lifetime with HString and HStringReference wrappers. r=nalexander → Bug 1774083 - Pre 1: Manage Windows toast notifcation HSTRING handles lifetime with HString and HStringReference wrappers. r=nalexander
Attachment #9285347 - Attachment description: Bug 1774083 - Post 2: Condense litany of Windows toast notification error cases with NS_ENSURE_* macros. r=nalexander. → Bug 1774083 - Pre 2: Condense litany of Windows toast notification error cases with NS_ENSURE_* macros. r=nalexander.

Windows toast actions (buttons) override the launch argument. The launch arguments are necessary for the notification server to reconstruct the source of the toast, therefore we prepend it to the action argument.

Depends on D151741

Attachment #9286540 - Attachment description: WIP: Bug 1774083 - Part 4: Prepend Windows toast launch arguments to the toast action arguments. → Bug 1774083 - Part 4: Prepend Windows toast launch arguments to the toast action arguments. r=nalexander

Comment on attachment 9285346 [details]
Bug 1774083 - Pre 1: Manage Windows toast notifcation HSTRING handles lifetime with HString and HStringReference wrappers. r=nalexander

Revision D151742 was moved to bug 1780666. Setting attachment 9285346 [details] to obsolete.

Attachment #9285346 - Attachment is obsolete: true

Comment on attachment 9285347 [details]
Bug 1774083 - Pre 2: Condense litany of Windows toast notification error cases with NS_ENSURE_* macros. r=nalexander.

Revision D151743 was moved to bug 1780666. Setting attachment 9285347 [details] to obsolete.

Attachment #9285347 - Attachment is obsolete: true
Attachment #9281097 - Attachment is obsolete: true
Pushed by nrishel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/54beca69e971
Part 1: Add notificationserver.dll COM Server to handle Window's toast notifications. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/173c4519227f
Part 2: Launch Firefox from notification COM server when activation event occurs. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/ad20680728cc
Part 3: Allow Windows notifications to persist after dismissed by timeout. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/4056bc743e25
Part 4: Prepend Windows toast launch arguments to the toast action arguments. r=nalexander

Backed out for causing xpcshell failures.

Push with failures

Failure log

Backout link

[task 2022-08-01T22:20:44.086Z] 22:20:44     INFO -  testUnicodeInAssertMethods (__main__.XPCShellTests.runSelfTest.<locals>.XPCShellTestsTests) ... FAIL
[task 2022-08-01T22:20:44.086Z] 22:20:44     INFO -  ======================================================================
[task 2022-08-01T22:20:44.086Z] 22:20:44     INFO -  FAIL: testAddTaskSkip (__main__.XPCShellTests.runSelfTest.<locals>.XPCShellTestsTests)
[task 2022-08-01T22:20:44.087Z] 22:20:44     INFO -  ----------------------------------------------------------------------
[task 2022-08-01T22:20:44.087Z] 22:20:44     INFO -  Traceback (most recent call last):
[task 2022-08-01T22:20:44.087Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 1134, in testAddTaskSkip
[task 2022-08-01T22:20:44.088Z] 22:20:44     INFO -      self.assertTestResult(True)
[task 2022-08-01T22:20:44.088Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 555, in assertTestResult
[task 2022-08-01T22:20:44.088Z] 22:20:44     INFO -      % ("passed" if expected else "failed", self.log.getvalue()),
[task 2022-08-01T22:20:44.089Z] 22:20:44     INFO -  AssertionError: True != False : Tests should have passed, log:
[task 2022-08-01T22:20:44.089Z] 22:20:44     INFO -  ========
[task 2022-08-01T22:20:44.089Z] 22:20:44     INFO -  Found node at Z:/task_1659391378/fetches\node/node.exe
[task 2022-08-01T22:20:44.089Z] 22:20:44     INFO -  Found moz-http2 at Z:\task_1659391378\build\tests\xpcshell\moz-http2\moz-http2.js
[task 2022-08-01T22:20:44.090Z] 22:20:44     INFO -  Found Z:\task_1659391378\build\tests\xpcshell\http3server\http3server.exe
[task 2022-08-01T22:20:44.090Z] 22:20:44     INFO -  Using Z:\task_1659391378\build\tests\xpcshell\http3server\http3serverDB
[task 2022-08-01T22:20:44.090Z] 22:20:44     INFO -  Running tests sequentially.
[task 2022-08-01T22:20:44.091Z] 22:20:44     INFO -  SUITE-START | Running 1 tests
[task 2022-08-01T22:20:44.091Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.091Z] 22:20:44     INFO -  TEST-START | test_tasks_skip.js
[task 2022-08-01T22:20:44.092Z] 22:20:44     INFO -  TEST-FAIL | test_tasks_skip.js | took 31ms
[task 2022-08-01T22:20:44.092Z] 22:20:44     INFO -  test_tasks_skip.js failed or timed out, will retry.
[task 2022-08-01T22:20:44.092Z] 22:20:44     INFO -  Retrying tests that failed when run in parallel.
[task 2022-08-01T22:20:44.092Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.093Z] 22:20:44     INFO -  TEST-START | test_tasks_skip.js
[task 2022-08-01T22:20:44.093Z] 22:20:44  WARNING -  TEST-UNEXPECTED-FAIL | test_tasks_skip.js | xpcshell return code: 3228369022
[task 2022-08-01T22:20:44.093Z] 22:20:44     INFO -  TEST-INFO took 28ms
[task 2022-08-01T22:20:44.094Z] 22:20:44     INFO -  INFO | Result summary:
[task 2022-08-01T22:20:44.094Z] 22:20:44     INFO -  INFO | Passed: 0
[task 2022-08-01T22:20:44.094Z] 22:20:44  WARNING -  INFO | Failed: 1
[task 2022-08-01T22:20:44.094Z] 22:20:44  WARNING -  One or more unittests failed.
[task 2022-08-01T22:20:44.094Z] 22:20:44     INFO -  INFO | Todo: 0
[task 2022-08-01T22:20:44.095Z] 22:20:44     INFO -  INFO | Retried: 1
[task 2022-08-01T22:20:44.095Z] 22:20:44     INFO -  SUITE-END | took 0s
[task 2022-08-01T22:20:44.095Z] 22:20:44     INFO -  Node moz-http2 server shutting down ...
[task 2022-08-01T22:20:44.096Z] 22:20:44     INFO -  http3Server server shutting down ...
[task 2022-08-01T22:20:44.096Z] 22:20:44     INFO -  ========
[task 2022-08-01T22:20:44.096Z] 22:20:44     INFO -  ======================================================================
[task 2022-08-01T22:20:44.097Z] 22:20:44     INFO -  FAIL: testAddTaskSkipAll (__main__.XPCShellTests.runSelfTest.<locals>.XPCShellTestsTests)
[task 2022-08-01T22:20:44.097Z] 22:20:44     INFO -  ----------------------------------------------------------------------
[task 2022-08-01T22:20:44.097Z] 22:20:44     INFO -  Traceback (most recent call last):
[task 2022-08-01T22:20:44.097Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 1143, in testAddTaskSkipAll
[task 2022-08-01T22:20:44.098Z] 22:20:44     INFO -      self.assertTestResult(True)
[task 2022-08-01T22:20:44.098Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 555, in assertTestResult
[task 2022-08-01T22:20:44.098Z] 22:20:44     INFO -      % ("passed" if expected else "failed", self.log.getvalue()),
[task 2022-08-01T22:20:44.099Z] 22:20:44     INFO -  AssertionError: True != False : Tests should have passed, log:
[task 2022-08-01T22:20:44.099Z] 22:20:44     INFO -  ========
[task 2022-08-01T22:20:44.099Z] 22:20:44     INFO -  Found node at Z:/task_1659391378/fetches\node/node.exe
[task 2022-08-01T22:20:44.100Z] 22:20:44     INFO -  Found moz-http2 at Z:\task_1659391378\build\tests\xpcshell\moz-http2\moz-http2.js
[task 2022-08-01T22:20:44.100Z] 22:20:44     INFO -  Found Z:\task_1659391378\build\tests\xpcshell\http3server\http3server.exe
[task 2022-08-01T22:20:44.100Z] 22:20:44     INFO -  Using Z:\task_1659391378\build\tests\xpcshell\http3server\http3serverDB
[task 2022-08-01T22:20:44.100Z] 22:20:44     INFO -  Running tests sequentially.
[task 2022-08-01T22:20:44.101Z] 22:20:44     INFO -  SUITE-START | Running 1 tests
[task 2022-08-01T22:20:44.101Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.101Z] 22:20:44     INFO -  TEST-START | test_tasks_skipall.js
[task 2022-08-01T22:20:44.102Z] 22:20:44     INFO -  TEST-FAIL | test_tasks_skipall.js | took 31ms
[task 2022-08-01T22:20:44.102Z] 22:20:44     INFO -  test_tasks_skipall.js failed or timed out, will retry.
[task 2022-08-01T22:20:44.102Z] 22:20:44     INFO -  Retrying tests that failed when run in parallel.
[task 2022-08-01T22:20:44.103Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.103Z] 22:20:44     INFO -  TEST-START | test_tasks_skipall.js
[task 2022-08-01T22:20:44.103Z] 22:20:44  WARNING -  TEST-UNEXPECTED-FAIL | test_tasks_skipall.js | xpcshell return code: 3228369022
[task 2022-08-01T22:20:44.103Z] 22:20:44     INFO -  TEST-INFO took 28ms
[task 2022-08-01T22:20:44.104Z] 22:20:44     INFO -  INFO | Result summary:
[task 2022-08-01T22:20:44.104Z] 22:20:44     INFO -  INFO | Passed: 0
[task 2022-08-01T22:20:44.104Z] 22:20:44  WARNING -  INFO | Failed: 1
[task 2022-08-01T22:20:44.104Z] 22:20:44  WARNING -  One or more unittests failed.
[task 2022-08-01T22:20:44.104Z] 22:20:44     INFO -  INFO | Todo: 0
[task 2022-08-01T22:20:44.105Z] 22:20:44     INFO -  INFO | Retried: 1
[task 2022-08-01T22:20:44.105Z] 22:20:44     INFO -  SUITE-END | took 0s
[task 2022-08-01T22:20:44.105Z] 22:20:44     INFO -  Node moz-http2 server shutting down ...
[task 2022-08-01T22:20:44.106Z] 22:20:44     INFO -  http3Server server shutting down ...
[task 2022-08-01T22:20:44.106Z] 22:20:44     INFO -  ========
[task 2022-08-01T22:20:44.106Z] 22:20:44     INFO -  ======================================================================
[task 2022-08-01T22:20:44.107Z] 22:20:44     INFO -  FAIL: testAddTaskStackTrace (__main__.XPCShellTests.runSelfTest.<locals>.XPCShellTestsTests)
[task 2022-08-01T22:20:44.107Z] 22:20:44     INFO -  ----------------------------------------------------------------------
[task 2022-08-01T22:20:44.107Z] 22:20:44     INFO -  Traceback (most recent call last):
[task 2022-08-01T22:20:44.108Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 1125, in testAddTaskStackTrace
[task 2022-08-01T22:20:44.108Z] 22:20:44     INFO -      self.assertInLog("this_test_will_fail")
[task 2022-08-01T22:20:44.108Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 574, in assertInLog
[task 2022-08-01T22:20:44.108Z] 22:20:44     INFO -      self._assertLog(s, True)
[task 2022-08-01T22:20:44.109Z] 22:20:44     INFO -    File "Z:\task_1659391378\build\tests\xpcshell\selftest.py", line 567, in _assertLog
[task 2022-08-01T22:20:44.109Z] 22:20:44     INFO -      % (s, "expected" if expected else "not expected", l),
[task 2022-08-01T22:20:44.109Z] 22:20:44     INFO -  AssertionError: True != False : Value this_test_will_fail expected in log:
[task 2022-08-01T22:20:44.110Z] 22:20:44     INFO -  ========
[task 2022-08-01T22:20:44.110Z] 22:20:44     INFO -  Found node at Z:/task_1659391378/fetches\node/node.exe
[task 2022-08-01T22:20:44.110Z] 22:20:44     INFO -  Found moz-http2 at Z:\task_1659391378\build\tests\xpcshell\moz-http2\moz-http2.js
[task 2022-08-01T22:20:44.111Z] 22:20:44     INFO -  Found Z:\task_1659391378\build\tests\xpcshell\http3server\http3server.exe
[task 2022-08-01T22:20:44.111Z] 22:20:44     INFO -  Using Z:\task_1659391378\build\tests\xpcshell\http3server\http3serverDB
[task 2022-08-01T22:20:44.111Z] 22:20:44     INFO -  Running tests sequentially.
[task 2022-08-01T22:20:44.112Z] 22:20:44     INFO -  SUITE-START | Running 1 tests
[task 2022-08-01T22:20:44.112Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.112Z] 22:20:44     INFO -  TEST-START | test_add_task_stack_trace.js
[task 2022-08-01T22:20:44.113Z] 22:20:44     INFO -  TEST-FAIL | test_add_task_stack_trace.js | took 31ms
[task 2022-08-01T22:20:44.113Z] 22:20:44     INFO -  test_add_task_stack_trace.js failed or timed out, will retry.
[task 2022-08-01T22:20:44.113Z] 22:20:44     INFO -  Retrying tests that failed when run in parallel.
[task 2022-08-01T22:20:44.114Z] 22:20:44     INFO -  profile dir is C:\Users\task_1659391378\AppData\Local\Temp\xpcshell\xpcshellprofile
[task 2022-08-01T22:20:44.114Z] 22:20:44     INFO -  TEST-START | test_add_task_stack_trace.js
[task 2022-08-01T22:20:44.114Z] 22:20:44  WARNING -  TEST-UNEXPECTED-FAIL | test_add_task_stack_trace.js | xpcshell return code: 3228369022
[task 2022-08-01T22:20:44.114Z] 22:20:44     INFO -  TEST-INFO took 29ms
[task 2022-08-01T22:20:44.115Z] 22:20:44     INFO -  INFO | Result summary:
[task 2022-08-01T22:20:44.115Z] 22:20:44     INFO -  INFO | Passed: 0
[task 2022-08-01T22:20:44.115Z] 22:20:44  WARNING -  INFO | Failed: 1
[task 2022-08-01T22:20:44.115Z] 22:20:44  WARNING -  One or more unittests failed.
[task 2022-08-01T22:20:44.115Z] 22:20:44     INFO -  INFO | Todo: 0
[task 2022-08-01T22:20:44.116Z] 22:20:44     INFO -  INFO | Retried: 1
[task 2022-08-01T22:20:44.116Z] 22:20:44     INFO -  SUITE-END | took 0s
Flags: needinfo?(nrishel)
Pushed by nrishel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/45b34479eb01
Part 1: Add notificationserver.dll COM Server to handle Window's toast notifications. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/dae9d6b79432
Part 2: Launch Firefox from notification COM server when activation event occurs. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/576e45fb4e37
Part 3: Allow Windows notifications to persist after dismissed by timeout. r=nalexander
https://hg.mozilla.org/integration/autoland/rev/34ddab3fee46
Part 4: Prepend Windows toast launch arguments to the toast action arguments. r=nalexander

xpcshell failures were due to using Windows 8+ APIs; fixed by loading them dynamically.

Flags: needinfo?(nrishel)
Regressions: 1782837

Your test now only works on Firefox, and fails on Thunderbird, because you wired in the word "firefox". I'll post a patch to fix it.

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/integration/autoland/rev/2bc22187f185
follow-up - Fix test_windows_alert_service.js on Thunderbird. r=nrishel,nalexander
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: