Skip to content
  • jberlin@webkit.org's avatar
    Expose a way to know when forms are added to a page or when form controls are added to a form · f13d0a3d
    jberlin@webkit.org authored
    in the injected bundle
    https://bugs.webkit.org/show_bug.cgi?id=116334
    
    Reviewed by Alexey Proskuryakov.
    
    Source/WebKit2:
    
    Add shouldNotifyOnFormChanges and didAssociateFormControls to the WKBundlePageFormClient.
    
    * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
    Add the new callbacks as part of version 2 of the WKBundlePageFormClient.
    
    * WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
    (WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
    Pass the message along to the client if the client has a handler.
    (WebKit::InjectedBundlePageFormClient::shouldNotifyOnFormChanges):
    Ditto.
    * WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
    
    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::didAssociateFormControls):
    Tell the injected bundle form client for the page.
    (WebKit::WebChromeClient::shouldNotifyOnFormChanges):
    Ditto.
    * WebProcess/WebCoreSupport/WebChromeClient.h:
    
    Tools:
    
    Add tests for the new callbacks.
    
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    Add DidAssociateFormControls/_Bundle.cpp and associate-form-controls.html
    
    * TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls.cpp: Added.
    (TestWebKitAPI::nullJavaScriptCallback):
    A "null" callback to handle the fact that WKPageRunJavaScriptInMainFrame cannot handle null
    being passed in for the callback.
    (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
    After receiving the message that didAssociateFormControls callback was invoked from adding
    the form in the onload handler, tell the page to add a password field to the form, which
    should also invoke didAssociateFormControls callback.
    (TestWebKitAPI::setInjectedBundleClient):
    Register to receive messages.
    (TestWebKitAPI::TEST):
    Load associate-form-controls.html and wait until the didAssociateFormControls callback has
    been invoked for both adding the form and for adding a password field to the form.
    
    * TestWebKitAPI/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp: Added.
    (TestWebKitAPI::shouldNotifyOnFormChanges):
    Return true so the didAssociateFormControls callback is invoked.
    (TestWebKitAPI::didAssociateFormControls):
    Tell the UI process.
    (TestWebKitAPI::DidAssociateFormControlsTest::DidAssociateFormControlsTest):
    (TestWebKitAPI::DidAssociateFormControlsTest::didCreatePage):
    Register for the shouldNotifyOnFormChanges and didAssociateFormControls callbacks.
    
    * TestWebKitAPI/Tests/WebKit2/associate-form-controls.html: Added.
    Add a form in response to the onload event. Add a button that will add the password field
    for manual testing.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    f13d0a3d