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.
6 * This variable is checked in SelectFileDialogExtensionBrowserTest.
9 window.JSErrorCount = 0;
12 * Counts uncaught exceptions.
14 window.onerror = function() { window.JSErrorCount++; };
17 * Opens the gallery window and waits until it is ready.
19 * @param {Array.<string>} urls URLs to be opened.
20 * @param {function(string)} callback Completion callback with the new window's
23 test.util.async.openGallery = function(urls, callback) {
24 openGalleryWindow(urls, false).then(callback);
28 * Gets the metadata of the entry.
30 * @param {string} url URL to be get the metadata.
31 * @param {function(string)} callback Completion callback with the metadata.
33 test.util.async.getMetadata = function(url, callback) {
34 util.URLsToEntries([url]).then(function(result) {
35 if (result.entries.length != 1) {
38 result.entries[0].getMetadata(function(metadata) {
40 modificationTime: metadata.modificationTime,
49 * Changes the value of the input element.
51 * @param {Window} contentWindow Window to be tested.
52 * @param {string} query Query for the input element.
53 * @param {string} newValue Value to be assigned.
55 test.util.sync.changeValue = function(contentWindow, query, newValue) {
56 var element = contentWindow.document.querySelector(query);
57 element.value = newValue;
58 chrome.test.assertTrue(element.dispatchEvent(new Event('change')));
62 * Changes the file name.
64 * @param {Window} contentWindow Window to be tested.
65 * @param {string} newName Name to be newly assigned.
67 test.util.sync.changeName = function(contentWindow, newName) {
68 var fullResCanvas = contentWindow.document.querySelector(
69 '.gallery[mode="slide"] .content canvas.fullres');
71 var nameBox = contentWindow.document.querySelector('.namebox');
73 nameBox.value = newName;
77 // Register the test utils.
78 test.util.registerRemoteTestUtils();