(cdp, label, timeout = 5000)
| 862 | debug?.rawTrack?.readyState === "live" || |
| 863 | debug?.localStream?.videoTracks?.some?.((track) => track.readyState === "live") || |
| 864 | false; |
| 865 | const liveVideoFromElement = Array.from(document.querySelectorAll("video")).some((video) => { |
| 866 | const stream = video.srcObject; |
| 867 | const tracks = stream && typeof stream.getVideoTracks === "function" |
| 868 | ? stream.getVideoTracks() |
| 869 | : []; |
| 870 | return tracks.some((track) => track.readyState === "live"); |
| 871 | }); |
| 872 | const alreadyOn = |
| 873 | debug?.isCameraOff === false && (liveVideoFromDebug || liveVideoFromElement); |
| 874 | const turnOnButton = Array.from(document.querySelectorAll("button")).find( |
| 875 | (candidate) => |
| 876 | candidate.getAttribute("aria-label") === "Turn on camera" || |
| 877 | (candidate.textContent || "").includes("Turn on camera") |
| 878 | ); |
| 879 | const turnOnReady = Boolean(turnOnButton && !turnOnButton.disabled); |
| 880 | if (!alreadyOn && !turnOnReady) return false; |
| 881 | return { |
| 882 | alreadyOn, |
| 883 | turnOnReady, |
| 884 | connectionState: debug?.connectionState ?? null, |
| 885 | isCameraOff: debug?.isCameraOff ?? null, |
| 886 | liveVideoFromDebug, |
| 887 | liveVideoFromElement, |
| 888 | }; |
| 889 | })()`, |
| 890 | 30000, |
| 891 | ); |
| 892 | emit("turn_camera_on_if_needed_state", { label, cameraState }); |
| 893 | if (cameraState.alreadyOn) return; |
| 894 | |
| 895 | await clickButton(cdp, "Turn on camera", 10000); |
no test coverage detected