Skip to content

A page's permission question is lost when a second one comes, and one for the camera or microphone stays after the page is gone #255

Done

Description

@manhpham90vn

A tab keeps one permission question, in permission (Sources/AgentTermMac/Browser.swift:480-485): a new ATC_EVENT_PERMISSION replaces the one shown. And a question for media (camera, microphone) is kept by the CEF layer with a prompt id of 0 (atc_keep_prompt(callback, 1, permissions, 0), Sources/CAgentTermCEF/AgentTermCEF.m:655-664), while on_dismiss_permission_prompt (AgentTermCEF.m:641-653) takes away only those whose kind is 0 and whose id matches: a media question is never dismissed by Chromium's telling.

Scenarios.

  • A page asks for notifications and then for the camera. The second replaces the first in the tab's bar; the first can no longer be answered, and its callback is kept for as long as the app runs.
  • A page asks for the camera, then goes to another page or its tab is closed. The bar "… wants your camera" stays over the next page, and Allow then answers the earlier page's callback.

Also, g_prompt_kinds and g_prompt_asked are not cleared when a prompt is dismissed (a small leak). No permission is given by itself anywhere: only the user's buttons answer.

Found by reading the code in the review of 2026-11-22, at commit 968516d; not reproduced yet. The single slot and the dismiss's condition were confirmed by a second reading. Not known: what CEF does with a kept media callback answered after its page navigated (ignored, or granted to the new page's origin); to be tried (principle 5).

A way to fix it, not decided: a tab keeps its questions in a queue and shows them one after the other; a tab's kept media questions are cancelled when its main frame goes to another page and when it closes.

  • Reproduced: tried with the real Chromium (a page that asks for notifications then the camera; a page that asks for the camera then navigates); a test that fails because of it, seen failing
  • Fixed at its root, the test passing, the layers of rule 2 run, committed, CI green

Definition of done

  1. Tried first with the real Chromium of the build: the two scenarios, and what answering a media question after a navigation does; written here with the CEF version.
  2. A test that fails because of it is seen failing, then passes and stays: two questions of one tab are both answerable, in the order asked, each with its own origin and kind in the bar.
  3. A question is gone, and its callback released as cancelled, when the page that asked navigates its main frame, when its tab closes, and when Chromium dismisses it; Allow never answers a question of a page that is no longer shown.
  4. Nothing is ever granted without the user's button, as now; what is kept for a prompt is cleared when it ends.
  5. A case in docs/TESTING.md (BROWSER-…) names the test.
  6. swift build, swift test, scripts/test-mac.sh pass; pictures of the bar with two questions waiting, and of the next page after a navigation without the bar, are looked at.
  7. make format and make lint, committed on the milestone's branch and pushed, CI on the branch green.

Tiếng Việt

Đây là bản dịch của phần tiếng Anh ở trên; các ô đánh dấu chỉ có ở phần tiếng Anh.

Một tab chỉ giữ một câu hỏi cấp quyền, trong permission (Sources/AgentTermMac/Browser.swift:480-485): một ATC_EVENT_PERMISSION mới thay thế câu đang hiện. Và câu hỏi về media (camera, micro) được tầng CEF giữ với prompt id bằng 0 (atc_keep_prompt(callback, 1, permissions, 0), Sources/CAgentTermCEF/AgentTermCEF.m:655-664), trong khi on_dismiss_permission_prompt (AgentTermCEF.m:641-653) chỉ gỡ những câu có kind bằng 0 và id khớp: câu hỏi media không bao giờ được gỡ khi Chromium báo.

Kịch bản.

  • Một trang xin quyền thông báo rồi xin camera. Câu thứ hai thay câu thứ nhất trên thanh của tab; câu thứ nhất không còn trả lời được, và callback của nó bị giữ suốt thời gian app chạy.
  • Một trang xin camera, rồi chuyển sang trang khác hoặc tab bị đóng. Thanh "… wants your camera" vẫn nằm trên trang kế tiếp, và Allow khi đó trả lời callback của trang trước.

Ngoài ra, g_prompt_kinds và g_prompt_asked không được xoá khi prompt bị gỡ (rò rỉ nhỏ). Không quyền nào được tự cấp ở đâu cả: chỉ các nút của user mới trả lời.

