Skip to content

Commit fb1e9c5

Browse files
authored
Merge pull request #42 from zphrs/webrtc-uninit
added WebRTC Test based on an uninitialized iFrame
2 parents c8e30f4 + 53ac850 commit fb1e9c5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<script src="js/media-access.js"></script>
9090

9191
<iframe id="iframe-regular" style="display: none"></iframe>
92+
<div id="iframe-container" style="display: none"></div>
9293
<iframe
9394
id="iframe-allow-same-origin"
9495
sandbox="allow-same-origin"

js/webrtc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ window.addEventListener("load", () => {
9898
/** @type {HTMLIFrameElement} */
9999
const iframeAllowSameOrigin = document.getElementById('iframe-allow-same-origin');
100100
const iframeAllowSameOriginWindow = iframeAllowSameOrigin?.contentWindow;
101+
// This test is specifically designed to get the RTCPeerConnection object
102+
// before the injected script on android is run.
103+
// The script injected into Android's WebView from Tauri
104+
// only runs once the page is loaded, compared to other targets
105+
// where the injected script is run immediately
106+
// after the iframe is constructed, before yeilding back to the JS
107+
// on the parent page which created the iframe.
108+
const iframeContainer = document.getElementById("iframe-container");
109+
/** @type {Window | undefined} */
110+
let iframeNotInitedWindow
111+
if (iframeContainer) {
112+
iframeContainer.innerHTML += "<iframe id=uninitiframe></iframe>"
113+
iframeNotInitedWindow = uninitiframe.contentWindow;
114+
}
101115
const tests = [
102116
["RTCPeerConnection", window.RTCPeerConnection],
103117
["mozRTCPeerConnection", window.mozRTCPeerConnection],
@@ -108,6 +122,9 @@ window.addEventListener("load", () => {
108122
["iframe regular RTCPeerConnection", iframeRegularWindow?.RTCPeerConnection],
109123
["iframe regular mozRTCPeerConnection", iframeRegularWindow?.mozRTCPeerConnection],
110124
["iframe regular webkitRTCPeerConnection", iframeRegularWindow?.webkitRTCPeerConnection],
125+
["iframe regular uninitialized RTCPeerConnection", iframeNotInitedWindow?.RTCPeerConnection],
126+
["iframe regular uninitialized mozRTCPeerConnection", iframeNotInitedWindow?.mozRTCPeerConnection],
127+
["iframe regular uninitialized webkitRTCPeerConnection", iframeNotInitedWindow?.webkitRTCPeerConnection],
111128
];
112129
const elements = [];
113130
const testPromises = [];

0 commit comments

Comments
 (0)