├── .gitignore ├── docs └── images │ ├── home-screen.png │ ├── developer-mode.png │ ├── pick-manifest.png │ ├── load-unpacked-extension.png │ ├── successfull-installation.png │ └── installed-extensions-settings.png ├── api-test-extension ├── icons │ ├── icon16.png │ ├── icon19.png │ ├── icon48.png │ ├── icon80.png │ └── icon128.png ├── src │ ├── browser_action │ │ ├── popup.html │ │ ├── bg.js │ │ ├── run_test.js │ │ ├── browser_action.html │ │ └── browser_action.js │ ├── tests │ │ ├── tabs_bg.js │ │ ├── content_scripts_bg.js │ │ ├── web_navigation.js │ │ ├── content_scripts.js │ │ ├── top_sites.js │ │ ├── storage.js │ │ ├── browser_action.js │ │ ├── popup_scripts.js │ │ ├── notifications.js │ │ ├── alarms.js │ │ ├── idle.js │ │ ├── common.js │ │ ├── history.js │ │ ├── browsing_data.js │ │ ├── windows.js │ │ ├── context_menus.js │ │ ├── web_request.js │ │ ├── sessions.js │ │ ├── cookies.js │ │ ├── downloads.js │ │ ├── bookmarks.js │ │ ├── extension.js │ │ ├── privacy.js │ │ ├── content_settings.js │ │ └── tabs.js │ └── APITest │ │ └── test.js ├── manifest.json └── css │ └── styles.css └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | *.DS_Store -------------------------------------------------------------------------------- /docs/images/home-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/home-screen.png -------------------------------------------------------------------------------- /docs/images/developer-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/developer-mode.png -------------------------------------------------------------------------------- /docs/images/pick-manifest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/pick-manifest.png -------------------------------------------------------------------------------- /api-test-extension/icons/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/api-test-extension/icons/icon16.png -------------------------------------------------------------------------------- /api-test-extension/icons/icon19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/api-test-extension/icons/icon19.png -------------------------------------------------------------------------------- /api-test-extension/icons/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/api-test-extension/icons/icon48.png -------------------------------------------------------------------------------- /api-test-extension/icons/icon80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/api-test-extension/icons/icon80.png -------------------------------------------------------------------------------- /api-test-extension/icons/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/api-test-extension/icons/icon128.png -------------------------------------------------------------------------------- /docs/images/load-unpacked-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/load-unpacked-extension.png -------------------------------------------------------------------------------- /docs/images/successfull-installation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/successfull-installation.png -------------------------------------------------------------------------------- /docs/images/installed-extensions-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yandex/browser-extensions/master/docs/images/installed-extensions-settings.png -------------------------------------------------------------------------------- /api-test-extension/src/browser_action/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Popup Scripts 6 | 7 | 8 | 9 | 10 | 11 |

Wait...

