Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3340)

Unified Diff: chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js

Issue 274123003: Enabling alwaysOnTop should fail to create app windows if the permission is lacking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/app_window/app_window_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js b/chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js
index 1d49d1cd20184e7c01ca9460371d6cab43c0341b..0b63b039bbd35c4f62725af3375e2ba97d719201 100644
--- a/chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js
+++ b/chrome/test/data/extensions/platform_apps/windows_api_always_on_top/no_permissions/background.js
@@ -3,29 +3,22 @@
// found in the LICENSE file.
var callbackPass = chrome.test.callbackPass;
+var callbackFail = chrome.test.callbackFail;
-function testAlwaysOnTop(testId, value) {
- var options = {
- id: testId,
- alwaysOnTop: value
- };
-
+function setAlwaysOnTop(value) {
chrome.app.window.create('index.html',
- options,
+ {},
callbackPass(function(win) {
- // Check that isAlwaysOnTop() returns false because the manifest did not
- // specify the "app.window.alwaysOnTop" permission.
- chrome.test.assertEq(false, win.isAlwaysOnTop());
+ chrome.test.assertFalse(win.isAlwaysOnTop());
- // Attempt to use setAlwaysOnTop() to change the property. But this should
- // also fail.
+ // Attempt to use setAlwaysOnTop() to change the property.
win.setAlwaysOnTop(value);
- // setAlwaysOnTop is synchronous in the browser, so send an async request to
- // ensure we get the updated value of isAlwaysOnTop.
- chrome.test.waitForRoundTrip("msg", callbackPass(function(platformInfo) {
- // Check that isAlwaysOnTop() returns false.
- chrome.test.assertEq(false, win.isAlwaysOnTop());
+ // setAlwaysOnTop() is synchronous in the browser, so send an async request
+ // to ensure we get the updated value of isAlwaysOnTop().
+ chrome.test.waitForRoundTrip("", callbackPass(function() {
+ // Check that isAlwaysOnTop() always returns false.
+ chrome.test.assertFalse(win.isAlwaysOnTop());
win.contentWindow.close();
}));
@@ -35,14 +28,43 @@ function testAlwaysOnTop(testId, value) {
chrome.app.runtime.onLaunched.addListener(function() {
chrome.test.runTests([
- // Try to enable alwaysOnTop on window creation and after window creation.
- function testAlwaysOnTopEnable() {
- testAlwaysOnTop('testAlwaysOnTopEnable', true);
+ // Attempting to create an alwaysOnTop window without the permission should
+ // fail to create a window.
+ function testCreateAlwaysOnTopEnabled() {
+ var options = {
+ alwaysOnTop: true
+ };
+
+ chrome.app.window.create(
+ 'index.html', options,
+ callbackFail('The "app.window.alwaysOnTop" permission is required.'));
+ },
+
+ // Setting the alwaysOnTop property to false without the permission should
+ // still result in a window being created.
+ function testCreateAlwaysOnTopDisabled() {
+ var options = {
+ alwaysOnTop: false
+ };
+
+ chrome.app.window.create('index.html',
+ options,
+ callbackPass(function(win) {
+ chrome.test.assertFalse(win.isAlwaysOnTop());
+ win.contentWindow.close();
+ }));
+ },
+
+ // Enabling the alwaysOnTop property after window creation without the
+ // permission should fail.
+ function testSetAlwaysOnTopEnabled() {
+ setAlwaysOnTop(true);
},
- // Try to disable alwaysOnTop on window creation and after window creation.
- function testAlwaysOnTopDisable() {
- testAlwaysOnTop('testAlwaysOnTopDisable', false);
+ // Disabling the alwaysOnTop property after window creation without the
+ // permission should not change the property.
+ function testSetAlwaysOnTopDisabled() {
+ setAlwaysOnTop(false);
}
]);
« no previous file with comments | « chrome/browser/extensions/api/app_window/app_window_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698