electron/patches/chromium/feat_add_onclose_to_messageport.patch
electron-roller[bot] bbdd037219
chore: bump chromium to 117.0.5892.0 (main) (#39118)
* chore: bump chromium in DEPS to 117.0.5892.0

* 4670267: Don't send javascript: or empty URLs to browser in CreateNewWindow.

https://chromium-review.googlesource.com/c/chromium/src/+/4670267

* 4662090: Add metrics for WebGPU support

https://chromium-review.googlesource.com/c/chromium/src/+/4662090

* 4672599: Use set_defaults for mac_app_bundle

https://chromium-review.googlesource.com/c/chromium/src/+/4672599

* 4663771: usb: Add connection count tracking methods for UsbDelegate

https://chromium-review.googlesource.com/c/chromium/src/+/4663771

* 4664578: Remove unused parameter from ExtensionsGuestViewManagerDelegate ctor

https://chromium-review.googlesource.com/c/chromium/src/+/4664578

* 4622253: usb: Create classes for usb system tray icon

https://chromium-review.googlesource.com/c/chromium/src/+/4622253

* 4678263: Remove ARC support from scoped_nsobject

https://chromium-review.googlesource.com/c/chromium/src/+/4678263

* chore: follow-up ARC changes and missing guard corrections

* chore: don't mark 0-param ctor explicit

Follow up to https://chromium-review.googlesource.com/c/chromium/src/+/4664578

* chore: fixup patch indices

* 4670865: Merge ObjectProxy::CallMethodAndBlock{,WithErrorDetails}.

https://chromium-review.googlesource.com/c/chromium/src/+/4670865

* chore: follow-up ARC changes and missing guard corrections

* fixup: retain ElectronApplicationDelegate

* fix: correct rustc binary

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-07-19 00:26:27 +02:00

51 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Wed, 4 Mar 2020 11:18:03 -0800
Subject: feat: add onclose to MessagePort
This adds the 'onclose' event to MessagePort. This is
[proposed](https://github.com/w3ctag/design-reviews/issues/269#issuecomment-407584290)
in w3c and has been discussed for years without conclusion. I'd like to
get this standardised, but in lieu of that, this makes MessagePort a
whole bunch more useful!
diff --git a/third_party/blink/renderer/core/messaging/message_port.cc b/third_party/blink/renderer/core/messaging/message_port.cc
index 109ca611fedb6acce1142b2087ec3c4d6cbbfbf0..cf683459c3bb67df027d8b28cd471214b89fbda6 100644
--- a/third_party/blink/renderer/core/messaging/message_port.cc
+++ b/third_party/blink/renderer/core/messaging/message_port.cc
@@ -175,6 +175,7 @@ void MessagePort::close() {
Entangle(pipe.TakePort0());
}
closed_ = true;
+ DispatchEvent(*Event::Create(event_type_names::kClose));
}
void MessagePort::Entangle(MessagePortDescriptor port) {
diff --git a/third_party/blink/renderer/core/messaging/message_port.h b/third_party/blink/renderer/core/messaging/message_port.h
index 3055b625e7474f94aaddcf5500b4db07bd59a428..cc6b29749a9cf5ddd71aa4163078dce8989bd3bf 100644
--- a/third_party/blink/renderer/core/messaging/message_port.h
+++ b/third_party/blink/renderer/core/messaging/message_port.h
@@ -120,6 +120,13 @@ class CORE_EXPORT MessagePort : public EventTarget,
return GetAttributeEventListener(event_type_names::kMessageerror);
}
+ void setOnclose(EventListener* listener) {
+ SetAttributeEventListener(event_type_names::kClose, listener);
+ }
+ EventListener* onclose() {
+ return GetAttributeEventListener(event_type_names::kClose);
+ }
+
// A port starts out its life entangled, and remains entangled until it is
// closed or is cloned.
bool IsEntangled() const { return !closed_ && !IsNeutered(); }
diff --git a/third_party/blink/renderer/core/messaging/message_port.idl b/third_party/blink/renderer/core/messaging/message_port.idl
index 6fab27fcdf1c333739b6ffe88b3cc4eed3301ee4..3f1f181d9b8a66997136f870f55c97c08294b6eb 100644
--- a/third_party/blink/renderer/core/messaging/message_port.idl
+++ b/third_party/blink/renderer/core/messaging/message_port.idl
@@ -40,4 +40,5 @@
// event handlers
attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
+ attribute EventHandler onclose;
};