Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / chrome / test / data / webui / bidichecker_tests.js
blob5f7466a3296eea6943174324473b00e3c1f95b0f
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The following test runs the BiDi Checker on the current page with LTR
6 // base direction. Any bad mixture or RTL and LTR will be reported back
7 // by this test.
9 function filtersForPage(pageName, isRTL) {
10 // Suppression filters should be added to the object below. You may omit
11 // either RTL or LTR filters, or may not include filters for your page at all.
12 // For additional info about BidiChecker go to
13 // http://code.google.com/p/bidichecker
14 // For specific info about filters, check out the following links:
15 // http://bidichecker.googlecode.com/svn/trunk/docs/users_guide.html
16 // #TOC-Error-descriptions
17 // http://bidichecker.googlecode.com/svn/trunk/docs/jsdoc/index.html
18 // TODO(ofri): Link to more comprehensive documentation when available.
19 var filters = {
20 // Page filters
21 "chrome://history" : {
22 // Filters for LTR UI
23 "LTR" : [
24 // BUG: http://crbug.com/80791
25 bidichecker.FilterFactory.atText("בדיקה")
27 // Filters for RTL UI
28 "RTL" : [
29 // BUG: http://crbug.com/80791
30 bidichecker.FilterFactory.atText("Google"),
31 bidichecker.FilterFactory.atText("www.google.com"),
32 // The following two are probably false positives since we can't
33 // completely change the environment to RTL on Linux.
34 // TODO(ofri): Verify that it's indeed a false positive.
35 bidichecker.FilterFactory.locationClass('day'),
36 bidichecker.FilterFactory.locationClass('time')
39 "chrome://settings/autofill" : {
40 "LTR" : [
41 // BUG: http://crbug.com/82267
42 bidichecker.FilterFactory.atText("משה ב כהן, דרך מנחם בגין")
44 "RTL" : [
45 // BUG: http://crbug.com/90322
46 bidichecker.FilterFactory.atText(
47 "Milton C. Waddams, 4120 Freidrich Lane")
50 "chrome://plugins" : {
51 "RTL" : [
52 // False positive
53 bidichecker.FilterFactory.atText('x'),
54 // Apparently also a false positive
55 bidichecker.FilterFactory.atText("undefined\n undefined"),
56 bidichecker.FilterFactory.locationClass('plugin-text')
59 "chrome://newtab" : {
60 "RTL" : [
61 // BUG: http://crbug.com/93339
62 bidichecker.FilterFactory.atText("Chrome Web Store"),
63 bidichecker.FilterFactory.atText("File Manager"),
64 bidichecker.FilterFactory.atText("Chrome Apps Debugger")
67 "chrome://feedback#0?description=%D7%91%D7%93%D7%99%D7%A7%D7%94" :
69 "LTR" : [
70 // BUG: http://crbug.com/90835
71 bidichecker.FilterFactory.atText("בדיקה")
74 "chrome://feedback#0?description=test" : {
75 "RTL" : [
76 // BUG: http://crbug.com/90835
77 bidichecker.FilterFactory.atText("test"),
78 bidichecker.FilterFactory.atText("stub-user@example.com")
81 "chrome://settings/browser" : {
82 "LTR" : [
83 // BUG: http://crbug.com/93702
84 bidichecker.FilterFactory.atText(
85 "חדשות תוכן ועדכונים - ידיעות אחרונות")
88 "chrome://history-frame" : {
89 "LTR" : [
90 // BUG: http://crbug.com/119595
91 bidichecker.FilterFactory.atText("בדיקה")
93 "RTL" : [
94 // BUG: http://crbug.com/119595
95 bidichecker.FilterFactory.atText("Google"),
96 bidichecker.FilterFactory.atText("www.google.com")
100 var globalFilters = {
101 "RTL" : [
102 // BUG: http://crbug/158750
103 bidichecker.FilterFactory.locationId("timezone-select")
107 var dir = isRTL ? "RTL" : "LTR";
108 if (!filters.hasOwnProperty(pageName))
109 pageName += '/';
110 if (!filters.hasOwnProperty(pageName)) {
111 if (pageName.charAt(pageName.length - 2) == '/')
112 pageName = pageName.substr(0, pageName.length - 2);
113 else
114 return globalFilters[dir];
116 if (filters.hasOwnProperty(pageName) &&
117 filters[pageName].hasOwnProperty(dir)) {
118 return filters[pageName][dir].concat(globalFilters[dir]);
119 } else {
120 return globalFilters[dir];
124 function buildPrettyErrors(bidiErrors) {
125 var idx;
126 var prettyErrors;
127 for (idx = 0; idx < bidiErrors.length; ++idx) {
128 prettyErrors += '\n\n';
129 prettyErrors += bidiErrors[idx].toString();
131 prettyErrors += '\n\n';
132 return prettyErrors;
135 function runBidiChecker(pageName, isRTL) {
136 var filters = filtersForPage(pageName, isRTL);
137 var bidiErrors = bidichecker.checkPage(isRTL, top.document.body, filters);
138 assertTrue(bidiErrors.length == 0, buildPrettyErrors(bidiErrors));