Path: blob/trunk/javascript/atoms/test/test_bootstrap.js
2884 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() {42window.errors = [];43window.onerror = function() { window.errors.push(arguments); console.log(arguments); };44var scripts = document.getElementsByTagName('script');45var directoryPath = './';46var thisFile = 'test_bootstrap.js';4748for (var i = 0; i < scripts.length; i++) {49var src = scripts[i].src;50var len = src.length;51if (src.substr(len - thisFile.length) == thisFile) {52directoryPath = src.substr(0, len - thisFile.length);53break;54}55}5657// All the files to load. Files are specified in the order they must be58// loaded, NOT alphabetical order.59var files = [60'../../../third_party/closure/goog/base.js',61'deps.js'62];6364if (location.pathname.lastIndexOf('/filez/_main/javascript/', 0) === 0) {65directoryPath = '';66files = [67'/filez/com_google_javascript_closure_library/closure/goog/base.js',68'/filez/_main/javascript/atoms/deps.js',69];70}7172for (var j = 0; j < files.length; j++) {73document.write('<script type="text/javascript" src="' +74directoryPath + files[j] + '"></script>');75}76})();777879