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

Unified Diff: chrome/test/data/extensions/platform_apps/restrictions/main.js

Issue 120733003: Feature detection-friendly restrictions for packaged apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated broken test. Created 7 years 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
Index: chrome/test/data/extensions/platform_apps/restrictions/main.js
diff --git a/chrome/test/data/extensions/platform_apps/restrictions/main.js b/chrome/test/data/extensions/platform_apps/restrictions/main.js
index 0176ff1a1eb1b68ca39a1296003e859fa9380c5f..2646727af12610c19aaed24205ca4e3daff2e861 100644
--- a/chrome/test/data/extensions/platform_apps/restrictions/main.js
+++ b/chrome/test/data/extensions/platform_apps/restrictions/main.js
@@ -33,23 +33,23 @@ chrome.test.runTests([
assertThrowsError(document.write);
assertThrowsError(document.writeln);
- assertThrowsError(function() {document.all;});
- assertThrowsError(function() {document.bgColor;});
- assertThrowsError(function() {document.fgColor;});
- assertThrowsError(function() {document.alinkColor;});
- assertThrowsError(function() {document.linkColor;});
- assertThrowsError(function() {document.vlinkColor;});
+ assertEq('undefined', typeof(document.all));
+ assertEq('undefined', typeof(document.bgColor));
+ assertEq('undefined', typeof(document.fgColor));
+ assertEq('undefined', typeof(document.alinkColor));
+ assertEq('undefined', typeof(document.linkColor));
+ assertEq('undefined', typeof(document.vlinkColor));
succeed();
},
function testHistory() {
- // These are replaced by wrappers that throws exceptions.
- assertThrowsError(history.back);
- assertThrowsError(history.forward);
- assertThrowsError(function() {history.length;});
+ // Accessing these logs warnings to the console.
+ assertEq('undefined', typeof(history.back));
+ assertEq('undefined', typeof(history.forward));
+ assertEq('undefined', typeof(history.length));
- // These are part of the HTML5 History API that is feature detected, so we
+ // These are part of the HTML5 History API that are feature detected, so we
// remove them altogether, allowing apps to have fallback behavior.
chrome.test.assertFalse('pushState' in history);
chrome.test.assertFalse('replaceState' in history);
@@ -59,30 +59,30 @@ chrome.test.runTests([
},
function testWindowFind() {
- assertThrowsError(Window.prototype.find);
- assertThrowsError(window.find);
- assertThrowsError(find);
+ assertEq('undefined', typeof(Window.prototype.find('needle')));
+ assertEq('undefined', typeof(window.find('needle')));
+ assertEq('undefined', typeof(find('needle')));
succeed();
},
function testWindowAlert() {
- assertThrowsError(Window.prototype.alert);
- assertThrowsError(window.alert);
- assertThrowsError(alert);
+ assertEq('undefined', typeof(Window.prototype.alert()));
+ assertEq('undefined', typeof(window.alert()));
+ assertEq('undefined', typeof(alert()));
succeed();
},
function testWindowConfirm() {
- assertThrowsError(Window.prototype.confirm);
- assertThrowsError(window.confirm);
- assertThrowsError(confirm);
+ assertEq('undefined', typeof(Window.prototype.confirm('Failed')));
+ assertEq('undefined', typeof(window.confirm('Failed')));
+ assertEq('undefined', typeof(confirm('Failed')));
succeed();
},
function testWindowPrompt() {
- assertThrowsError(Window.prototype.prompt);
- assertThrowsError(window.prompt);
- assertThrowsError(prompt);
+ assertEq('undefined', typeof(Window.prototype.prompt('Failed')));
+ assertEq('undefined', typeof(window.prompt('Failed')));
+ assertEq('undefined', typeof(prompt('Failed')));
succeed();
},
@@ -90,29 +90,26 @@ chrome.test.runTests([
var bars = ['locationbar', 'menubar', 'personalbar',
'scrollbars', 'statusbar', 'toolbar'];
for (var x = 0; x < bars.length; x++) {
- assertThrowsError(function() {
- var visible = this[bars[x]].visible;
- visible = window[bars[x]].visible;
- });
+ assertEq('undefined', typeof(this[bars[x]]));
+ assertEq('undefined', typeof(window[bars[x]]));
}
succeed();
},
function testBlockedEvents() {
- var eventHandler = function() { fail('event handled'); };
+ var eventHandler = function() { fail('blocked event handled'); };
var blockedEvents = ['unload', 'beforeunload'];
for (var i = 0; i < blockedEvents.length; ++i) {
- assertThrowsError(function() {
- window['on' + blockedEvents[i]] = eventHandler;
- });
- assertThrowsError(function() {
- window.addEventListener(blockedEvents[i], eventHandler);
- });
- assertThrowsError(function() {
- Window.prototype.addEventListener.apply(window,
- [blockedEvents[i], eventHandler]);
- });
+ window['on' + blockedEvents[i]] = eventHandler;
+ assertEq(undefined, window['on' + blockedEvents[i]]);
+
+ var event = new Event(blockedEvents[i]);
+ window.addEventListener(blockedEvents[i], eventHandler);
+ window.dispatchEvent(event);
+ Window.prototype.addEventListener.apply(window,
+ [blockedEvents[i], eventHandler]);
+ window.dispatchEvent(event);
Jeffrey Yasskin 2014/01/08 22:49:17 Can you comment how this tests something?
pwnall-personal 2014/01/08 23:20:46 Done. Does this sound reasonable?
}
succeed();
@@ -132,7 +129,7 @@ chrome.test.runTests([
function testIframe() {
var iframe = document.createElement('iframe');
iframe.onload = function() {
- assertThrowsError(iframe.contentWindow.alert);
+ assertThrowsError(iframe.contentWindow.document.write);
succeed();
};
iframe.src = 'iframe.html';

Powered by Google App Engine
This is Rietveld 408576698