Tìm thấy khi đọc code trong đợt rà soát 2026-11-22, tại commit 968516d; chưa tái hiện. Việc chỉ có một chỗ chứa và điều kiện của hàm dismiss đã được xác nhận bằng lần đọc thứ hai. Chưa biết: CEF làm gì với một callback media còn giữ được trả lời sau khi trang của nó đã chuyển đi (bỏ qua, hay cấp cho origin của trang mới); cần thử (nguyên tắc 5).

Một cách sửa, chưa quyết: tab giữ các câu hỏi trong một hàng đợi và hiện lần lượt; các câu hỏi media còn giữ của tab bị huỷ khi main frame chuyển sang trang khác và khi tab đóng.

  • Tái hiện: thử với Chromium thật (một trang xin thông báo rồi camera; một trang xin camera rồi chuyển trang); một test fail vì lỗi này, đã thấy fail
  • Sửa tận gốc, test pass, chạy các tầng của rule 2, commit, CI xanh

Định nghĩa hoàn thành

  1. Thử trước với Chromium thật của bản build: hai kịch bản trên, và việc trả lời một câu hỏi media sau khi chuyển trang thì ra sao; ghi vào đây kèm phiên bản CEF.
  2. Một test fail vì lỗi này được thấy fail, rồi pass và được giữ lại: hai câu hỏi của một tab đều trả lời được, theo thứ tự được hỏi, mỗi câu có origin và loại riêng trên thanh.
  3. Một câu hỏi biến mất, và callback của nó được giải phóng dưới dạng đã huỷ, khi trang đã hỏi chuyển main frame, khi tab đóng, và khi Chromium gỡ nó; Allow không bao giờ trả lời câu hỏi của một trang không còn được hiển thị.
  4. Không gì được cấp mà không có nút bấm của user, như hiện nay; những gì được giữ cho một prompt được xoá khi nó kết thúc.
  5. Một case trong docs/TESTING.md (BROWSER-…) gọi tên test.
  6. swift build, swift test, scripts/test-mac.sh pass; xem ảnh chụp thanh với hai câu hỏi đang chờ, và trang kế tiếp sau khi chuyển trang không còn thanh đó.
  7. make format và make lint, commit trên nhánh của milestone và push, CI trên nhánh xanh.

Activity

  1. added this to the 0.15.1 milestone on Nov 22, 2026
  2. added
    bug
    on Nov 22, 2026
  3. manhpham90vn commented on Nov 23, 2026

    @manhpham90vn
    CollaboratorAuthor

    Tried with CEF 156.0.30, BROWSER-61 (testAPagesPermissionQuestionsWaitTheirTurn): a page asks for its location, then to send notifications 0.8 s later. Chromium itself asks the second only once the first is answered: with the single slot put back, the test passed too. That part is not reproduced at this version.

    Changed in 38d0693 all the same: a tab keeps its questions in turn, and a camera's or microphone's question of a page that goes to another page or closes is refused and leaves the bar; g_prompt_kinds and g_prompt_asked are cleared on a dismissal. The microphone's case could not be tried: getUserMedia in the test build waits on macOS's own question for the microphone, which is the user's to answer, and no bar comes.

    Run on milestone-0.15.1, 2026-11-23, commit 38d0693: swift build, swift test passing; scripts/test-ios.sh "iPhone Air" passing; scripts/test-mac.sh in full, one failure, the new BROWSER-63 (it opened DevTools from the menu bar, which acts on the focused tab; it now uses the tab's own menu, and passed with both windows); BrowserUITests again, 61 passing and one failure of testNoPageProcessIsLeftWithTheLastPageClosed, which passed 5 times in 5 alone (said in #323); make lint; CI on the branch green (run 45138832250).

    Left: the camera's or microphone's question after its page went, tried with a build macOS has been given the microphone for. Stays open.

  4. manhpham90vn commented on Nov 25, 2026

    @manhpham90vn
    CollaboratorAuthor

    Closed at the owner's word (2026-11-25): the automated tests are enough for 0.15.1.

    Done: questions kept in turn and a page's media question refused when it navigates (38d0693); a pending media question cancelled when its tab closes (4dfe99e, PR #331, BrowserUITests), with BROWSER-61 and its focused Mac UI test passing; CI on PR #331 green.

    Not done: a whole scripts/test-mac.sh run after 4dfe99e, and the pictures of item 6 looked at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions