[webkit-changes] [WebKit/WebKit] c8fad1: Provide initial infrastructure for creating PDF re...

Sammy Gill noreply at github.com
Fri Mar 15 22:19:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c8fad15f783eb5b7f84b415d0c2a8c97b24fc786
      https://github.com/WebKit/WebKit/commit/c8fad15f783eb5b7f84b415d0c2a8c97b24fc786
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2024-03-15 (Fri, 15 Mar 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    A LayoutTests/pdf/unifiedpdf/annotations/checkbox-set-active-expected.html
    A LayoutTests/pdf/unifiedpdf/annotations/checkbox-set-active.html
    A LayoutTests/pdf/unifiedpdf/annotations/dropdown-select-second-option-expected.html
    A LayoutTests/pdf/unifiedpdf/annotations/dropdown-select-second-option.html
    A LayoutTests/pdf/unifiedpdf/annotations/radio-buttons-select-second-expected.html
    A LayoutTests/pdf/unifiedpdf/annotations/radio-buttons-select-second.html
    A LayoutTests/pdf/unifiedpdf/resources/annotation-checkbox-active.pdf
    A LayoutTests/pdf/unifiedpdf/resources/annotation-checkbox-inactive.pdf
    A LayoutTests/pdf/unifiedpdf/resources/annotation-dropdown-first-option-selected.pdf
    A LayoutTests/pdf/unifiedpdf/resources/annotation-dropdown-second-option-selected.pdf
    A LayoutTests/pdf/unifiedpdf/resources/annotation-two-radio-buttons-first-active.pdf
    A LayoutTests/pdf/unifiedpdf/resources/annotation-two-radio-buttons-second-active.pdf
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/plugins/PluginViewBase.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/Plugins/PluginView.cpp
    M Source/WebKit/WebProcess/Plugins/PluginView.h

  Log Message:
  -----------
  Provide initial infrastructure for creating PDF ref tests.
https://bugs.webkit.org/show_bug.cgi?id=270044
rdar://problem/123573535

Reviewed by Tim Horton.

This patch provides the very initial infrastructure that we will build
upon for creating PDF ref tests. The main focus was to create a way
for us to test PDF annotations, but we can build upon this to test other
parts of PDF functionality. I added three very basic tests to cover PDF
annotation interaction: selecting radio buttons, checkboxes, and select
menus.

Two APIs were added to window.internals to make this possible:
1.) registerPDFTestCallback
2.) pdfAnnotationRects

registerPDFTestCallback takes two arguments: the HTML element that
corresponds to the plugin and a callback that will get executed once
the PDF document is installed in the plugin. The callback is supposed to
act as the test that we would like to run and should contain all of the
logic involved with testing a particular part of PDF functionality.
This callback is taken and plumbed into the PDFPlugin so that it can
execute once the document is ready so that it can use any other APIs
that return information about the document. This is done by calling into
the corresponding private method on PluginViewBase that is available to
Internals since it is a friend. I chose this approach because I did not
want this to become a public API on PluginViewBase that can be used
arbitrarily. Also, if the document is already loaded in the plugin then
we will execute the callback immediately in order to avoid holding onto
it.

pdfAnotationRects is a simple API that just returns a list
of the geometry of all the annotations in the document in plugin space.
Returning the geometry of all the annotations was the simplest and was
sufficient enough for the tests that were added in this patch. However,
we can build upon this to filter out which annotations should be
retruned based upon what we find useful for testing.

The current approach to creating a PDF ref test is to load a document
in either a iframe or embed and then register a callback that will
contain all of the logic for the test once the document has been loaded
in the plugin. For example, the tests for the annotations in this patch
use UIHelper pdfAnnotationRects to interact with the document.

One current limitation with the initial infrastructure is that you need
to have a reference document with the modified PDF that the test will be
compared against. The annotation tests mutate the document in the test
itself, but the result is compared with a PDF that is mutated to be the
expectation of the test result. I tried to make it so that the reference
could use the legacy plugin, but my initial attempts were fruitless so
opted for the simpler approach for the sake of getting the groundwork
laid out so that we could iterate on it for future patches. Another
alternative improvement to consider besides getting the legacy plugin
to work is to add some additional APIs that gather data on the PDF
document and then have the tests assert against the data with what they
expect it to be.

* LayoutTests/TestExpectations:
* LayoutTests/pdf/unifiedpdf/annotations/checkbox-set-active-expected.html: Added.
* LayoutTests/pdf/unifiedpdf/annotations/checkbox-set-active.html: Added.
* LayoutTests/pdf/unifiedpdf/annotations/dropdown-select-second-option-expected.html: Added.
* LayoutTests/pdf/unifiedpdf/annotations/dropdown-select-second-option.html: Added.
* LayoutTests/pdf/unifiedpdf/annotations/radio-buttons-select-second-expected.html: Added.
* LayoutTests/pdf/unifiedpdf/annotations/radio-buttons-select-second.html: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-checkbox-active.pdf: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-checkbox-inactive.pdf: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-dropdown-first-option-selected.pdf: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-dropdown-second-option-selected.pdf: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-two-radio-buttons-first-active.pdf: Added.
* LayoutTests/pdf/unifiedpdf/resources/annotation-two-radio-buttons-second-active.pdf: Added.
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/plugins/PluginViewBase.h:
(WebCore::PluginViewBase::pdfAnnotationRectsForTesting const):
(WebCore::PluginViewBase::registerPDFTestCallback):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::pdfAnnotationRectsForTesting const):
(WebCore::Internals::registerPDFTest):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::annotationRectsForTesting const):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::registerPDFTest):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::annotationRectsForTesting const):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pdfAnnotationRectsForTesting const):
(WebKit::PluginView::registerPDFTestCallback):
* Source/WebKit/WebProcess/Plugins/PluginView.h:

Canonical link: https://commits.webkit.org/276228@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list