PageRenderTime 105ms CodeModel.GetById 40ms app.highlight 29ms RepoModel.GetById 32ms app.codeStats 0ms

/tests/automatic_tests/save_devtools_settings/index.html

https://github.com/qiongocean/node-webkit
HTML | 183 lines | 173 code | 10 blank | 0 comment | 0 complexity | b2b8370728a9a15def95994a7a01b899 MD5 | raw file
  1<!DOCTYPE html>
  2<html lang="en">
  3<head>
  4  <meta charset="UTF-8">
  5  <title>Test case for save devtools settings</title>
  6</head>
  7<body>
  8  <p id="wait" style="font-size:1.5em">Please wait to be closed.</p>
  9  <input type="text" id="color" placeholder="css color"/>
 10  <script>
 11    var gui = require('nw.gui');
 12    var win = gui.Window.get();
 13    var result = new Array();
 14    //action: 1 change the devtools settings
 15    var action = gui.App.argv[0];
 16
 17    //load devtools into iframe
 18    win.showDevTools('', true);
 19    win.on("devtools-opened", function(url) {
 20        var iframe_devtools = document.createElement("iframe");
 21	iframe_devtools.id = 'devtools';
 22	iframe_devtools.src = url;
 23	iframe_devtools.height = '1000';
 24	iframe_devtools.width = '1000';
 25	function change_setttings() {
 26	    var scripts = devtools.document.getElementsByClassName('scripts');
 27
 28	    // make sure it is complete 
 29	    if(scripts == undefined  || scripts[0] == undefined || scripts[0].click == undefined)
 30                setTimeout(change_setttings, 3000);
 31	    else {
 32	    	// open settitng 
 33		devtools.WebInspector.SettingsController.prototype.showSettingsScreen();
 34		// save original settings
 35		// general
 36		devtools.WebInspector.settingsController._settingsScreen._tabbedPane._tabs[0]._tabbedPane.selectTab('general', true);
 37		result.push(devtools.document.getElementsByName('Disable cache (while DevTools is open)')[0].checked);
 38		result.push(devtools.document.getElementsByName('Disable JavaScript')[0].checked);
 39		result.push(devtools.document.getElementsByName('Split panels vertically when docked to right')[0].checked);
 40		// 0~3
 41		for (var i = 0; i < 4; i++) 
 42		    if (devtools.document.getElementsByClassName('toplevel')[0].childNodes[1][i]) {
 43			result.push(i);
 44			break;
 45		    }
 46		result.push(devtools.document.getElementsByName('Show user agent styles')[0].checked);
 47		result.push(devtools.document.getElementsByName('Word wrap')[0].checked);
 48		result.push(devtools.document.getElementsByName('Show Shadow DOM')[0].checked);
 49		result.push(devtools.document.getElementsByName('Show rulers')[0].checked);
 50		result.push(devtools.document.getElementsByName('Show paint rectangles')[0].checked);
 51		result.push(devtools.document.getElementsByName('Show composited layer borders')[0].checked);
 52		result.push(devtools.document.getElementsByName('Search in content scripts')[0].checked);
 53		result.push(devtools.document.getElementsByName('Enable JS source maps')[0].checked);
 54		result.push(devtools.document.getElementsByName('Enable CSS source maps')[0].checked);
 55		// 0~3
 56		result.push(devtools.document.getElementsByClassName('toplevel')[0].childNodes[1].selectedIndex);
 57		result.push(devtools.document.getElementsByName('Show whitespace characters')[0].checked);
 58		result.push(devtools.document.getElementsByName("Detect indentation")[0].checked);
 59		result.push(devtools.document.getElementsByName('Limit number of captured JS stack frames')[0].checked);
 60		result.push(devtools.document.getElementsByClassName('numeric')[0].value);
 61		result.push(devtools.document.getElementsByName('Show CPU activity on the ruler')[0].checked);
 62		result.push(devtools.document.getElementsByName('Log XMLHttpRequests')[0].checked);
 63		result.push(devtools.document.getElementsByName('Preserve log upon navigation')[0].checked);
 64	        if (process.platform != 'darwin')
 65		        result.push(devtools.document.getElementsByName('Enable Ctrl + 1-9 shortcut to switch panels')[0].checked);
 66         	else
 67            		result.push(devtools.document.getElementsByName('Enable Cmd + 1-9 shortcut to switch panels')[0].checked);
 68		// overrides 
 69		devtools.WebInspector.settingsController._settingsScreen._tabbedPane._tabs[0]._tabbedPane.selectTab("overrides", true);
 70
 71                result.push(devtools.document.getElementsByClassName('help-block')[0].childNodes[0].childNodes[0].checked);//
 72                result.push(devtools.document.getElementsByClassName('help-block')[0].childNodes[1].childNodes[0].childNodes[0].checked);//Enable on Devtools startup 
 73		// 0~21
 74		result.push(devtools.document.getElementsByClassName('help-block')[1].childNodes[0].childNodes[1].childNodes[0].selectedIndex);
 75		result.push(devtools.document.getElementsByName('User Agent')[0].checked);//Overrides User agent
 76		
 77		// ignore next
 78		//result.push(devtools.document.getElementById('metrics-override-checkbox').checked);
 79		result.push(devtools.document.getElementsByName('Device metrics')[0].checked);
 80		// result.push(devtools.document.getElementById('metrics-override-width').value);
 81		// result.push(devtools.document.getElementById('metrics-override-height').value);
 82		// ignore next next
 83		result.push(devtools.document.getElementsByName('Fit in window')[0].checked);
 84		result.push(devtools.document.getElementsByName('Override Geolocation')[0].checked);
 85		result.push(devtools.document.getElementById('geolocation-override-latitude').value);
 86		result.push(devtools.document.getElementById('geolocation-override-longitude').value);
 87		result.push(devtools.document.getElementById('geolocation-error').checked);
 88
 89		result.push(devtools.document.getElementsByName('Override Device Orientation')[0].checked);
 90
 91		result.push(devtools.document.getElementById('device-orientation-override-alpha').value);
 92		result.push(devtools.document.getElementById('device-orientation-override-beta').value);
 93		result.push(devtools.document.getElementById('device-orientation-override-gamma').value);
 94		result.push(devtools.document.getElementsByClassName('help-block')[4].childNodes[0].childNodes[0].childNodes[0].checked);
 95		result.push(devtools.document.getElementsByClassName('help-block')[5].childNodes[0].childNodes[0].childNodes[0].checked);
 96		// 0~8
 97		//result.push(devtools.document.getElementsByClassName('help-block')[5].childNodes[0].childNodes[1].selectedIndex);
 98		result.push(devtools.document.getElementsByName('Emulate CSS media')[0].checked);
 99		if (action == '1') {
100		    var i = 0;
101		    // change original settings
102		    // general
103		    devtools.WebInspector.settingsController._settingsScreen._tabbedPane._tabs[0]._tabbedPane.selectTab('general', true);
104		    devtools.document.getElementsByName('Disable cache (while DevTools is open)')[0].click(); i++;
105		    devtools.document.getElementsByName('Disable JavaScript')[0].click(); i++;
106		    devtools.document.getElementsByName('Split panels vertically when docked to right')[0].click(); i++;
107		    // 0~3
108		    devtools.document.getElementsByClassName('toplevel')[0].childNodes[1][(result[i++] + 1) % 4].click();
109
110		    devtools.document.getElementsByName('Show user agent styles')[0].click(); i++;
111		    devtools.document.getElementsByName('Word wrap')[0].click(); i++;
112		    devtools.document.getElementsByName('Show Shadow DOM')[0].click(); i++;
113		    devtools.document.getElementsByName('Show rulers')[0].click(); i++;
114		    devtools.document.getElementsByName('Show paint rectangles')[0].click(); i++;
115		    devtools.document.getElementsByName('Show composited layer borders')[0].click(); i++;
116		    devtools.document.getElementsByName('Search in content scripts')[0].click(); i++;
117		    devtools.document.getElementsByName('Enable JS source maps')[0].click(); i++;
118		    devtools.document.getElementsByName('Enable CSS source maps')[0].click(); i++;
119
120		    if (!result[i - 1])
121			// 0~3
122			devtools.document.getElementsByClassName('toplevel')[0].childNodes[1].selectedIndex = (result[i++] + 1) % 4;
123		    devtools.document.getElementsByName('Show whitespace characters')[0].click(); i++;
124		    devtools.document.getElementsByName("Detect indentation")[0].click(); i++;
125		    devtools.document.getElementsByName('Limit number of captured JS stack frames')[0].click(); i++;
126		    if (!result[i - 1])
127			devtools.document.getElementsByClassName('numeric')[0].value = (result[i++] + 1) % 10;
128		    devtools.document.getElementsByName('Show CPU activity on the ruler')[0].click(); i++;
129		    devtools.document.getElementsByName('Log XMLHttpRequests')[0].click(); i++;
130		    devtools.document.getElementsByName('Preserve log upon navigation')[0].click(); i++;
131                    if (process.platform != 'darwin')
132		        devtools.document.getElementsByName('Enable Ctrl + 1-9 shortcut to switch panels')[0].click();
133		    else
134            		devtools.document.getElementsByName('Enable Cmd + 1-9 shortcut to switch panels')[0].click();
135		    i++;
136
137		    // overrides 
138		    devtools.WebInspector.settingsController._settingsScreen._tabbedPane._tabs[0]._tabbedPane.selectTab("overrides", true);
139                    devtools.document.getElementsByClassName('help-block')[0].childNodes[0].childNodes[0].click(); i++;//
140                    devtools.document.getElementsByClassName('help-block')[0].childNodes[1].childNodes[0].childNodes[0].click(); i++//Enable on Devtools startup 
141		    if (!result[i - 1])
142			// 0~21
143			devtools.document.getElementsByClassName('help-block')[1].childNodes[0].childNodes[1].childNodes[0].selectedIndex = (result[i++] + 1) % 22;
144		    // ignore next
145		    //devtools.document.getElementById('metrics-override-checkbox').click(); i++;
146		    devtools.document.getElementsByName('Device metrics')[0].click(); i++;
147		    // result.push(devtools.document.getElementById('metrics-override-width').value);
148		    // result.push(devtools.document.getElementById('metrics-override-height').value);
149		    // ignore next next
150		    devtools.document.getElementsByName('Fit in window')[0].click(); i++;
151		    devtools.document.getElementsByName('Override Geolocation')[0].click(); i++;
152		    if (!result[i - 1]) {
153			devtools.document.getElementById('geolocation-override-latitude').value =  (result[i++] + 1) % 10;
154			devtools.document.getElementById('geolocation-override-longitude').value = (result[i++] + 1) % 10;
155		    }
156		    devtools.document.getElementById('geolocation-error').click(); i++;
157		    devtools.document.getElementsByName('Override Device Orientation')[0].click(); i++;
158		    if (!result[i - 1]) {
159			devtools.document.getElementById('device-orientation-override-alpha').value = (result[i++] + 1) % 10;
160			devtools.document.getElementById('device-orientation-override-beta').value = (result[i++] + 1) % 10;
161			devtools.document.getElementById('device-orientation-override-gamma').value = (result[i++] + 1) % 10;
162		    }
163		    devtools.document.getElementsByClassName('help-block')[4].childNodes[0].childNodes[0].childNodes[0].click(); i++;
164		    devtools.document.getElementsByClassName('help-block')[5].childNodes[0].childNodes[0].childNodes[0].click(); i++;
165		    devtools.document.getElementsByName('Emulate CSS media')[0].checked;
166		    //if (!result[i - 1])
167			// 0~8
168		//	devtools.document.getElementsByClassName('help-block')[5].childNodes[0].childNodes[1].selectedIndex = (result[i++] + 1) % 9;
169		}
170		win.showDevTools();
171
172		var client = require('../../nw_test_app').createClient({
173                    argv: gui.App.argv,
174                    data: result
175		});
176	    }
177	}
178	iframe_devtools.onload = change_setttings;
179	document.getElementById("wait").appendChild(iframe_devtools);
180    });
181</script>
182</body>
183</html>