-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#682@minor: Adds support for HTMLIframeElement, MessageEvent and Wind…
…ow.postMessage().
- Loading branch information
1 parent
71b3286
commit 285f41c
Showing
18 changed files
with
752 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import IEventTarget from './IEventTarget'; | ||
|
||
/** | ||
* Message port. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessagePort | ||
*/ | ||
export default interface IMessagePort extends IEventTarget { | ||
/** | ||
* Sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts. | ||
* | ||
* @param type Event type. | ||
* @param listener Listener. | ||
*/ | ||
postMessage(message: unknown, transerList: unknown[]): void; | ||
|
||
/** | ||
* Starts the sending of messages queued on the port. | ||
*/ | ||
start(): void; | ||
|
||
/** | ||
* Disconnects the port, so it is no longer active. This stops the flow of messages to that port. | ||
*/ | ||
close(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import EventTarget from './EventTarget'; | ||
import IMessagePort from './IMessagePort'; | ||
|
||
/** | ||
* Message port. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessagePort | ||
*/ | ||
export default abstract class MessagePort extends EventTarget implements IMessagePort { | ||
/** | ||
* Sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts. | ||
* | ||
* @param _message Message. | ||
* @param _transerList Transfer list. | ||
*/ | ||
public postMessage(_message: unknown, _transerList: unknown[]): void { | ||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* Starts the sending of messages queued on the port. | ||
*/ | ||
public start(): void { | ||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* Disconnects the port, so it is no longer active. This stops the flow of messages to that port. | ||
*/ | ||
public close(): void { | ||
// TODO: Implement | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import IEventInit from '../IEventInit'; | ||
import IWindow from '../../window/IWindow'; | ||
import IMessagePort from '../IMessagePort'; | ||
|
||
export default interface IMessageEventInit extends IEventInit { | ||
data?: unknown | null; | ||
origin?: string; | ||
lastEventId?: string; | ||
source?: IWindow | null; | ||
ports?: IMessagePort[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import IWindow from '../../window/IWindow'; | ||
import Event from '../Event'; | ||
import IMessagePort from '../IMessagePort'; | ||
import IMessageEventInit from './IMessageEventInit'; | ||
|
||
/** | ||
* Message event. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent | ||
*/ | ||
export default class MessageEvent extends Event { | ||
public data?: unknown | null = null; | ||
public origin?: string = ''; | ||
public lastEventId?: string = ''; | ||
public source?: IWindow | null = null; | ||
public ports?: IMessagePort[] = []; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param type Event type. | ||
* @param [eventInit] Event init. | ||
*/ | ||
constructor(type: string, eventInit?: IMessageEventInit) { | ||
super(type, eventInit); | ||
this.data = eventInit?.data !== undefined ? eventInit.data : null; | ||
this.origin = eventInit?.origin || ''; | ||
this.lastEventId = eventInit?.lastEventId || ''; | ||
this.source = eventInit?.source || null; | ||
this.ports = eventInit?.ports || []; | ||
} | ||
} |
Oops, something went wrong.