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

Side by Side Diff: chrome/test/data/webui/extensions/extension_code_section_test.js

Issue 2769293002: [MD Extensions] Include the manifest code snippet in load errors (Closed)
Patch Set: . Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Suite of tests for extensions-code-section. */ 5 /** @fileoverview Suite of tests for extensions-code-section. */
6 cr.define('extension_code_section_tests', function() { 6 cr.define('extension_code_section_tests', function() {
7 /** @enum {string} */ 7 /** @enum {string} */
8 var TestNames = { 8 var TestNames = {
9 Layout: 'layout', 9 Layout: 'layout',
10 }; 10 };
11 11
12 function registerTests() { 12 function registerTests() {
13 suite('ExtensionCodeSectionTest', function() { 13 suite('ExtensionCodeSectionTest', function() {
14 /** @type {chrome.developerPrivate.RequestFileSourceResponse} */ 14 /** @type {chrome.developerPrivate.RequestFileSourceResponse} */
15 var code = { 15 var code = {
16 beforeHighlight: 'this part before the highlight\nAnd this too\n', 16 beforeHighlight: 'this part before the highlight\nAnd this too\n',
17 highlight: 'highlight this part\n', 17 highlight: 'highlight this part\n',
18 afterHighlight: 'this part after the highlight\n', 18 afterHighlight: 'this part after the highlight\n',
19 message: 'Highlight message', 19 message: 'Highlight message',
20 }; 20 };
21 21
22 /** @type {extensions.CodeSection} */ 22 /** @type {extensions.CodeSection} */
23 var codeSection; 23 var codeSection;
24 24
25 var noCodeError = 'No code here'; 25 var couldNotDisplayCode = 'No code here';
26 26
27 suiteSetup(function() { 27 suiteSetup(function() {
28 return PolymerTest.importHtml('chrome://extensions/code_section.html'); 28 return PolymerTest.importHtml('chrome://extensions/code_section.html');
29 }); 29 });
30 30
31 // Initialize an extension item before each test. 31 // Initialize an extension item before each test.
32 setup(function() { 32 setup(function() {
33 PolymerTest.clearBody(); 33 PolymerTest.clearBody();
34 codeSection = new extensions.CodeSection(); 34 codeSection = new extensions.CodeSection();
35 codeSection.noCodeError = noCodeError; 35 codeSection.couldNotDisplayCode = couldNotDisplayCode;
36 document.body.appendChild(codeSection); 36 document.body.appendChild(codeSection);
37 }); 37 });
38 38
39 test(assert(TestNames.Layout), function() { 39 test(assert(TestNames.Layout), function() {
40 Polymer.dom.flush(); 40 Polymer.dom.flush();
41 41
42 var testIsVisible = 42 var testIsVisible =
43 extension_test_util.isVisible.bind(null, codeSection); 43 extension_test_util.isVisible.bind(null, codeSection);
44 expectFalse(!!codeSection.code); 44 expectFalse(!!codeSection.code);
45 expectTrue(codeSection.isMainHidden_()); 45 expectTrue(codeSection.isEmpty());
46 expectTrue(codeSection.$$('#main').hidden); 46 expectTrue(codeSection.$$('#main').hidden);
47 expectFalse(testIsVisible('#main')); 47 expectFalse(testIsVisible('#main'));
48 expectTrue(testIsVisible('#no-code')); 48 expectTrue(testIsVisible('#no-code'));
49 expectEquals('', codeSection.$['line-numbers'].textContent.trim()); 49 expectEquals('', codeSection.$['line-numbers'].textContent.trim());
50 50
51 codeSection.code = code; 51 codeSection.code = code;
52 expectTrue(testIsVisible('#main')); 52 expectTrue(testIsVisible('#main'));
53 expectFalse(testIsVisible('#no-code')); 53 expectFalse(testIsVisible('#no-code'));
54 54
55 var fullSpan = codeSection.$$('#source span'); 55 var fullSpan = codeSection.$$('#source span');
56 expectEquals( 56 expectEquals(
57 code.beforeHighlight + code.highlight + code.afterHighlight, 57 code.beforeHighlight + code.highlight + code.afterHighlight,
58 fullSpan.textContent); 58 fullSpan.textContent);
59 var highlightSpan = codeSection.$$('.highlight'); 59 var highlightSpan = codeSection.$$('.highlight');
60 expectEquals(code.highlight, highlightSpan.textContent); 60 expectEquals(code.highlight, highlightSpan.textContent);
61 expectEquals(code.message, highlightSpan.title); 61 expectEquals(code.message, highlightSpan.title);
62 expectEquals('1\n2\n3\n4', 62 expectEquals('1\n2\n3\n4',
63 codeSection.$['line-numbers'].textContent.trim()); 63 codeSection.$['line-numbers'].textContent.trim());
64 }); 64 });
65 }); 65 });
66 } 66 }
67 67
68 return { 68 return {
69 registerTests: registerTests, 69 registerTests: registerTests,
70 TestNames: TestNames, 70 TestNames: TestNames,
71 }; 71 };
72 }); 72 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698