Changes between Version 1 and Version 2 of Exposing WebKit internals for Layout Tests
- Timestamp:
- Jun 26, 2012, 3:05:56 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Exposing WebKit internals for Layout Tests
v1 v2 1 Exposing WebKit internals for layout tests: 1 '''Exposing WebKit internals for layout tests:''' 2 2 3 3 4 4 This turned out to be a bit harder than one might expect. Many methods of the Document object are already public, but not all the ones that we might need. In my case, I needed a way to get at the list of favicon URLs in the head of the document. My plan was to do something similar to what DumpRenderTree does, and dump out the icon url list in the Layout Test, then check that the dumped text matched the expected dumped text. 5 5 6 The approach that didn’t pass CR: (in case you need to try something similar someday) 6 '''The approach that didn’t pass CR: (in case you need to try something similar someday)''' 7 7 8 8 My first thought was to try and expose the methods so that I could call them from the dump render tree code, which is easy enough. I put them into Document.h, but Document.h is not exposed to external callers. To be exposed to clients of WebKit, you need to expose the function in WebDocument.h (and WebFrame.h, in this case). WebFrame and WebDocument have access to the internals of Frame and Document, and can copy items from the Frame and Document into their own internal data structures and expose them. You have to build the C++ to back the JS methods in LayoutTexstController.cpp After that, I was able to write a DumpRenderTree function in TestShell.cpp to dump the icon URL list. 9 9 10 However, that involved modifying the public API of webkit to make available the icon URL list. When the code got to code review, the approach was rejected. (The same approach might still work for you if your case does not require adding new methods to the WebKit API, which is why I’ve documented it here.)10 '''However''', that involved modifying the public API of webkit to make available the icon URL list. When the code got to code review, the approach was rejected. (The same approach might still work for you if your case does not require adding new methods to the WebKit API, which is why I’ve documented it here.) 11 11 12 The internals approach: 12 '''The internals approach:''' 13 13 14 14 A second approach is to use the “Internals” object, which exists for this purpose. Any newer stuff you want to expose from the internals of webkit to layout tests should be put here. With this approach, I was able to expose a list of icon URLs to a JavaScript function running in the layout tests.