1 // Copyright 2014 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.
7 * Test that some key elements exist and that they have the appropriate
8 * constructor name. This verifies that polymer is working correctly.
10 function testHasElements() {
13 'viewer-bookmarks-content',
14 'viewer-zoom-toolbar',
15 'viewer-password-screen',
18 for (var i
= 0; i
< elementNames
.length
; i
++) {
19 var elements
= document
.querySelectorAll(elementNames
[i
]);
20 chrome
.test
.assertEq(1, elements
.length
);
21 var element
= elements
[0];
22 chrome
.test
.assertTrue(
23 String(element
.constructor).indexOf(elementNames
[i
]) != -1);
25 chrome
.test
.succeed();
29 * Test that the plugin element exists and is navigated to the correct URL.
31 function testPluginElement() {
32 var plugin
= document
.getElementById('plugin');
33 chrome
.test
.assertEq('embed', plugin
.localName
);
35 chrome
.test
.assertTrue(
36 plugin
.getAttribute('src').indexOf('/pdf/test.pdf') != -1);
37 chrome
.test
.succeed();
41 * Test that shouldIgnoreKeyEvents correctly searches through the shadow DOM
42 * to find input fields.
44 function testIgnoreKeyEvents() {
45 // Test that the traversal through the shadow DOM works correctly.
46 var toolbar
= document
.getElementById('material-toolbar');
47 toolbar
.$.pageselector
.$.input
.focus();
48 chrome
.test
.assertTrue(shouldIgnoreKeyEvents(toolbar
));
50 // Test case where the active element has a shadow root of its own.
51 toolbar
.$.buttons
.children
[0].focus();
52 chrome
.test
.assertFalse(shouldIgnoreKeyEvents(toolbar
));
54 chrome
.test
.assertFalse(
55 shouldIgnoreKeyEvents(document
.getElementById('plugin')));
57 chrome
.test
.succeed();
61 var scriptingAPI
= new PDFScriptingAPI(window
, window
);
62 scriptingAPI
.setLoadCallback(function() {
63 chrome
.test
.runTests(tests
);