tests.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. var cordova = require('cordova');
  22. var isWindows = cordova.platformId == 'windows';
  23. window.alert = window.alert || navigator.notification.alert;
  24. exports.defineManualTests = function (contentEl, createActionButton) {
  25. function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) {
  26. numExpectedRedirects = numExpectedRedirects || 0;
  27. useWindowOpen = useWindowOpen || false;
  28. console.log("Opening " + url);
  29. var counts;
  30. var lastLoadStartURL;
  31. var wasReset = false;
  32. function reset() {
  33. counts = {
  34. 'loaderror': 0,
  35. 'loadstart': 0,
  36. 'loadstop': 0,
  37. 'exit': 0
  38. };
  39. lastLoadStartURL = '';
  40. }
  41. reset();
  42. var iab;
  43. var callbacks = {
  44. loaderror: logEvent,
  45. loadstart: logEvent,
  46. loadstop: logEvent,
  47. exit: logEvent
  48. };
  49. if (useWindowOpen) {
  50. console.log('Use window.open() for url');
  51. iab = window.open(url, target, params, callbacks);
  52. }
  53. else {
  54. iab = cordova.ThemeableBrowser.open(url, target, params, callbacks);
  55. }
  56. if (!iab) {
  57. alert('open returned ' + iab);
  58. return;
  59. }
  60. function logEvent(e) {
  61. console.log('IAB event=' + JSON.stringify(e));
  62. counts[e.type]++;
  63. // Verify that event.url gets updated on redirects.
  64. if (e.type == 'loadstart') {
  65. if (e.url == lastLoadStartURL) {
  66. alert('Unexpected: loadstart fired multiple times for the same URL.');
  67. }
  68. lastLoadStartURL = e.url;
  69. }
  70. // Verify the right number of loadstart events were fired.
  71. if (e.type == 'loadstop' || e.type == 'loaderror') {
  72. if (e.url != lastLoadStartURL) {
  73. alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
  74. }
  75. if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) {
  76. // Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
  77. if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) {
  78. alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')');
  79. }
  80. } else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) {
  81. alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']);
  82. }
  83. wasReset = true;
  84. numExpectedRedirects = 0;
  85. reset();
  86. }
  87. // Verify that loadend / loaderror was called.
  88. if (e.type == 'exit') {
  89. var numStopEvents = counts['loadstop'] + counts['loaderror'];
  90. if (numStopEvents === 0 && !wasReset) {
  91. alert('Unexpected: browser closed without a loadstop or loaderror.');
  92. } else if (numStopEvents > 1) {
  93. alert('Unexpected: got multiple loadstop/loaderror events.');
  94. }
  95. }
  96. }
  97. return iab;
  98. }
  99. function doHookOpen(url, target, params, numExpectedRedirects) {
  100. var originalFunc = window.open;
  101. var wasClobbered = window.hasOwnProperty('open');
  102. window.open = cordova.ThemeableBrowser.open;
  103. try {
  104. doOpen(url, target, params, numExpectedRedirects, true);
  105. }
  106. finally {
  107. if (wasClobbered) {
  108. window.open = originalFunc;
  109. }
  110. else {
  111. console.log('just delete, to restore open from prototype');
  112. delete window.open;
  113. }
  114. }
  115. }
  116. function openWithStyle(url, cssUrl, useCallback) {
  117. var iab = doOpen(url, '_blank', 'location=yes');
  118. var callback = function (results) {
  119. if (results && results.length === 0) {
  120. alert('Results verified');
  121. } else {
  122. console.log(results);
  123. alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
  124. }
  125. };
  126. if (cssUrl) {
  127. iab.addEventListener('loadstop', function (event) {
  128. iab.insertCSS({ file: cssUrl }, useCallback && callback);
  129. });
  130. } else {
  131. iab.addEventListener('loadstop', function (event) {
  132. iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' },
  133. useCallback && callback);
  134. });
  135. }
  136. }
  137. function openWithScript(url, jsUrl, useCallback) {
  138. var iab = doOpen(url, '_blank', 'location=yes');
  139. if (jsUrl) {
  140. iab.addEventListener('loadstop', function (event) {
  141. iab.executeScript({ file: jsUrl }, useCallback && function (results) {
  142. if (results && results.length === 0) {
  143. alert('Results verified');
  144. } else {
  145. console.log(results);
  146. alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
  147. }
  148. });
  149. });
  150. } else {
  151. iab.addEventListener('loadstop', function (event) {
  152. var code = '(function(){\n' +
  153. ' var header = document.getElementById("header");\n' +
  154. ' header.innerHTML = "Script literal successfully injected";\n' +
  155. ' return "abc";\n' +
  156. '})()';
  157. iab.executeScript({ code: code }, useCallback && function (results) {
  158. if (results && results.length === 1 && results[0] === 'abc') {
  159. alert('Results verified');
  160. } else {
  161. console.log(results);
  162. alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
  163. }
  164. });
  165. });
  166. }
  167. }
  168. var hiddenwnd = null;
  169. var loadlistener = function (event) { alert('background window loaded '); };
  170. function openHidden(url, startHidden) {
  171. var shopt = (startHidden) ? 'hidden=yes' : '';
  172. hiddenwnd = cordova.ThemeableBrowser.open(url, 'random_string', shopt);
  173. if (!hiddenwnd) {
  174. alert('cordova.ThemeableBrowser.open returned ' + hiddenwnd);
  175. return;
  176. }
  177. if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
  178. }
  179. function showHidden() {
  180. if (!!hiddenwnd) {
  181. hiddenwnd.show();
  182. }
  183. }
  184. function closeHidden() {
  185. if (!!hiddenwnd) {
  186. hiddenwnd.removeEventListener('loadstop', loadlistener);
  187. hiddenwnd.close();
  188. hiddenwnd = null;
  189. }
  190. }
  191. var info_div = '<h1>ThemeableBrowser</h1>' +
  192. '<div id="info">' +
  193. 'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
  194. 'Make sure http://www.apple.com is not in the white list.</br>' +
  195. 'In iOS, starred <span style="vertical-align:super">*</span> tests will put the app in a state with no way to return. </br>' +
  196. '<h4>User-Agent: <span id="user-agent"> </span></hr>' +
  197. '</div>';
  198. var local_tests = '<h1>Local URL</h1>' +
  199. '<div id="openLocal"></div>' +
  200. 'Expected result: opens successfully in CordovaWebView.' +
  201. '<p/> <div id="openLocalHook"></div>' +
  202. 'Expected result: opens successfully in CordovaWebView (using hook of window.open()).' +
  203. '<p/> <div id="openLocalSelf"></div>' +
  204. 'Expected result: opens successfully in CordovaWebView.' +
  205. '<p/> <div id="openLocalSystem"></div>' +
  206. 'Expected result: fails to open' +
  207. '<p/> <div id="openLocalBlank"></div>' +
  208. 'Expected result: opens successfully in ThemeableBrowser with locationBar at top.' +
  209. '<p/> <div id="openLocalRandomNoLocation"></div>' +
  210. 'Expected result: opens successfully in ThemeableBrowser without locationBar.' +
  211. '<p/> <div id="openLocalRandomToolBarBottom"></div>' +
  212. 'Expected result: opens successfully in ThemeableBrowser with locationBar. On iOS the toolbar is at the bottom.' +
  213. '<p/> <div id="openLocalRandomToolBarTop"></div>' +
  214. 'Expected result: opens successfully in ThemeableBrowser with locationBar. On iOS the toolbar is at the top.' +
  215. '<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
  216. 'Expected result: open successfully in ThemeableBrowser with no locationBar. On iOS the toolbar is at the top.';
  217. var white_listed_tests = '<h1>White Listed URL</h1>' +
  218. '<div id="openWhiteListed"></div>' +
  219. 'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
  220. '<p/> <div id="openWhiteListedHook"></div>' +
  221. 'Expected result: open successfully in CordovaWebView to cordova.apache.org (using hook of window.open())' +
  222. '<p/> <div id="openWhiteListedSelf"></div>' +
  223. 'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
  224. '<p/> <div id="openWhiteListedSystem"></div>' +
  225. 'Expected result: open successfully in system browser to cordova.apache.org' +
  226. '<p/> <div id="openWhiteListedBlank"></div>' +
  227. 'Expected result: open successfully in ThemeableBrowser to cordova.apache.org' +
  228. '<p/> <div id="openWhiteListedRandom"></div>' +
  229. 'Expected result: open successfully in ThemeableBrowser to cordova.apache.org' +
  230. '<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
  231. 'Expected result: open successfully in ThemeableBrowser to cordova.apache.org with no location bar.';
  232. var non_white_listed_tests = '<h1>Non White Listed URL</h1>' +
  233. '<div id="openNonWhiteListed"></div>' +
  234. 'Expected result: open successfully in ThemeableBrowser to apple.com.' +
  235. '<p/> <div id="openNonWhiteListedHook"></div>' +
  236. 'Expected result: open successfully in ThemeableBrowser to apple.com (using hook of window.open()).' +
  237. '<p/> <div id="openNonWhiteListedSelf"></div>' +
  238. 'Expected result: open successfully in ThemeableBrowser to apple.com (_self enforces whitelist).' +
  239. '<p/> <div id="openNonWhiteListedSystem"></div>' +
  240. 'Expected result: open successfully in system browser to apple.com.' +
  241. '<p/> <div id="openNonWhiteListedBlank"></div>' +
  242. 'Expected result: open successfully in ThemeableBrowser to apple.com.' +
  243. '<p/> <div id="openNonWhiteListedRandom"></div>' +
  244. 'Expected result: open successfully in ThemeableBrowser to apple.com.' +
  245. '<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
  246. 'Expected result: open successfully in ThemeableBrowser to apple.com without locationBar.';
  247. var page_with_redirects_tests = '<h1>Page with redirect</h1>' +
  248. '<div id="openRedirect301"></div>' +
  249. 'Expected result: should 301 and open successfully in ThemeableBrowser to https://www.google.co.uk.' +
  250. '<p/> <div id="openRedirect302"></div>' +
  251. 'Expected result: should 302 and open successfully in ThemeableBrowser to www.zhihu.com/answer/16714076.';
  252. var pdf_url_tests = '<h1>PDF URL</h1>' +
  253. '<div id="openPDF"></div>' +
  254. 'Expected result: ThemeableBrowser opens. PDF should render on iOS.' +
  255. '<p/> <div id="openPDFBlank"></div>' +
  256. 'Expected result: ThemeableBrowser opens. PDF should render on iOS.';
  257. var invalid_url_tests = '<h1>Invalid URL</h1>' +
  258. '<div id="openInvalidScheme"></div>' +
  259. 'Expected result: fail to load in ThemeableBrowser.' +
  260. '<p/> <div id="openInvalidHost"></div>' +
  261. 'Expected result: fail to load in ThemeableBrowser.' +
  262. '<p/> <div id="openInvalidMissing"></div>' +
  263. 'Expected result: fail to load in ThemeableBrowser (404).';
  264. var css_js_injection_tests = '<h1>CSS / JS Injection</h1>' +
  265. '<div id="openOriginalDocument"></div>' +
  266. 'Expected result: open successfully in ThemeableBrowser without text "Style updated from..."' +
  267. '<p/> <div id="openCSSInjection"></div>' +
  268. 'Expected result: open successfully in ThemeableBrowser with "Style updated from file".' +
  269. '<p/> <div id="openCSSInjectionCallback"></div>' +
  270. 'Expected result: open successfully in ThemeableBrowser with "Style updated from file", and alert dialog with text "Results verified".' +
  271. '<p/> <div id="openCSSLiteralInjection"></div>' +
  272. 'Expected result: open successfully in ThemeableBrowser with "Style updated from literal".' +
  273. '<p/> <div id="openCSSLiteralInjectionCallback"></div>' +
  274. 'Expected result: open successfully in ThemeableBrowser with "Style updated from literal", and alert dialog with text "Results verified".' +
  275. '<p/> <div id="openScriptInjection"></div>' +
  276. 'Expected result: open successfully in ThemeableBrowser with text "Script file successfully injected".' +
  277. '<p/> <div id="openScriptInjectionCallback"></div>' +
  278. 'Expected result: open successfully in ThemeableBrowser with text "Script file successfully injected" and alert dialog with the text "Results verified".' +
  279. '<p/> <div id="openScriptLiteralInjection"></div>' +
  280. 'Expected result: open successfully in ThemeableBrowser with the text "Script literal successfully injected" .' +
  281. '<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
  282. 'Expected result: open successfully in ThemeableBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
  283. var open_hidden_tests = '<h1>Open Hidden </h1>' +
  284. '<div id="openHidden"></div>' +
  285. 'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
  286. '<p/> <div id="showHidden"></div>' +
  287. 'Expected result: after first clicking on previous test "create hidden", open successfully in ThemeableBrowser to https://www.google.co.uk.' +
  288. '<p/> <div id="closeHidden"></div>' +
  289. 'Expected result: no output. But click on "show hidden" again and nothing should be shown.' +
  290. '<p/> <div id="openHiddenShow"></div>' +
  291. 'Expected result: open successfully in ThemeableBrowser to https://www.google.co.uk';
  292. var clearing_cache_tests = '<h1>Clearing Cache</h1>' +
  293. '<div id="openClearCache"></div>' +
  294. 'Expected result: ?' +
  295. '<p/> <div id="openClearSessionCache"></div>' +
  296. 'Expected result: ?';
  297. var video_tag_tests = '<h1>Video tag</h1>' +
  298. '<div id="openRemoteVideo"></div>' +
  299. 'Expected result: open successfully in ThemeableBrowser with an embedded video that works after clicking the "play" button.';
  300. var local_with_anchor_tag_tests = '<h1>Local with anchor tag</h1>' +
  301. '<div id="openAnchor1"></div>' +
  302. 'Expected result: open successfully in ThemeableBrowser to the local page, scrolled to the top as normal.' +
  303. '<p/> <div id="openAnchor2"></div>' +
  304. 'Expected result: open successfully in ThemeableBrowser to the local page, scrolled to the beginning of the tall div with border.';
  305. // CB-7490 We need to wrap this code due to Windows security restrictions
  306. // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
  307. if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
  308. MSApp.execUnsafeLocalFunction(function() {
  309. contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
  310. css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests;
  311. });
  312. } else {
  313. contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
  314. css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests;
  315. }
  316. document.getElementById("user-agent").textContent = navigator.userAgent;
  317. // we are already in cdvtests directory
  318. var basePath = 'iab-resources/';
  319. var localhtml = basePath + 'local.html',
  320. localpdf = basePath + 'local.pdf',
  321. injecthtml = basePath + 'inject.html',
  322. injectjs = isWindows ? basePath + 'inject.js' : 'inject.js',
  323. injectcss = isWindows ? basePath + 'inject.css' : 'inject.css',
  324. videohtml = basePath + 'video.html';
  325. //Local
  326. createActionButton('target=Default', function () {
  327. doOpen(localhtml);
  328. }, 'openLocal');
  329. createActionButton('target=Default (window.open)', function () {
  330. doHookOpen(localhtml);
  331. }, 'openLocalHook');
  332. createActionButton('target=_self', function () {
  333. doOpen(localhtml, '_self');
  334. }, 'openLocalSelf');
  335. createActionButton('target=_system', function () {
  336. doOpen(localhtml, '_system');
  337. }, 'openLocalSystem');
  338. createActionButton('target=_blank', function () {
  339. doOpen(localhtml, '_blank');
  340. }, 'openLocalBlank');
  341. createActionButton('target=Random, location=no, disallowoverscroll=yes', function () {
  342. doOpen(localhtml, 'random_string', 'location=no, disallowoverscroll=yes');
  343. }, 'openLocalRandomNoLocation');
  344. createActionButton('target=Random, toolbarposition=bottom', function () {
  345. doOpen(localhtml, 'random_string', 'toolbarposition=bottom');
  346. }, 'openLocalRandomToolBarBottom');
  347. createActionButton('target=Random, toolbarposition=top', function () {
  348. doOpen(localhtml, 'random_string', 'toolbarposition=top');
  349. }, 'openLocalRandomToolBarTop');
  350. createActionButton('target=Random, toolbarposition=top, location=no', function () {
  351. doOpen(localhtml, 'random_string', 'toolbarposition=top,location=no');
  352. }, 'openLocalRandomToolBarTopNoLocation');
  353. //White Listed
  354. createActionButton('* target=Default', function () {
  355. doOpen('http://cordova.apache.org');
  356. }, 'openWhiteListed');
  357. createActionButton('* target=Default (window.open)', function () {
  358. doHookOpen('http://cordova.apache.org');
  359. }, 'openWhiteListedHook');
  360. createActionButton('* target=_self', function () {
  361. doOpen('http://cordova.apache.org', '_self');
  362. }, 'openWhiteListedSelf');
  363. createActionButton('target=_system', function () {
  364. doOpen('http://cordova.apache.org', '_system');
  365. }, 'openWhiteListedSystem');
  366. createActionButton('target=_blank', function () {
  367. doOpen('http://cordova.apache.org', '_blank');
  368. }, 'openWhiteListedBlank');
  369. createActionButton('target=Random', function () {
  370. doOpen('http://cordova.apache.org', 'random_string');
  371. }, 'openWhiteListedRandom');
  372. createActionButton('* target=Random, no location bar', function () {
  373. doOpen('http://cordova.apache.org', 'random_string', 'location=no');
  374. }, 'openWhiteListedRandomNoLocation');
  375. //Non White Listed
  376. createActionButton('target=Default', function () {
  377. doOpen('http://www.apple.com');
  378. }, 'openNonWhiteListed');
  379. createActionButton('target=Default (window.open)', function () {
  380. doHookOpen('http://www.apple.com');
  381. }, 'openNonWhiteListedHook');
  382. createActionButton('target=_self', function () {
  383. doOpen('http://www.apple.com', '_self');
  384. }, 'openNonWhiteListedSelf');
  385. createActionButton('target=_system', function () {
  386. doOpen('http://www.apple.com', '_system');
  387. }, 'openNonWhiteListedSystem');
  388. createActionButton('target=_blank', function () {
  389. doOpen('http://www.apple.com', '_blank');
  390. }, 'openNonWhiteListedBlank');
  391. createActionButton('target=Random', function () {
  392. doOpen('http://www.apple.com', 'random_string');
  393. }, 'openNonWhiteListedRandom');
  394. createActionButton('* target=Random, no location bar', function () {
  395. doOpen('http://www.apple.com', 'random_string', 'location=no');
  396. }, 'openNonWhiteListedRandomNoLocation');
  397. //Page with redirect
  398. createActionButton('http://google.co.uk', function () {
  399. doOpen('http://google.co.uk', 'random_string', '', 1);
  400. }, 'openRedirect301');
  401. createActionButton('http://goo.gl/pUFqg', function () {
  402. doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);
  403. }, 'openRedirect302');
  404. //PDF URL
  405. createActionButton('Remote URL', function () {
  406. doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');
  407. }, 'openPDF');
  408. createActionButton('Local URL', function () {
  409. doOpen(localpdf, '_blank');
  410. }, 'openPDFBlank');
  411. //Invalid URL
  412. createActionButton('Invalid Scheme', function () {
  413. doOpen('x-ttp://www.invalid.com/', '_blank');
  414. }, 'openInvalidScheme');
  415. createActionButton('Invalid Host', function () {
  416. doOpen('http://www.inv;alid.com/', '_blank');
  417. }, 'openInvalidHost');
  418. createActionButton('Missing Local File', function () {
  419. doOpen('nonexistent.html', '_blank');
  420. }, 'openInvalidMissing');
  421. //CSS / JS injection
  422. createActionButton('Original Document', function () {
  423. doOpen(injecthtml, '_blank');
  424. }, 'openOriginalDocument');
  425. createActionButton('CSS File Injection', function () {
  426. openWithStyle(injecthtml, injectcss);
  427. }, 'openCSSInjection');
  428. createActionButton('CSS File Injection (callback)', function () {
  429. openWithStyle(injecthtml, injectcss, true);
  430. }, 'openCSSInjectionCallback');
  431. createActionButton('CSS Literal Injection', function () {
  432. openWithStyle(injecthtml);
  433. }, 'openCSSLiteralInjection');
  434. createActionButton('CSS Literal Injection (callback)', function () {
  435. openWithStyle(injecthtml, null, true);
  436. }, 'openCSSLiteralInjectionCallback');
  437. createActionButton('Script File Injection', function () {
  438. openWithScript(injecthtml, injectjs);
  439. }, 'openScriptInjection');
  440. createActionButton('Script File Injection (callback)', function () {
  441. openWithScript(injecthtml, injectjs, true);
  442. }, 'openScriptInjectionCallback');
  443. createActionButton('Script Literal Injection', function () {
  444. openWithScript(injecthtml);
  445. }, 'openScriptLiteralInjection');
  446. createActionButton('Script Literal Injection (callback)', function () {
  447. openWithScript(injecthtml, null, true);
  448. }, 'openScriptLiteralInjectionCallback');
  449. //Open hidden
  450. createActionButton('Create Hidden', function () {
  451. openHidden('https://www.google.co.uk', true);
  452. }, 'openHidden');
  453. createActionButton('Show Hidden', function () {
  454. showHidden();
  455. }, 'showHidden');
  456. createActionButton('Close Hidden', function () {
  457. closeHidden();
  458. }, 'closeHidden');
  459. createActionButton('google.co.uk Not Hidden', function () {
  460. openHidden('https://www.google.co.uk', false);
  461. }, 'openHiddenShow');
  462. //Clearing cache
  463. createActionButton('Clear Browser Cache', function () {
  464. doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes');
  465. }, 'openClearCache');
  466. createActionButton('Clear Session Cache', function () {
  467. doOpen('https://www.google.co.uk', '_blank', 'clearsessioncache=yes');
  468. }, 'openClearSessionCache');
  469. //Video tag
  470. createActionButton('Remote Video', function () {
  471. doOpen(videohtml, '_blank');
  472. }, 'openRemoteVideo');
  473. //Local With Anchor Tag
  474. createActionButton('Anchor1', function () {
  475. doOpen(localhtml + '#bogusanchor', '_blank');
  476. }, 'openAnchor1');
  477. createActionButton('Anchor2', function () {
  478. doOpen(localhtml + '#anchor2', '_blank');
  479. }, 'openAnchor2');
  480. };