<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Toggling settings in tests is a confusing area, with multiple (sometimes conflicting) ways to modify settings.</div><div class=""><br class=""></div><div class="">After cleaning things up a bit in r211006 I wanted to document my understanding of the patterns I see right now. Much of this was new to me so others may find it useful.</div><div class=""><br class=""></div><div class=""><b class="">Different Types of Settings:</b></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">• RuntimeEnabledFeatures (WebCore)</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Should be for features that have <i class="">Web Exposed APIs </i>that will only be exposed if the feature is enabled</div><div class="">- Should be for features that must be toggled <i class="">before a page has loaded</i>, since after a page load may be too late for EnabledAtRuntime bindings</div></blockquote><br class=""></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">• Settings (WebCore)</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- All other settings that change engine behavior</div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Okay to toggle at any time and WebCore often respects the setting immediately</div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div><div class="">• WebPreferences (WebKit, WebKit2)</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- API level Toggles for the above settings</div><div class="">- Toggles for WebKit level behavior (e.g. Tabbing between links behavior)</div><div class="">- Ports may have different default values for features</div></blockquote></blockquote><div class=""><br class=""></div><div class=""><b class="">Policies for Settings in LayoutTests:</b></div><div class=""><b class=""><br class=""></b></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">• TestRunners (WebKitTestRunner / DumpRenderTree)</div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Should set up a consistent environment before each test</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- Ports have different defaults, so having TestRunner make things consistent seems reasonable</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>- WTR: <i class="">TestController::resetPreferencesToConsistentValues</i></div></blockquote></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- DRT: <i class="">resetWebPreferencesToConsistentValues</i></div></blockquote></div></blockquote><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Should enable Experimental features for tests</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- Since we allow users to enable these features they should be enabled and get maximum testing</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- WTR: <i class="">WKPreferencesEnableAllExperimentalFeatures</i></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- DRT: <i class="">enableExperimentalFeatures</i></div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div><div class="">• If a test wants to change a Setting:</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Use: <i class="">internals.settings.setFoo(value);</i></div><div class="">- Settings in Settings.in are autogenerated, others are added to InternalSettings as needed</div><div class="">- InternalSettings handles resetting modifications before the next test</div></blockquote></blockquote></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">• If a test wants to change a RuntimeEnabledFeature:</div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">- No set pattern.</div><div class="">- Some tests use internals.settings but this seems inappropriate, since the page has already loaded</div><div class="">- Some tests use the special comment syntax parsed by TestRunners; this makes sense, but would not be good for imported tests</div></div></blockquote></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></blockquote><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">• If a test wants to change a WebPreference / WebKit level setting:</div></blockquote></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Use: <i class="">testRunner.someMethod(value);</i></div><div class=""><i class="">- </i>Avoid: <i class="">testRunner.overridePreference(preferenceKey, value);</i></div></blockquote></div></blockquote><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- TestRunners should reset these back to a consistent value before the next test</div></blockquote></blockquote><div class=""><br class=""></div><div class="">Let me know if you think anything is inaccurate or if you have ideas to simplify / improve.</div><div class=""><br class=""></div><div class="">- Joe</div></div></body></html>