The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
WebKit pages: Picture in Picture on, and none in WebKit's own fullscreen
Victor79ddb32d64b3
diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swiftindex 6710d89..866d617 100644--- a/Sources/Cra/Services/BrowserManager.swift+++ b/Sources/Cra/Services/BrowserManager.swift@@ -704,7 +704,10 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {for id in visibleTabIDs {guard let rt = runtimes[id] else { continue }if covered {- if rt.browser.isAudible { leaveTab(id) }+ // A WebKit page's own fullscreen window covers this one: that is the video on+ // screen, not out of sight. Asked then, WebKit's Picture in Picture got stuck in its+ // transition and never opened for that video again.+ if rt.browser.isAudible, !PageEngines.isInOwnFullscreen(rt.browser) { leaveTab(id) }} else if rt.autoPictureInPicture || rt.pendingAutoPictureInPicture {returnToTab(rt)}diff --git a/Sources/Cra/Services/WebKit/PageEngines.swift b/Sources/Cra/Services/WebKit/PageEngines.swiftindex be9e0d8..1e57dcb 100644--- a/Sources/Cra/Services/WebKit/PageEngines.swift+++ b/Sources/Cra/Services/WebKit/PageEngines.swift@@ -21,6 +21,10 @@ enum PageEngines {static func engine(of browser: CraBrowser) -> PageEngine { browser is WebKitBrowser ? .webKit : .chromium }+ /// The page is in WebKit's own fullscreen window, which covers Cra's (Chromium's fullscreen+ /// is Cra's window going fullscreen).+ static func isInOwnFullscreen(_ browser: CraBrowser) -> Bool { (browser as? WebKitBrowser)?.isContentFullscreen == true }+/// A page browser for `url` in the engine the rules pick. A popup host (`url` nil) takes its/// opener's engine: WebKit can only hand a popup to a web view it made, CEF to a CraBrowser.static func makeBrowser(frame: NSRect, url: String?, delegate: CraBrowserDelegate?, incognito: Bool,diff --git a/Sources/Cra/Services/WebKit/WebKitBrowser.swift b/Sources/Cra/Services/WebKit/WebKitBrowser.swiftindex 9361bba..523e092 100644--- a/Sources/Cra/Services/WebKit/WebKitBrowser.swift+++ b/Sources/Cra/Services/WebKit/WebKitBrowser.swift@@ -37,6 +37,8 @@ final class WebKitBrowser: CraBrowser, WKNavigationDelegate, WKUIDelegate, WKDowprivate var audible = falseprivate var audibleOff: DispatchWorkItem?private var capturing = false+ /// WebKit took the page to its own fullscreen window (Chromium's fullscreen is Cra's window).+ private(set) var isContentFullscreen = falseprivate var inPictureInPicture = falseprivate var pictureInPicturePlaying = falseprivate var hoverURL = ""@@ -173,6 +175,9 @@ final class WebKitBrowser: CraBrowser, WKNavigationDelegate, WKUIDelegate, WKDowweb.observe(\.microphoneCaptureState, options: [.new]) { [weak self] _, _ inMainActor.assumeIsolated { self?.reportCapture() }},+ web.observe(\.fullscreenState, options: [.new]) { [weak self] web, _ in+ MainActor.assumeIsolated { self?.isContentFullscreen = web.fullscreenState != .notInFullscreen }+ },]// WebKit's own "playing audio" (Safari's tab speaker), when this macOS has it; the// isolated world's media events stand in otherwise.diff --git a/Tests/BrowserManagerLifecycleTests.swift b/Tests/BrowserManagerLifecycleTests.swiftindex 32c4c52..6ff75c5 100644--- a/Tests/BrowserManagerLifecycleTests.swift+++ b/Tests/BrowserManagerLifecycleTests.swift@@ -191,6 +191,22 @@ enum BrowserManagerLifecycleTests {expect(manager.runtime(for: hidden.tabID)?.browser is WebKitBrowser && !manager.visibleTabIDs.contains(hidden.tabID),"a hidden tab is reopened in WebKit and stays hidden")+ // WebKit's own fullscreen window covers Cra's: the video is on screen, so no Picture in Picture.+ store.settings.autoPictureInPicture = true+ let player2 = store.createTab(url: "https://www.netflix.com/watch/1").id+ manager.show(player2, focus: false)+ let fullscreen = manager.runtime(for: player2)!.browser as! WebKitBrowser+ fullscreen.isAudible = true+ fullscreen.isContentFullscreen = true+ manager.windowVisibilityChanged(covered: true)+ expect(!fullscreen.replies.contains { $0.method == "Runtime.evaluate" }, "a WebKit page in its own fullscreen isn't sent to Picture in Picture")+ manager.windowVisibilityChanged(covered: false)+ fullscreen.isContentFullscreen = false+ manager.windowVisibilityChanged(covered: true)+ expect(fullscreen.replies.contains { $0.method == "Runtime.evaluate" }, "out of fullscreen, a covered window's playing WebKit page is asked as before")+ manager.windowVisibilityChanged(covered: false)+ store.settings.autoPictureInPicture = false+// A late request from a page that already moved changes nothing.expect(!manager.browser(chromium, handsOffNavigationToURL: "https://www.netflix.com/", method: "GET"), "a retired page can't move its tab again")manager.closeAll()diff --git a/Tests/BrowserManagerSupport/AppServices.swift b/Tests/BrowserManagerSupport/AppServices.swiftindex 4e9e76a..1a4266a 100644--- a/Tests/BrowserManagerSupport/AppServices.swift+++ b/Tests/BrowserManagerSupport/AppServices.swift@@ -91,4 +91,6 @@ final class PictureInPictureChrome {}/// The WebKit page (Sources/Cra/Services/WebKit/WebKitBrowser.swift): here only its type, which/// is what PageEngines and BrowserManager decide on.-final class WebKitBrowser: CraBrowser {}+final class WebKitBrowser: CraBrowser {+ var isContentFullscreen = false+}diff --git a/Tests/Fixtures/Pages/media.html b/Tests/Fixtures/Pages/media.htmlindex 407e48e..e59f52d 100644--- a/Tests/Fixtures/Pages/media.html+++ b/Tests/Fixtures/Pages/media.html@@ -5,7 +5,7 @@<!-- A looping H.264/AAC clip (clip.mp4: ffmpeg testsrc2 with a silent AAC track, 4 s; WebKit counts a playing, unmuted track as sound, and a scenario stays quiet) with mediasession handlers, for the sidebar player, Picture in Picture and tab sleep. Paused until ascenario plays it with a user gesture. The title says what the page last heard. -->-<video id="v" src="clip.mp4" loop playsinline></video>+<div id="player"><video id="v" src="clip.mp4" loop playsinline></video></div><p id="state">ready</p><script>const v = document.getElementById('v');diff --git a/Tests/Scenarios/webkit-drm-tabs.scenario b/Tests/Scenarios/webkit-drm-tabs.scenarioindex b5a77e9..aba3ead 100644--- a/Tests/Scenarios/webkit-drm-tabs.scenario+++ b/Tests/Scenarios/webkit-drm-tabs.scenario@@ -3,7 +3,7 @@# such a service, so the journey needs no network and no account. A Chromium page answers# 'userAgentData' in navigator with true, a WebKit page with false.# Covers: the engine a tab gets, the page's world kept apart from Cra's, the DevTools methods Cra-# calls, FairPlay, moving between engines both ways, split view with one page of each, the sidebar+# calls, FairPlay, cookies, popups with their opener, moving between engines both ways, split view with one page of each, the sidebar# player and its media session buttons, a Little Window, tab sleep and waking, closing the page.# No & in a script: it ends the cra:// query. The clip is silent and paused before its tab is left: nothing plays aloud or pops out in# Picture in Picture while it runs behind your windows.@@ -29,6 +29,25 @@ expect-log Cra cdp Page.getLayoutMetrics → .*cssContentSizecra://debug?cdp=Cra.discardexpect-log Cra cdp Cra.discard → error: Cra.discard is not available in a WebKit page+# Arc's Clear Cookies and Refresh empties the WebKit page's own cookies.+cra://debug?cdp=Runtime.evaluate¶ms={"expression":"document.cookie='cra=1; max-age=3600',document.cookie"}+expect-log Cra cdp Runtime.evaluate .*"value":"cra=1"+cra://debug?cdp=Storage.clearDataForOrigin¶ms={"origin":"${WEBKIT}","storageTypes":"cookies"}+expect-log Cra cdp Storage.clearDataForOrigin → \{\}+wait 1+cra://debug?cdp=Runtime.evaluate¶ms={"expression":"'cookies:'+document.cookie"}+expect-log Cra cdp Runtime.evaluate .*"value":"cookies:"++# window.open (a sign-in window) opens a tab that keeps its opener and is WebKit too; its own+# window.close() closes the tab.+cra://debug?cdp=Runtime.evaluate¶ms={"expression":"window.open('${WEBKIT}/page.html?n=popup')?'opened':'blocked'"}+expect-log Cra cdp Runtime.evaluate .*"value":"opened"+wait 2+cra://debug?cdp=Runtime.evaluate¶ms={"expression":"[document.title,!!window.opener,'userAgentData' in navigator].join()"}+expect-log Cra cdp Runtime.evaluate .*"value":"Fixture popup,true,false"+cra://debug?pageJS=window.close()+expect-log closed by its page+# A Chromium page's own navigation to the service moves to WebKit before its request goes out.cra://open?url=${PAGE}?n=linkexpect-log loaded 127\.0\.0\.1diff --git a/docs/protected-media.md b/docs/protected-media.mdindex b311a4d..28c1b5b 100644--- a/docs/protected-media.md+++ b/docs/protected-media.md@@ -86,9 +86,14 @@ services pick their DRM by browser.- **Chrome's DevTools**: Develop ▸ Developer Tools opens WebKit's Web Inspector in its own window.- **Arc's Picture in Picture window**: the video goes to the system's own Picture in Picturewindow, with its controls. Auto Picture in Picture, the sidebar player's button and coming- back to the tab work as for Chromium pages.+ back to the tab work as for Chromium pages. WebKit has Picture in Picture off for apps other+ than Safari until its `allowsPictureInPictureMediaPlayback` preference is set (without it,+ `requestPictureInPicture()` answers NotSupportedError).- **Chromium's fullscreen handling**: WebKit takes a fullscreen video to its own fullscreen- window, as in Safari.+ window, as in Safari, and Esc leaves it. That window covers Cra's, so the covered-window+ auto Picture in Picture leaves a WebKit page in its own fullscreen alone+ (`PageEngines.isInOwnFullscreen`): a request made then got stuck in WebKit's transition, and+ that video never went to Picture in Picture again.- **In-place tab sleep**: a sleeping WebKit page closes and loads its address again when shown.Its back/forward list goes with it.@@ -112,6 +117,13 @@ They are read at launch. A test instance takes `CRA_WEBKIT_DRM=0|1` andFairPlay being offered and every emulated protocol method. It also covers both handoffs, splitview with one engine per pane, the sidebar player and its media-session buttons, playbackwhile the tab is out of sight, a Little Window, tab sleep, waking and closing.-- By hand (L5), with real accounts: Spotify plays track after track, Netflix and Disney+ play,- Picture in Picture opens and returns, fullscreen enters and leaves, ⌘-shortcuts reach Cra, Peek- works, and sign-in through Google or Apple comes back signed in.+- On screen (4 Nov 2026, a renamed test copy): a WebKit tab and a split with one engine per+ pane drawn in their cards. Picture in Picture opens from the player's button, on leaving the+ tab, and after container and video fullscreen. Fullscreen enters and Esc leaves. ⌘F opens Cra's+ find bar with a count, and ⌘L opens the command bar with the page's address. In a background+ instance, EZDRM's public FairPlay stream played (licence, keys usable, 720p), and logged out,+ Spotify, Netflix, Disney+, Max, Apple TV, Apple Music, Prime Video and Tidal open in WebKit with+ no "browser not supported" message. Cookies and storage survive a relaunch, which restores the+ tab in WebKit. A download from a WebKit page lands in Downloads.+- Still by hand, with real accounts: Spotify plays track after track, Netflix and Disney+ play,+ and sign-in through Google or Apple comes back signed in. Peek from a pinned WebKit tab.