Mockable code needs to be in Javascript also. Consider for example, browser detection:

if (navigator.appName == 'Microsoft Internet Explorer') {
...
if (preg_match('/(?i)msie [1-8]/', $_SERVER['HTTP_USER_AGENT'])) { 
...
}

It should be possible to mock both of these with a single setting.