Bug 259594

Summary: Web Automation: Parse WebAutomationSessionProxy as a built-in to get guaranteed non-user-overridden JSC built-ins
Product: WebKit Reporter: Sam Sneddon [:gsnedders] <gsnedders>
Component: WebDriverAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bburg, cgarcia, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Sam Sneddon [:gsnedders] 2023-07-28 07:15:35 PDT
rdar://110740489

See also bug 152294 which did similar for the Web Inspector injected script.

Something like this will fail each test:

@pytest.mark.parametrize("expression", [
    ("Promise.prototype.finally"),
    ("Promise.race"),
    ("window.Promise"),
    ("JSON.stringify"),
])
def test_callback(session, expression):
    session.url = "about:blank"
    response = execute_async_script(session, f"""
        let callback = arguments[0];
        delete {expression};
        callback('foobar');
        """)
    assert_success(response, "foobar")

Bug 204151 practically made this worse by introducing all the references to Promises on the common-path, and it's this case (and specifically with Promise.prototype.finally deleted) which was reported as rdar://110740489.