Path: blob/trunk/javascript/chrome-driver/test/test_bootstrap.js
4500 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617/**18* @fileoverview Bootstrap file that loads all of the WebDriver scripts in the19* correct order. Once loaded, pages can use {@code goog.require} statements20* from Google Closure to load additional files as needed.21*22* Example Usage:23*24* <html>25* <head>26* <script src="test_bootstrap.js"></script>27* <script>28* goog.require('goog.debug.Logger');29* </script>30* <script>31* window.onload = function() {32* goog.debug.Logger.getLogger('').info(33* 'The page has finished loading');34* };35* </script>36* </head>37* <body></body>38* </html>39*/4041(function() {42// Enable the debug loader for the Closure Library (required for goog.require to work)43window.CLOSURE_UNCOMPILED_DEFINES = {'goog.ENABLE_DEBUG_LOADER': true};4445window.errors = [];46window.onerror = function() { window.errors.push(arguments); console.log(arguments); };47var scripts = document.getElementsByTagName('script');48var directoryPath = './';49var thisFile = 'test_bootstrap.js';5051for (var i = 0; i < scripts.length; i++) {52var src = scripts[i].src;53var len = src.length;54if (src.substr(len - thisFile.length) == thisFile) {55directoryPath = src.substr(0, len - thisFile.length);56break;57}58}5960// All of the files to load. Files are specified in the order they must be61// loaded, NOT alphabetical order.62var files = [63'../../../third_party/closure/goog/base.js',64'../../deps.js'65];6667if (location.pathname.lastIndexOf('/filez/_main/javascript/', 0) === 0) {68directoryPath = '';69files = [70'/filez/_main/third_party/closure/goog/base.js',71'/filez/_main/javascript/chrome-driver/deps.js',72];73}7475for (var j = 0; j < files.length; j++) {76document.write('<script type="text/javascript" src="' +77directoryPath + files[j] + '"></script>');78}79})();808182