12 | 13 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/tabs_bg.js: -------------------------------------------------------------------------------- 1 | let msg = { data: "msg" }; 2 | let res = { data: "response" }; 3 | 4 | let listener = function (response, sender, sendResponse) { 5 | if (response.data === msg.data) { 6 | sendResponse(res); 7 | chrome.runtime.onMessage.removeListener(listener); 8 | } else { 9 | sendResponse(true); 10 | } 11 | }; 12 | 13 | chrome.runtime.onMessage.addListener(listener); -------------------------------------------------------------------------------- /api-test-extension/src/tests/content_scripts_bg.js: -------------------------------------------------------------------------------- 1 | let msg = { data: "msg" }; 2 | let res = { data: "response" }; 3 | 4 | let listener = function (response, sender, sendResponse) { 5 | if (response.data === msg.data) { 6 | sendResponse(res); 7 | chrome.runtime.onMessage.removeListener(listener); 8 | } else { 9 | sendResponse(true); 10 | } 11 | }; 12 | 13 | chrome.runtime.onMessage.addListener(listener); -------------------------------------------------------------------------------- /api-test-extension/src/tests/web_navigation.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var web_navigation_test = new TestSet() 4 | .require("[Method Exists] webNavigation", methodExists(chrome, 'webNavigation'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] getFrame", methodExists(chrome.webNavigation, 'getFrame'), { hideOnSuccess: true }) 7 | .require("[Method Call] getFrame", methodCall(chrome.webNavigation, 'getFrame', { 8 | tabId: 0, 9 | processId: 0, 10 | frameId: 0 11 | }, () => {})) 12 | 13 | .require("[Method Exists] getAllFrames", methodExists(chrome.webNavigation, 'getAllFrames'), 14 | { hideOnSuccess: true }) 15 | .require("[Method Call] getAllFrames", methodCall(chrome.webNavigation, 'getAllFrames', {tabId: 0}, () => {})); 16 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/content_scripts.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var content_scripts = new TestSet() 4 | .require("[Content Script] {Internet connection required}", () => new Promise((resolve, reject) => { 5 | let msg = { data: "msg" }; 6 | let res = { data: "response" }; 7 | 8 | chrome.tabs.create({ 9 | url: "https://ya.ru/", 10 | selected: false 11 | }, tab => { 12 | setTimeout(() => { 13 | chrome.tabs.sendMessage(tab.id, msg, response => { 14 | if (response.data === res.data) { 15 | resolve(''); 16 | } else { 17 | reject("Sent and received responses are different") 18 | } 19 | 20 | chrome.tabs.remove(tab.id); 21 | }); 22 | }, 2700); 23 | }) 24 | }), { async: true }); 25 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/top_sites.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var top_sites_test = new TestSet() 4 | .require("[Method Exists] topSites", methodExists(chrome, 'topSites'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] get", methodExists(chrome.topSites, 'get'), { hideOnSuccess: true }) 7 | .require("[Method Call] get", methodCall(chrome.topSites, 'get', () => {})) 8 | 9 | .suggest("[Check Top Sites] find substring \"yandex\" in the top sites list " + 10 | "(keep in mind that tableau and top sites aren't the same things)", () => { 11 | return new Promise((resolve, reject) => { 12 | chrome.topSites.get(arr => { 13 | for (let site of arr) { 14 | if (site.url.indexOf('yandex') != -1) { 15 | resolve(''); 16 | return; 17 | } 18 | } 19 | reject("*yandex* not found in the top sites list") 20 | }) 21 | }); 22 | }, { async: true }); 23 | -------------------------------------------------------------------------------- /api-test-extension/src/browser_action/bg.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | let runtimeMsgFromPopup = { data: 'runtime_msg_from_popup' }; // Incoming 4 | let runtimeMsgToTab = { data: 'runtime_msg_from_background'}; // Outgoing 5 | 6 | let listener = function (response, sender, sendResponse) { 7 | if (response.data == runtimeMsgFromPopup.data) { 8 | sendResponse('Background'); 9 | chrome.runtime.sendMessage(runtimeMsgToTab, response => { 10 | if (response != 'Tab') { 11 | failManualTest( 12 | 'popup-scripts-test', 13 | "Message received by the background from the tab differs from expected" 14 | ) 15 | } else { 16 | chrome.runtime.onMessage.removeListener(listener); 17 | } 18 | }); 19 | } 20 | }; 21 | 22 | chrome.runtime.onMessage.addListener(listener); 23 | 24 | document.addEventListener("DOMContentLoaded", () => { 25 | let div = document.createElement("div"); 26 | div.setAttribute('id', 'bg-div-elem'); 27 | 28 | document.querySelector('body').appendChild(div); 29 | }); 30 | -------------------------------------------------------------------------------- /api-test-extension/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "version": "0.1.9", 4 | "name": "Browser API Test", 5 | "description": "Tests Chrome API for browser extensions.", 6 | "icons": { 7 | "16": "icons/icon16.png", 8 | "128": "icons/icon128.png" 9 | }, 10 | "browser_action": { 11 | "default_title": "", 12 | "default_icon": "icons/icon19.png", 13 | "default_popup": "src/browser_action/popup.html" 14 | }, 15 | "background": { 16 | "scripts": ["src/browser_action/bg.js"] 17 | }, 18 | "content_scripts": [ 19 | { 20 | "matches": [ 21 | "http://ya.ru/", 22 | "https://ya.ru/" 23 | ], 24 | "js": ["src/tests/content_scripts_bg.js"] 25 | } 26 | ], 27 | "commands": {}, 28 | "permissions": [ 29 | "tabs", 30 | "contextMenus", 31 | "cookies", 32 | "http://*/*", "https://*/*", 33 | "idle", 34 | "notifications", 35 | "bookmarks", 36 | "browsingData", 37 | "history", 38 | "downloads", 39 | "idle", 40 | "notifications", 41 | "topSites", 42 | "sessions", 43 | "webNavigation", 44 | "storage", 45 | "webRequest", 46 | "privacy", 47 | "alarms", 48 | "contentSettings" 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/storage.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var storage_test = new TestSet() 4 | .require("[Method Exists] storage", methodExists(chrome, 'storage'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] local", methodExists(chrome.storage, 'local'), { hideOnSuccess: true }) 7 | 8 | .require("[Method Exists] set", methodExists(chrome.storage.local, 'set'), { hideOnSuccess: true }) 9 | .require("[Method Call] set", methodCall(chrome.storage.local, 'set', {}, () => {})) 10 | 11 | .require("[Method Exists] get", methodExists(chrome.storage.local, 'get'), { hideOnSuccess: true }) 12 | .require("[Method Call] get", methodCall(chrome.storage.local, 'get', '', () => {})) 13 | 14 | .require("[Method Exists] remove", methodExists(chrome.storage.local, 'remove'), { hideOnSuccess: true }) 15 | .require("[Method Call] remove", methodCall(chrome.storage.local, 'remove', '', () => {})) 16 | 17 | .require("[Set-Get-Remove]", () => new Promise((resolve, reject) => { 18 | let key = 'storage_local_test'; 19 | chrome.storage.local.set({ 20 | storage_local_test: "test" 21 | }, () => { 22 | chrome.storage.local.get(key, items => { 23 | if (items[key] == "test") { 24 | chrome.storage.local.remove(key, () => { 25 | chrome.storage.local.get(key, items => { 26 | if (items[key] === undefined) { 27 | resolve(''); 28 | } else { 29 | reject("Item wasn't removed") 30 | } 31 | }); 32 | }); 33 | } else { 34 | reject("Item set but not found") 35 | } 36 | }); 37 | }); 38 | }), { async: true }); -------------------------------------------------------------------------------- /api-test-extension/src/tests/browser_action.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var browser_action_test = new TestSet() 4 | .require("[Method Exists] browserAction", methodExists(chrome, 'browserAction'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] setTitle", methodExists(chrome.browserAction, 'setTitle'), { hideOnSuccess: true }) 7 | .require("[Method Call] setTitle", methodCall(chrome.browserAction, 'setTitle', {title: "BrowserActionTest"})) 8 | 9 | .require("[Method Exists] getTitle", methodExists(chrome.browserAction, 'getTitle'), { hideOnSuccess: true }) 10 | .require("[Method Call] getTitle", methodCall(chrome.browserAction, 'getTitle', {}, () => {})) 11 | 12 | .require("[Set-Get Title]", () => { 13 | return new Promise((resolve, reject) => { 14 | chrome.browserAction.getTitle({}, title => { 15 | if (title == "BrowserActionTest") { 16 | resolve(''); 17 | } else { 18 | reject("Title incorrect"); 19 | } 20 | }) 21 | }); 22 | }, { async: true }) 23 | 24 | .require("[Method Exists] setIcon", methodExists(chrome.browserAction, 'setIcon'), { hideOnSuccess: true }) 25 | .require("[Method Call] setIcon", methodCall(chrome.browserAction, 'setIcon', {path: ""}, () => {})) 26 | 27 | .require("[Method Exists] setPopup", methodExists(chrome.browserAction, 'setPopup'), { hideOnSuccess: true }) 28 | 29 | .require("[Method Exists] getPopup", methodExists(chrome.browserAction, 'getPopup'), { hideOnSuccess: true }) 30 | .require("[Method Call] getPopup", () => { 31 | return new Promise((resolve, reject) => { 32 | chrome.browserAction.getPopup({}, result => { 33 | if (typeof result === 'string' && 34 | result.indexOf("src/browser_action/popup.html") != -1) { 35 | resolve(''); 36 | } else { 37 | reject("Popup incorrect"); 38 | } 39 | }) 40 | }); 41 | }, { async: true }); 42 | -------------------------------------------------------------------------------- /api-test-extension/src/browser_action/run_test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | chrome.tabs.getSelected(tab => { 4 | if (tab.url.indexOf("chrome-extension://") == -1) { 5 | let newURL = chrome.extension.getURL('src/browser_action/browser_action.html'); 6 | chrome.tabs.update({ url: newURL }); 7 | } else { 8 | let $tmp = $('h3'); 9 | $tmp.text("Sending message to tab..."); 10 | 11 | const TEST_NAME = 'popup-scripts-test'; 12 | 13 | let tabsMsgToPopup = { data: 'tabs_msg_from_popup' }; // Outgoing 14 | let msgFromTab = { data: 'msg_from_tab' }; // Incoming 15 | let runtimeMsgToTab = { data: 'runtime_msg_from_popup' }; // Outgoing 16 | 17 | chrome.tabs.getSelected(tab => { 18 | chrome.tabs.sendMessage(tab.id, tabsMsgToPopup, response => { 19 | if (response != 'Tab') { 20 | failManualTest( 21 | TEST_NAME, 22 | "Message received by popup from tab differs from expected" 23 | ); 24 | } 25 | }); 26 | }); 27 | 28 | let responses = new Set(['Tab', 'Background']); 29 | 30 | let listener = function (response, sender, sendResponse) { 31 | if (response.data == msgFromTab.data) { 32 | sendResponse('Popup'); 33 | chrome.runtime.sendMessage(runtimeMsgToTab, response => { 34 | if (response in responses) { 35 | responses.delete(response.data); 36 | 37 | if (!responses.size) { 38 | chrome.runtime.onMessage.removeListener(listener); 39 | } 40 | } else { 41 | failManualTest( 42 | TEST_NAME, 43 | "Message received by the popup from the tab differs from expected" 44 | ) 45 | } 46 | }); 47 | } 48 | }; 49 | 50 | chrome.runtime.onMessage.addListener(listener); 51 | } 52 | }); 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to install extensions 2 | - Install Yandex Browser from Google Play (https://play.google.com/store/apps/details?id=com.yandex.browser) 3 | 4 | ## What's new 5 | 2016-11-14 6 | - Added tests for alarms API. 7 | 8 | 2016-11-10 9 | - Added tests for privacy API. 10 | 11 | 2016-09-07 (build 16.9.0.886) 12 | - We have published Yandex Browser Alpha with extensions support. You can download it from Google Play: 13 | https://play.google.com/store/apps/details?id=com.yandex.browser.alpha 14 | 15 | 2016-08-24 (build 16.7.211760) 16 | - Fix Issue #1: Action menu doesn't dynamically resize to content. 17 | 18 | 2016-08-16 19 | - Add more permissions (for screenshot mostly) 20 | - Update UI 21 | 22 | 2016-08-11 23 | - Report generated by Browser API Test extension 24 | 25 | 2016-08-07 26 | - add tabCapture and desktopCapture permissions support 27 | - add activeTab permission support 28 | 29 | 2016-08-05 30 | - Implement chrome.tabs.remove support 31 | - Implement chomre.tabs events 32 | 33 | ## Custom Extension Install In Developer Mode 34 | 35 | ### 1. Copy an unzipped folder with an extension source code to your mobile device 36 | 37 | ### 2. Type browser://extensions/ 38 | 39 | 40 | ### 3. Turn on the Developer Mode by checking the box 41 | 42 | 43 | ### 4. Tap "Load unpacked extension" 44 | 45 | 46 | ### 5. Find your extension folder and pick manifest.json 47 | 48 | 49 | 50 | ## Install From Store 51 | 52 | 1) Using the "Settings -> Extensions -> Opera Store" or "Settings -> Extensions -> Google Chrome Webstore" menu open the store page 53 | 54 | 2) Find the extension and add them to browser 55 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/popup_scripts.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var popup_scripts = new TestSet() 4 | .require('[empty]', () => '', { hideOnSuccess: true }) 5 | .manual('popup-scripts-test', "Click on extension button again") 6 | .report_ready(() => { 7 | const TEST_NAME = 'popup-scripts-test'; 8 | 9 | let tabsMsgFromPopup = { data: 'tabs_msg_from_popup' }; // Incoming 10 | let msgToPopup = { data: 'msg_from_tab' }; // Outgoing 11 | let runtimeMsgFromPopup = { data: 'runtime_msg_from_popup' }; // Incoming 12 | let runtimeMsgFromBackground = { data: 'runtime_msg_from_background'}; // Incoming 13 | 14 | // Here tab message is chrome.tabs.sendMessage() and 15 | // runtime message is chrome.tabs.sendMessage() : 16 | 17 | // 1. Activated popup sends initial tab message to tab. 18 | // 2. Tab receives initial message and sends broadcast runtime message and popup should receive it. 19 | // 3. Then popup sends broadcast runtime message to tab and awaits for callback. 20 | // 4. Background also receives broadcast message from popup. 21 | // 5. Then background sends broadcast runtime message to tab. 22 | // 6. If tab received msg from background the test is done. 23 | 24 | let listener = function (response, sender, sendResponse) { 25 | if (response.data == tabsMsgFromPopup.data) { 26 | sendResponse('Tab'); 27 | chrome.runtime.sendMessage(msgToPopup, response => { 28 | if (response != 'Popup') { 29 | failManualTest( 30 | TEST_NAME, 31 | "Message received by the tab from the popup differs from expected" 32 | ) 33 | } 34 | }); 35 | } else if (response.data == runtimeMsgFromPopup.data) { 36 | sendResponse('Tab'); 37 | } else if (response.data == runtimeMsgFromBackground.data) { 38 | sendResponse('Tab'); 39 | doneManualTest('popup-scripts-test'); 40 | chrome.runtime.onMessage.removeListener(listener); 41 | } 42 | }; 43 | 44 | chrome.runtime.onMessage.addListener(listener); 45 | }); 46 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/notifications.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var notifications_test = new TestSet() 4 | .require("[Method Exists] notifications", methodExists(chrome, 'notifications'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] create", methodExists(chrome.notifications, 'create'), { hideOnSuccess: true }) 7 | .require("[Method Call] create", methodCall(chrome.notifications, 'create', { 8 | type: 'basic', 9 | title: "", 10 | iconUrl: "", 11 | message: "" 12 | }, () => {})) 13 | 14 | .require("[Method Exists] update", methodExists(chrome.notifications, 'update'), { hideOnSuccess: true }) 15 | .require("[Method Call] update", methodCall(chrome.notifications, 'update', "", {}, () => {})) 16 | 17 | .require("[Method Exists] clear", methodExists(chrome.notifications, 'clear'), { hideOnSuccess: true }) 18 | .require("[Method Call] clear", methodCall(chrome.notifications, 'clear', "", () => {})) 19 | 20 | .require("[Method Exists] ", methodExists(chrome.notifications, 'getAll'), { hideOnSuccess: true }) 21 | .require("[Method Call] ", methodCall(chrome.notifications, 'getAll', () => {})) 22 | 23 | .require("[Method Exists] ", methodExists(chrome.notifications, 'getPermissionLevel'), { hideOnSuccess: true }) 24 | .require("[Method Call] ", methodCall(chrome.notifications, 'getPermissionLevel', () => {})) 25 | 26 | .manual('notification-test', "[Test Notification] Press Start and then click on appeared notification" + 27 | " ") 28 | .report_ready(() => { 29 | $('#notification-test-button').click(() => { 30 | chrome.notifications.create({ 31 | type: 'basic', 32 | iconUrl: "/icons/icon80.png", 33 | title: "Test", 34 | message: "Test" 35 | }, id => { 36 | let listener = function (id_) { 37 | if (id == id_) { 38 | doneManualTest('notification-test'); 39 | chrome.notifications.onClicked.removeListener(listener); 40 | } 41 | }; 42 | 43 | chrome.notifications.onClicked.addListener(listener); 44 | }); 45 | }) 46 | }); 47 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/alarms.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var alarms_test = new TestSet() 4 | .require("[Method Exists]", methodExists(chrome, "alarms"), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] create", methodExists(chrome.alarms, 'create'), { hideOnSuccess: true }) 7 | .require("[Method Call] create", methodCall(chrome.alarms, 'create', "", {})) 8 | 9 | .require("[Method Exists] get", methodExists(chrome.alarms, 'get'), { hideOnSuccess: true }) 10 | .require("[Method Call] get", methodCall(chrome.alarms, 'get', "", () => {})) 11 | 12 | .require("[Method Exists] getAll", methodExists(chrome.alarms, 'getAll'), { hideOnSuccess: true }) 13 | .require("[Method Call] getAll", methodCall(chrome.alarms, 'getAll', () => {})) 14 | 15 | .require("[Method Exists] clear", methodExists(chrome.alarms, 'clear'), { hideOnSuccess: true }) 16 | .require("[Method Call] clear", methodCall(chrome.alarms, 'clear')) 17 | 18 | .require("[Method Exists] clearAll", methodExists(chrome.alarms, 'clearAll'), { hideOnSuccess: true }) 19 | .require("[Method Call] clearAll", methodCall(chrome.alarms, 'clearAll')) 20 | 21 | .manual('check-alarm-delay', "[Create Alarm and Delayed Fire] click on Start button to create alarm," + 22 | " test usually passes during 1 minute (but can be delayed)" + 23 | " ") 24 | 25 | .manual('check-alarm-period', "[Periodic Fire] usually passes " + 26 | "during 1 minute after Delayed Fire test is done") 27 | 28 | .report_ready(() => { 29 | $('#check-alarm-button').click(() => { 30 | chrome.alarms.create("APITestAlarm", { 31 | delayInMinutes: 1, 32 | periodInMinutes: 1 33 | }); 34 | 35 | let listener = function (alarm) { 36 | if (alarm.name == "APITestAlarm") { 37 | if ($('#check-alarm-delay').data('status') != "done") { 38 | doneManualTest('check-alarm-delay'); 39 | } else { 40 | doneManualTest('check-alarm-period'); 41 | chrome.alarms.onAlarm.removeListener(listener); 42 | chrome.alarms.clear("APITestAlarm") 43 | } 44 | } 45 | }; 46 | 47 | chrome.alarms.onAlarm.addListener(listener); 48 | }) 49 | }); 50 | -------------------------------------------------------------------------------- /api-test-extension/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #f2f2f2; 3 | font-family: Arial, Helvetica, sans-serif; 4 | font-size: 12px; 5 | } 6 | 7 | .title { 8 | padding: 0 10px 0 10px; 9 | margin-bottom: 20px; 10 | } 11 | 12 | .report-container { 13 | width: 100%; 14 | } 15 | 16 | .test-set-container { 17 | padding: 0 10px 0 10px; 18 | margin-bottom: 30px; 19 | } 20 | 21 | .auto-test-set-title { 22 | min-height: 40px; 23 | min-width: 240px; 24 | padding-left: 10px; 25 | line-height: 40px; 26 | font-size: 1.6em; 27 | border: #808080 2px solid; 28 | } 29 | 30 | .manual-test-set-title { 31 | min-height: 40px; 32 | line-height: 40px; 33 | font-size: 1.6em; 34 | min-width: 240px; 35 | padding-left: 10px; 36 | margin-top: -2px; 37 | border: gray 2px solid; 38 | background-color: #337ab7; 39 | } 40 | 41 | .auto-tests-list { 42 | border: gray 2px solid; 43 | border-bottom-width: 1px; 44 | margin-top: -2px; 45 | } 46 | 47 | .manual-tests-list { 48 | border: gray 2px solid; 49 | border-bottom-width: 1px; 50 | margin-top: -2px 51 | } 52 | 53 | .auto-test-item { 54 | padding-left: 10px; 55 | min-height: 32px; 56 | line-height: 32px; 57 | font-size: 1.4em; 58 | } 59 | 60 | .manual-test-item { 61 | padding-left: 10px; 62 | min-height: 32px; 63 | line-height: 32px; 64 | font-size: 1.4em; 65 | background-color: #d9edf7; 66 | color: #333; 67 | } 68 | 69 | .line { 70 | height: 1px; 71 | background-color: gray 72 | } 73 | 74 | .button-red, #history-delete-all-button { 75 | font-size: 1em; 76 | background-color: #c52222; 77 | color: white; 78 | border: 1px grey solid; 79 | cursor: pointer; 80 | } 81 | 82 | .button-blue, #check-idle-button, #check-lock-button { 83 | font-size: 1em; 84 | background-color: #2323c4; 85 | color: white; 86 | border: 1px grey solid; 87 | cursor: pointer; 88 | } 89 | 90 | .button-green { 91 | font-size: 1em; 92 | background-color: #23c223; 93 | color: white; 94 | border: 1px #006400 solid; 95 | cursor: pointer; 96 | } 97 | 98 | .title-container { 99 | display: inline-block; 100 | width: 180px; 101 | margin-right: 10px; 102 | } 103 | 104 | .save-report-container { 105 | display: inline-block; 106 | float: right; 107 | margin: 0.7em 0 0 0; 108 | font-size: 1.4em; 109 | } 110 | -------------------------------------------------------------------------------- /api-test-extension/src/tests/idle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var idle_test = new TestSet() 4 | .require("[Method Exists] idle", methodExists(chrome, 'idle'), { hideOnSuccess: true }) 5 | 6 | .require("[Method Exists] queryState", methodExists(chrome.idle, 'queryState'), { hideOnSuccess: true }) 7 | .require("[Method Call] queryState", methodCall(chrome.idle, 'queryState', 60, () => {})) 8 | 9 | .require("[Method Exists] setDetectionInterval", methodExists(chrome.idle, 'setDetectionInterval'), 10 | { hideOnSuccess: true }) 11 | .require("[Method Call] setDetectionInterval", methodCall(chrome.idle, 'setDetectionInterval', 60)) 12 | 13 | .require("[Check active state]", () => { 14 | return new Promise((resolve, reject) => { 15 | chrome.idle.queryState(10000, state => { 16 | if (state == 'active') { 17 | resolve(''); 18 | } else { 19 | reject("Expected state is active, actual state: " + state); 20 | } 21 | }) 22 | }) 23 | }, { async: true }) 24 | 25 | .manual('check-idle', "[Check idle state] click on Start button, stay still until end of the test (approx. 15sec)" + 26 | " ") 27 | .manual('check-lock', "[Check lock state] click on Start button, lock your device, return after 20sec" + 28 | " ") 29 | 30 | .report_ready(() => { 31 | $('#check-idle-button').click(() => { 32 | let min_allowed_time_in_seconds = 15; 33 | setTimeout(() => { 34 | chrome.idle.queryState(min_allowed_time_in_seconds, state => { 35 | if (state == 'idle') { 36 | doneManualTest('check-idle'); 37 | } else { 38 | failManualTest('check-idle', "Expected state: idle, actual state: " + state); 39 | } 40 | }); 41 | }, (min_allowed_time_in_seconds + 2) * 1000); 42 | }); 43 | 44 | $('#check-lock-button').click(() => { 45 | let test_time_in_seconds = 20; 46 | setTimeout(() => { 47 | chrome.idle.queryState(10000, state => { 48 | if (state == 'locked') { 49 | doneManualTest('check-lock'); 50 | } else { 51 | failManualTest('check-lock', "Expected state: locked, actual state: " + state); 52 | } 53 | }); 54 | }, test_time_in_seconds * 1000); 55 | }); 56 | }); -------------------------------------------------------------------------------- /api-test-extension/src/browser_action/browser_action.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 |
41 |

Browser API Tests

42 |
43 |
44 | 45 | 46 |
47 |
48 |
49 |
50 | 51 | -------------------------------------------------------------------------------- /api-test-extension/src/browser_action/browser_action.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(() => { 4 | let $body = $('body'); 5 | 6 | let test = new APITest(); 7 | 8 | test 9 | .addTestSet("Tabs", tabs_test) 10 | .addTestSet("Cookies", cookies_test) 11 | .addTestSet("Browser Action", browser_action_test) 12 | .addTestSet("Context Menus", context_menus_test) 13 | .addTestSet("Bookmarks", bookmarks_test) 14 | .addTestSet("History", history_test) 15 | .addTestSet("Browsing Data", browsing_data_test) 16 | .addTestSet("Downloads", downloads_test) 17 | .addTestSet("Idle", idle_test) 18 | .addTestSet("Notifications", notifications_test) 19 | .addTestSet("Top Sites", top_sites_test) 20 | .addTestSet("Sessions", sessions_test) 21 | .addTestSet("Web Navigation", web_navigation_test) 22 | .addTestSet("Storage", storage_test) 23 | .addTestSet("Web Request", web_request_test) 24 | .addTestSet("Windows", windows_test) 25 | .addTestSet("Privacy", privacy_test) 26 | .addTestSet("Alarms", alarms_test) 27 | .addTestSet("Content Settings", content_settings_test) 28 | .addTestSet("Content Scripts", content_scripts) 29 | .addTestSet("Popup Scripts", popup_scripts) 30 | .addTestSet("Extension", extension_test) 31 | ; // -- test -- // 32 | 33 | test.runAll(); 34 | test.htmlReport().then(res => $body.append(res)).then(() => { 35 | let $t = $(".auto-test-set-title, .manual-test-set-title"); 36 | 37 | $t.css('cursor', 'pointer').click(function () { 38 | $(this).next().toggle('fast'); 39 | }); 40 | 41 | test.fns.reduce((prev, curr) => { 42 | return prev.then(() => new Promise(resolve => { 43 | resolve(curr()); 44 | })); 45 | }, Promise.resolve()).then(() => {}); 46 | 47 | $('#save-report-button') 48 | .toggle('fast') 49 | .click(function () { 50 | $.ajax({ url: "/css/styles.css" }).done((css) => { 51 | let $body = $('html').clone(); 52 | 53 | $body.find('button').detach(); 54 | $body.find('#save-report-link').detach(); 55 | $body.find('script').detach(); 56 | $body.find(".auto-test-set-title, .manual-test-set-title").css('cursor', 'auto'); 57 | $('