Path: blob/trunk/javascript/webdriver/test/test_bootstrap.js
2868 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() {42var scripts = document.getElementsByTagName('script');43var directoryPath = './';44var thisFile = 'test_bootstrap.js';4546for (var i = 0; i < scripts.length; i++) {47var src = scripts[i].src;48var len = src.length;49if (src.substr(len - thisFile.length) == thisFile) {50directoryPath = src.substr(0, len - thisFile.length);51break;52}53}5455// All of the files to load. Files are specified in the order they must be56// loaded, NOT alphabetical order.57var files = [58'../../../third_party/closure/goog/base.js',59'../../deps.js'60];616263if (location.pathname.lastIndexOf('/filez/_main/javascript/', 0) === 064|| location.pathname.lastIndexOf('/common/generated/javascript/', 0) === 0) {65directoryPath = '';66files = [67'/filez/com_google_javascript_closure_library/closure/goog/base.js',68'/filez/_main/javascript/atoms/deps.js',69'/filez/_main/javascript/webdriver/deps.js',70];71}7273for (var j = 0; j < files.length; j++) {74document.write('<script type="text/javascript" src="' +75directoryPath + files[j] + '"></script>');76}77})();787980