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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs

Issue 1513933005: Reland: Make the check for compat mode explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
index 36191c462ff5470fb4190fd4f0554a233350db67..06e90281b3084ef6437b35b01a94e697a4591dd5 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs
@@ -467,3 +467,41 @@ TEST_F('BackgroundTest', 'ActiveOrInactive', function() {
}
);
});
+
+TEST_F('BackgroundTest', 'ModeSwitching', function() {
+ this.runWithLoadedTree('<button></button>', function(root) {
+ // Tests default to force next mode.
+ assertEquals('force_next', global.backgroundObj.mode);
+
+ // Force next mode stays set regardless of where the range lands.
+ global.backgroundObj.refreshMode('http://google.com');
+ assertEquals('force_next', global.backgroundObj.mode);
+ // Empty urls occur before document load or when root is desktop.
+ global.backgroundObj.refreshMode('');
+ assertEquals('force_next', global.backgroundObj.mode);
+
+ // Verify compat -> classic switching.
+ global.backgroundObj.setMode('compat');
+ global.backgroundObj.refreshMode('http://google.com');
+ assertEquals('classic', global.backgroundObj.mode);
+
+ // Ensure we switch to compat if our current range has focused
+ // state set and is not in web content.
+ assertTrue(root.parent.state.focused);
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent));
+ global.backgroundObj.refreshMode('');
+ assertEquals('compat', global.backgroundObj.mode);
+
+ // And back to classic.
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root));
+ global.backgroundObj.refreshMode('');
+ assertEquals('classic', global.backgroundObj.mode);
+
+ // Now, try refreshing mode (which we call after tab switching) with a range
+ // that's not actually focused.
+ assertEquals(undefined, root.parent.parent.state.focused);
+ global.backgroundObj.setCurrentRange(cursors.Range.fromNode(root.parent.parent));
+ global.backgroundObj.refreshMode('');
+ assertEquals('classic', global.backgroundObj.mode);
+ }.bind(this));
+});

Powered by Google App Engine
This is Rietveld 408576698