[webkit-dev] Settings and Preferences in layout tests
Raphael Kubo da Costa
rakuco at webkit.org
Thu Sep 27 01:12:40 PDT 2012
Brady Eidson <beidson at apple.com> writes:
> On Sep 26, 2012, at 2:46 PM, Tony Chang <tony at chromium.org> wrote:
>> I suppose we're biased in Mac-land where the mechanism originated,
>> but the "API" is simply a single string based API that only had to
>> be implemented once.
>>
>> Your comment leads me to understand that at least one other port
>> doesn't have simple string based preferences.
[...]
>> I think for all the major ports, they are simple string based
>> preferences. However, adding a new overridePreference call means
>> updating 5 WebKit API interfaces (Mac, Win, Chromium, GTK+, QT), and
>> updating 5 DRTs and 1 WTR. Compared to updating a single
>> internal.settings implementation, this is a lot of work.
> I think you misunderstand what I meant.
>
> The Mac DRT implementation of overridePreference has the following
> implementation:
>
> void TestRunner::overridePreference(JSStringRef key, JSStringRef
> value)
> {
> RetainPtr<CFStringRef> keyCF(AdoptCF,
> JSStringCopyCFString(kCFAllocatorDefault, key));
> NSString *keyNS = (NSString *)keyCF.get();
>
> RetainPtr<CFStringRef> valueCF(AdoptCF,
> JSStringCopyCFString(kCFAllocatorDefault, value));
> NSString *valueNS = (NSString *)valueCF.get();
>
> [[WebPreferences standardPreferences]
> _setPreferenceForTestWithValue:valueNS forKey:keyNS];
> }
>
> This works for any preference; Even a new one that has never been
> twiddled in a regression test before.
The situation seems to be improving as more ports move towards WebKit2,
where adding new preferences to overridePreferences is normally a matter
of touching a (few) file(s) in Source/WebKit2/Shared.
However, for chromium and ports using DRT this does not help much, as
the Mac code ends up being the exception: all the other DRTs (chromium,
blackberry, Qt, EFL, GTK+) implement some variation of a big switch
mapping that string into an API of some sort, so even if the preference
already exists in the WebKit layer one needs to add more code to DRT
simply to call that.
And sometimes there's even more than one way of achieving the same
thing, such as changing the "WebKitDisplayImagesKey" preference or
calling testRunner.disableImageLoading().
More information about the webkit-dev
mailing list