3.0 source code
This commit is contained in:
5
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/one.dphpd
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/one.dphpd
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
sleep(1);
|
||||
?>
|
||||
|
||||
console.log("ONE");
|
||||
49
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/test.html
vendored
Normal file
49
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/test.html
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script appendChild Before Page Load Test</title>
|
||||
<script type="text/javascript">
|
||||
var attachScript = function(url, name){
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
|
||||
var urls = [
|
||||
"one.php",
|
||||
"two.js"
|
||||
]
|
||||
|
||||
for (var i = 0, url; url = urls[i]; i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Blocking Before Page Load Test</h1>
|
||||
<p><b>This test requires PHP. Rename one.dphpd in this directory to
|
||||
one.php before trying this test.</b></p>
|
||||
|
||||
<p>This test looks at scripts added via appendChild before the page loads.
|
||||
Do the scripts execute in the order added to the DOM or the order in which
|
||||
they are received from the network?</p>
|
||||
|
||||
<p>Normally after page load, IE and WebKit
|
||||
will evaluate scripts in network receive order, not in DOM order. This test
|
||||
is checking the behavior before page load.</p>
|
||||
|
||||
<p>Expected results:<br>
|
||||
<b>ONE</b><br>
|
||||
<b>TWO</b><br>
|
||||
</p>
|
||||
|
||||
<p>>Actual results: see browser console. IE and WebKit will execute scripts
|
||||
in network receive order, not in DOM order.</p>
|
||||
</body>
|
||||
</html>
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/two.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/appendbeforeload/two.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log("TWO");
|
||||
94
OfficeWeb/vendor/requirejs/tests/browsertests/async/async.php
vendored
Normal file
94
OfficeWeb/vendor/requirejs/tests/browsertests/async/async.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?
|
||||
if($_GET['quirks'] == "")
|
||||
{
|
||||
echo "<!DOCTYPE html>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "\n";
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Async Attribute Test</title>
|
||||
<script type="text/javascript" src="../common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var attachScript = function(url, name, approach){
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
if (approach === 'boolean') {
|
||||
node.async = true;
|
||||
} else if (approach === 'string') {
|
||||
node.async = 'async';
|
||||
} else if (approach === 'attribute') {
|
||||
node.setAttribute('async', 'async');
|
||||
}
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
|
||||
var urls = [
|
||||
"one.php",
|
||||
"two.js"
|
||||
];
|
||||
|
||||
var loadUrls = function(approach) {
|
||||
for (var i = 0, url; url = urls[i]; i++) {
|
||||
attachScript(url, url, approach);
|
||||
}
|
||||
}
|
||||
|
||||
function onFormAction () {
|
||||
var select = document.getElementById('approach'),
|
||||
approach = select.value,
|
||||
text = select.options[select.selectedIndex].text;
|
||||
window.log('Using approach: [' + text + '] (' + approach + ')...');
|
||||
loadUrls(approach);
|
||||
};
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Async Attribute Test</h1>
|
||||
<p><b>This test requires PHP to be enabled to run.</b></p>
|
||||
|
||||
<p>This test tests async attribute. It attaches two scripts to the DOM, <b>one.php</b> and <b>two.js</b>.
|
||||
The URLs to the scripts always has a timestamp querystring to make sure the scripts are fetched
|
||||
fresh for each request.</p>
|
||||
|
||||
<p>one.php uses a PHP sleep of 3 seconds before returning its result (a log message), where two.js will return
|
||||
immediately with a log message.</p>
|
||||
|
||||
<p>If the async attribute is being effective (In Gecko 1.9.2+/Firefox 3.6+ browsers, maybe
|
||||
Opera in the future), then the log message for two.js should appear before the one.php log message.
|
||||
If async is <b>not</b> effective, then one.php's log message will appear first.</p>
|
||||
|
||||
<p>You can also <b><a href="async.php?quirks=true">try this page in quirks mode</a></b>.
|
||||
When you are done, come back to <b><a href="async.php">standards mode</a></b>.</p>
|
||||
|
||||
<p>Watch the console for log messages. If no console is available, then it should print
|
||||
the log messages in the DOM.</p>
|
||||
|
||||
<p><b>Expected Results in All Browsers (except Opera)</b>:</p>
|
||||
<ul>
|
||||
<li>two.js script</li>
|
||||
<li>one.php script</li>
|
||||
</ul>
|
||||
|
||||
<form onsubmit="onFormAction(); return false;">
|
||||
<label for="approach">Choose an approach to indicate async:</label>
|
||||
<select id="approach" onchange="onFormAction();">
|
||||
<option value="boolean">script.async = true</option>
|
||||
<option value="string">script.async = 'async'</option>
|
||||
<option value="attribute">script.setAttribute('async', 'async')</option>
|
||||
<option value="">No async (one.php should be first in Firefox 3.6+)</option>
|
||||
</select>
|
||||
<input type="submit" name="Go" value="Go">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/async/one.php
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/async/one.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
sleep(3);
|
||||
?>
|
||||
|
||||
window.log("one.php script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/async/two.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/async/two.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
window.log("two.js script");
|
||||
47
OfficeWeb/vendor/requirejs/tests/browsertests/common.js
vendored
Normal file
47
OfficeWeb/vendor/requirejs/tests/browsertests/common.js
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
//Common functions for the test files. *MUST* be included after require.js.
|
||||
|
||||
(function() {
|
||||
var messages = [];
|
||||
var bodyReady = false;
|
||||
|
||||
window.log = function(message) {
|
||||
if (typeof console != "undefined" && console.log) {
|
||||
console.log(message);
|
||||
} else {
|
||||
messages.push(message);
|
||||
if (bodyReady) {
|
||||
dumpLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dumpLogs() {
|
||||
bodyReady = true;
|
||||
if (messages.length) {
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
if (body) {
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = messages[i];
|
||||
body.appendChild(div);
|
||||
}
|
||||
}
|
||||
messages =[];
|
||||
}
|
||||
}
|
||||
|
||||
//Wait for document ready before dumping results.
|
||||
//Will not work with Firefox 3.5 or earlier, but just
|
||||
//be sure to use Firebug or something that defines console.log
|
||||
var tries = 0;
|
||||
function checkDom() {
|
||||
if (document.readyState === "complete") {
|
||||
dumpLogs();
|
||||
} else if (tries < 5) {
|
||||
tries += 1;
|
||||
setTimeout(checkDom, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
checkDom();
|
||||
})();
|
||||
28
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/index.html
vendored
Normal file
28
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/index.html
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Nested doc.write Test</title>
|
||||
<script type="text/javascript">
|
||||
function loadScript(url) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
document.write('<script src="' + url + '"></' + 'script>');
|
||||
}
|
||||
loadScript("one.js");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Nested doc.write Test</h1>
|
||||
|
||||
<p>This test checks how the browser treats document.write calls that are nested.</p>
|
||||
<ol>
|
||||
<li>a script for one.js is written via document.write()</li>
|
||||
<li>when one.js loads it asks for two.js to be written via document.write()</li>
|
||||
<li>one.js then immediately accesses something defined in two.js</li>
|
||||
</ol>
|
||||
|
||||
<p>The expectation is that the access to the variable defined by two.js in one.js
|
||||
will fail.</p>
|
||||
|
||||
<p>Check the console for output</p>
|
||||
</body>
|
||||
</html>
|
||||
7
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/one.js
vendored
Normal file
7
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/one.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
loadScript("two.js");
|
||||
|
||||
one = {
|
||||
name: "one"
|
||||
};
|
||||
|
||||
console.log("Two's name is: " + two.name);
|
||||
3
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/two.js
vendored
Normal file
3
OfficeWeb/vendor/requirejs/tests/browsertests/docwritenested/two.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
two = {
|
||||
name: "two"
|
||||
};
|
||||
49
OfficeWeb/vendor/requirejs/tests/browsertests/functionToString.html
vendored
Normal file
49
OfficeWeb/vendor/requirejs/tests/browsertests/functionToString.html
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Function toString() Test</title>
|
||||
<style type="text/css">
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 20em;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
function def(func) {
|
||||
document.getElementById('output').value = func.toString();
|
||||
}
|
||||
|
||||
function convert() {
|
||||
def(function (require, exports, module) {
|
||||
//This is a comment
|
||||
var bar = require('foo/bar'),
|
||||
baz = require('baz');
|
||||
|
||||
//require('line');
|
||||
var moduleId = module.id;
|
||||
|
||||
/*
|
||||
This is a multi-line comment that contains
|
||||
as require('multiline')
|
||||
*/
|
||||
exports.name = 'bamf';
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Function toString() Test</h1>
|
||||
<p>This test shows how a function is converted to a string value via the Function.prototype.toString() method.
|
||||
See the source of this file to see the source for of the function that is converted to a string.</p>
|
||||
|
||||
<form action="#" onsubmit="convert();return false;">
|
||||
<input type="submit" name="toString" value="toString">
|
||||
<label for="output">Output:</label>
|
||||
<textarea id="output"></textarea>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
86
OfficeWeb/vendor/requirejs/tests/browsertests/noload/index.html
vendored
Normal file
86
OfficeWeb/vendor/requirejs/tests/browsertests/noload/index.html
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script noload Test</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
|
||||
var readyRegExp = /complete|loaded/;
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
log(node.getAttribute("data-name") + " loaded");
|
||||
|
||||
//Clean up binding.
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onTestError(evt) {
|
||||
var node = evt.target || evt.srcElement,
|
||||
name = node.getAttribute("data-name");
|
||||
|
||||
if (typeof console !== "undefined" && console.log) {
|
||||
console.log(name + ' has error event: ', evt);
|
||||
}
|
||||
|
||||
log(name + " onerror triggered");
|
||||
|
||||
//Clean up binding.
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("error", onTestError, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onerror", onTestError);
|
||||
}
|
||||
}
|
||||
|
||||
function attachScript(url, name) {
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
node.addEventListener("error", onTestError, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
node.attachEvent("onerror", onTestError);
|
||||
}
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
|
||||
//Main logic
|
||||
attachScript('404.js', '404');
|
||||
|
||||
var url505 = location.protocol + '//' + location.hostname + ':9320/505.js';
|
||||
attachScript(url505, '505');
|
||||
|
||||
var noServerUrl = location.protocol + '//' + location.hostname + ':9321/noserver.js';
|
||||
attachScript(noServerUrl, 'no server');
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script noload Test</h1>
|
||||
|
||||
<p>Test if HTTP 404 or 500 calls or down hosts for a script trigger a scripts error handler.</p>
|
||||
|
||||
<p>For this test to receive 500 responses, nodejs needs to run server.js in this directory.</p>
|
||||
|
||||
<p>Output below should be "404 onerror triggered", "500 onerror triggered" and "no server onerror triggered".
|
||||
They may be in a different order, but that is OK.</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
26
OfficeWeb/vendor/requirejs/tests/browsertests/noload/server.js
vendored
Normal file
26
OfficeWeb/vendor/requirejs/tests/browsertests/noload/server.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*jslint strict: false*/
|
||||
/*global require: false, console: false */
|
||||
|
||||
var http = require('http'),
|
||||
host = '0.0.0.0',
|
||||
port = 9320,
|
||||
config;
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
|
||||
req.on('end', function () {
|
||||
|
||||
var contents = '500 server error';
|
||||
|
||||
res.writeHead(500, {
|
||||
'Content-Type': 'text/plain',
|
||||
'Content-Length': contents.length
|
||||
});
|
||||
|
||||
res.write(contents, 'utf8');
|
||||
res.end();
|
||||
});
|
||||
|
||||
}).listen(port, host);
|
||||
|
||||
console.log('Server running at http://' + host + ':' + port + '/');
|
||||
74
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/index.html
vendored
Normal file
74
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/index.html
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script onerror Test</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
|
||||
var readyRegExp = /complete|loaded/;
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
log(node.getAttribute("data-name") + " loaded");
|
||||
|
||||
//Clean up binding.
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onTestError(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
log(node.getAttribute("data-name") + " onerror triggered");
|
||||
|
||||
//Clean up binding.
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("error", onTestError, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onerror", onTestError);
|
||||
}
|
||||
}
|
||||
|
||||
function attachScript(url, name) {
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
node.addEventListener("error", onTestError, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
node.attachEvent("onerror", onTestError);
|
||||
}
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script onerror Test</h1>
|
||||
|
||||
<p>Test different script loading scenarios to see if an error callback is
|
||||
given on the script tag.</p>
|
||||
|
||||
<p>Press the button and check console for output. There should be a log
|
||||
message for each button.</p>
|
||||
|
||||
<button onclick="attachScript('ok.js', 'ok');">OK</button>
|
||||
<button onclick="attachScript('parseError.js', 'parseError');">Parse Error</button>
|
||||
<button onclick="attachScript('scriptError.js', 'scriptError');">Script Error</button>
|
||||
<button onclick="attachScript('404.js', '404');">404 Script</button>
|
||||
</body>
|
||||
</html>
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/ok.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/ok.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("ok has executed");
|
||||
4
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/parseError.js
vendored
Normal file
4
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/parseError.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
funktion = foo() {
|
||||
return 'funky';
|
||||
}
|
||||
4
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/scriptError.js
vendored
Normal file
4
OfficeWeb/vendor/requirejs/tests/browsertests/onerror/scriptError.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
if (true) {
|
||||
throw "scriptError throwing";
|
||||
}
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/eight.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/eight.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("eight.js script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/five.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/five.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("five.js script");
|
||||
2520
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/four.js
vendored
Normal file
2520
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/four.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
98
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/index.html
vendored
Normal file
98
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/index.html
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script Load Test</title>
|
||||
<script type="text/javascript" src="../common.js"></script>
|
||||
<script type="text/javascript">
|
||||
//cache bust?
|
||||
var noCache = location.href.indexOf("nocache") != -1;
|
||||
|
||||
log("noCache: " + noCache);
|
||||
|
||||
var readyRegExp = /complete|loaded/;
|
||||
|
||||
var onTestScriptLoad = function(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type == "load" || readyRegExp.test(node.readyState)) {
|
||||
log(node.getAttribute("data-name") + " loaded");
|
||||
|
||||
//Clean up script binding.
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var attachScript = function(url, name, useDocWrite){
|
||||
if (noCache) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
}
|
||||
if (useDocWrite) {
|
||||
//TODO doc.write
|
||||
document.write('<script type="text/javascript" charset="utf-8" data-name="'
|
||||
+ name
|
||||
+ '" src="'
|
||||
+ url
|
||||
+ '" onload="onTestScriptLoad(evt)" onreadytate="onTestScriptLoad(evt)">\<\/script>');
|
||||
} else {
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
var urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.js",
|
||||
"five.js",
|
||||
"six.js",
|
||||
"seven.js",
|
||||
"eight.js",
|
||||
"nine.js"
|
||||
]
|
||||
|
||||
var loadUrls = function(useDocWrite) {
|
||||
for (var i = 0, url; url = urls[i]; i++) {
|
||||
attachScript(url, url, useDocWrite);
|
||||
}
|
||||
}
|
||||
|
||||
//First test document.write calls
|
||||
//xxx
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls(false);
|
||||
|
||||
//Try script appends after page load.
|
||||
log("----------------------");
|
||||
setTimeout(loadUrls, 2000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Load Test</h1>
|
||||
|
||||
<p>This test checks the order in which script onloads are called. Hopefully
|
||||
only one script onload is fired at a time and it matches the just-evaluated
|
||||
script tag. If this does not work, then it means require.js files *must* specify
|
||||
a module name for a module definition call, instead of letting it be derived
|
||||
from the file path.</p>
|
||||
<p>Check the console for output</p>
|
||||
</body>
|
||||
</html>
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/nine.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/nine.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("nine.js script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/one.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/one.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("one.js script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/seven.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/seven.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("seven.js script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/six.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/six.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("six.js script");
|
||||
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/three.js
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/three.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
log("three.js script");
|
||||
4
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/two.js
vendored
Normal file
4
OfficeWeb/vendor/requirejs/tests/browsertests/scriptload/two.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
log("two.js script");
|
||||
setTimeout(function () {
|
||||
log("two.js timeout -- should occur after two.js load");
|
||||
}, 13);
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/eight.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/eight.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'eight'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/five.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/five.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'five'
|
||||
};
|
||||
});
|
||||
2524
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/four.js
vendored
Normal file
2524
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/four.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2527
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/four.php
vendored
Normal file
2527
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/four.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/index-php.html
vendored
Normal file
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/index-php.html
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script Load Interactive Test (PHP used to delay two scripts)</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
/*jslint plusplus: false, strict: false */
|
||||
/*global log: false, dumpLogs: false */
|
||||
//cache bust?
|
||||
var noCache = location.href.indexOf("nocache") !== -1;
|
||||
|
||||
log("noCache: " + noCache);
|
||||
|
||||
var readyRegExp = /complete|loaded/,
|
||||
useInteractive = false,
|
||||
loadedScripts = [],
|
||||
callCount = 0,
|
||||
currentlyAddingScript,
|
||||
waitingFunc, loadUrls,
|
||||
urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.php",
|
||||
"five.js",
|
||||
"six.php",
|
||||
"seven.js",
|
||||
"eight.js",
|
||||
"nine.js"
|
||||
];
|
||||
|
||||
function report() {
|
||||
var i, module;
|
||||
for (i = 0; i < loadedScripts.length; i++) {
|
||||
module = loadedScripts[i];
|
||||
log("module " + module.name + " === " + module.obj.name);
|
||||
}
|
||||
callCount += 1;
|
||||
//dumpLogs();
|
||||
if (callCount === 1) {
|
||||
log("-------Trying cache hits now--------");
|
||||
loadedScripts = [];
|
||||
setTimeout(loadUrls, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function finishScript(script, func) {
|
||||
if (!script) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadedScripts.push({
|
||||
name: script.getAttribute('data-name').replace(/\.js$/, ''),
|
||||
obj: func()
|
||||
});
|
||||
|
||||
if (loadedScripts.length === 9) {
|
||||
report();
|
||||
}
|
||||
}
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
if (!useInteractive) {
|
||||
finishScript(node, waitingFunc);
|
||||
}
|
||||
|
||||
//Clean up
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
function attachScript(url, name, useDocWrite) {
|
||||
if (noCache) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
}
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
useInteractive = true;
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
currentlyAddingScript = node;
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
currentlyAddingScript = null;
|
||||
}
|
||||
|
||||
loadUrls = function () {
|
||||
for (var i = 0, url; (url = urls[i]); i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
};
|
||||
|
||||
function def(func) {
|
||||
var scripts, i, script = currentlyAddingScript;
|
||||
if (useInteractive) {
|
||||
scripts = document.getElementsByTagName('script');
|
||||
var states = [];
|
||||
for (i = scripts.length - 1; i > -1; i--) {
|
||||
states.push(i + scripts[i].readyState + scripts[i].src);
|
||||
//log('script with name ' + scripts[i].getAttribute('data-name') + ' has readyState = ' + scripts[i].readyState + ' for func: ' + func);
|
||||
if (scripts[i].readyState === 'interactive') {
|
||||
script = scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!script) {
|
||||
log("ERROR: No matching script interactive for " + func);
|
||||
log("script readyStates are: " + states);
|
||||
}
|
||||
//log('calling finishScript for interactive dat-name: ' + script.getAttribute('data-name'));
|
||||
finishScript(script, func);
|
||||
} else {
|
||||
waitingFunc = func;
|
||||
}
|
||||
}
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Load Interactive Test (PHP used to delay two scripts)</h1>
|
||||
|
||||
<p>This test checks to see if a function call can be associated with a specific script tag.</p>
|
||||
<p>For non-IE 6-8 browsers, the script onload event may not fire right after the the script
|
||||
is evaluated. Kris Zyp found for IE though that in a function call that is called while the
|
||||
script is executed, it could query the script nodes and the one that is in "interactive" mode
|
||||
indicates the current script.</p>
|
||||
<p>So this test tries to see to use interactive state if possible, and if that does not work,
|
||||
falls back to using script onload to associate the scripts.</p>
|
||||
<p>Check the console for output. Expected result, all scripts are matched up with their calls.</p>
|
||||
</body>
|
||||
</html>
|
||||
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/index.html
vendored
Normal file
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/index.html
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script Load Interactive Test</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
/*jslint plusplus: false, strict: false */
|
||||
/*global log: false, dumpLogs: false */
|
||||
//cache bust?
|
||||
var noCache = location.href.indexOf("nocache") !== -1;
|
||||
|
||||
log("noCache: " + noCache);
|
||||
|
||||
var readyRegExp = /complete|loaded/,
|
||||
useInteractive = false,
|
||||
loadedScripts = [],
|
||||
callCount = 0,
|
||||
currentlyAddingScript,
|
||||
waitingFunc, loadUrls,
|
||||
urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.js",
|
||||
"five.js",
|
||||
"six.js",
|
||||
"seven.js",
|
||||
"eight.js",
|
||||
"nine.js"
|
||||
];
|
||||
|
||||
function report() {
|
||||
var i, module;
|
||||
for (i = 0; i < loadedScripts.length; i++) {
|
||||
module = loadedScripts[i];
|
||||
log("module " + module.name + " === " + module.obj.name);
|
||||
}
|
||||
callCount += 1;
|
||||
//dumpLogs();
|
||||
if (callCount === 1) {
|
||||
log("-------Trying cache hits now--------");
|
||||
loadedScripts = [];
|
||||
setTimeout(loadUrls, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function finishScript(script, func) {
|
||||
if (!script) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadedScripts.push({
|
||||
name: script.getAttribute('data-name').replace(/\.js$/, ''),
|
||||
obj: func()
|
||||
});
|
||||
|
||||
if (loadedScripts.length === 9) {
|
||||
report();
|
||||
}
|
||||
}
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
if (!useInteractive) {
|
||||
finishScript(node, waitingFunc);
|
||||
}
|
||||
|
||||
//Clean up
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
function attachScript(url, name, useDocWrite) {
|
||||
if (noCache) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
}
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
useInteractive = true;
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
currentlyAddingScript = node;
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
currentlyAddingScript = null;
|
||||
}
|
||||
|
||||
loadUrls = function () {
|
||||
for (var i = 0, url; (url = urls[i]); i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
};
|
||||
|
||||
function def(func) {
|
||||
var scripts, i, script = currentlyAddingScript;
|
||||
if (useInteractive) {
|
||||
scripts = document.getElementsByTagName('script');
|
||||
var states = [];
|
||||
for (i = scripts.length - 1; i > -1; i--) {
|
||||
states.push(i + scripts[i].readyState + scripts[i].src);
|
||||
//log('script with name ' + scripts[i].getAttribute('data-name') + ' has readyState = ' + scripts[i].readyState + ' for func: ' + func);
|
||||
if (scripts[i].readyState === 'interactive') {
|
||||
script = scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!script) {
|
||||
log("ERROR: No matching script interactive for " + func);
|
||||
log("script readyStates are: " + states);
|
||||
}
|
||||
//log('calling finishScript for interactive dat-name: ' + script.getAttribute('data-name'));
|
||||
finishScript(script, func);
|
||||
} else {
|
||||
waitingFunc = func;
|
||||
}
|
||||
}
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Load Interactive Test</h1>
|
||||
|
||||
<p>This test checks to see if a function call can be associated with a specific script tag.</p>
|
||||
<p>For non-IE 6-8 browsers, the script onload event may not fire right after the the script
|
||||
is evaluated. Kris Zyp found for IE though that in a function call that is called while the
|
||||
script is executed, it could query the script nodes and the one that is in "interactive" mode
|
||||
indicates the current script.</p>
|
||||
<p>So this test tries to see to use interactive state if possible, and if that does not work,
|
||||
falls back to using script onload to associate the scripts.</p>
|
||||
<p>Check the console for output. Expected result, all scripts are matched up with their calls.</p>
|
||||
</body>
|
||||
</html>
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/nine.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/nine.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'nine'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/one.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/one.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'one'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/seven.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/seven.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'seven'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/six.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/six.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'six'
|
||||
};
|
||||
});
|
||||
9
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/six.php
vendored
Normal file
9
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/six.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
sleep(2)
|
||||
?>
|
||||
|
||||
def(function () {
|
||||
return {
|
||||
name: 'six'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/three.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/three.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'three'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/two.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractive/two.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'two'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/eight.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/eight.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'eight'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/five.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/five.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'five'
|
||||
};
|
||||
});
|
||||
2524
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/four.js
vendored
Normal file
2524
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/four.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2527
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/four.php
vendored
Normal file
2527
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/four.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/index-php.html
vendored
Normal file
149
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/index-php.html
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script Load Interactive Test (PHP used to delay two scripts)</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
/*jslint plusplus: false, strict: false */
|
||||
/*global log: false, dumpLogs: false */
|
||||
//cache bust?
|
||||
var noCache = location.href.indexOf("nocache") !== -1;
|
||||
|
||||
log("noCache: " + noCache);
|
||||
|
||||
var readyRegExp = /complete|loaded/,
|
||||
useInteractive = false,
|
||||
loadedScripts = [],
|
||||
callCount = 0,
|
||||
currentlyAddingScript,
|
||||
waitingFunc, loadUrls,
|
||||
urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.php",
|
||||
"five.js",
|
||||
"six.php",
|
||||
"seven.js",
|
||||
"eight.js",
|
||||
"nine.js"
|
||||
];
|
||||
|
||||
function report() {
|
||||
var i, module;
|
||||
for (i = 0; i < loadedScripts.length; i++) {
|
||||
module = loadedScripts[i];
|
||||
log("module " + module.name + " === " + module.obj.name);
|
||||
}
|
||||
callCount += 1;
|
||||
//dumpLogs();
|
||||
if (callCount === 1) {
|
||||
log("-------Trying cache hits now--------");
|
||||
loadedScripts = [];
|
||||
setTimeout(loadUrls, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function finishScript(script, func) {
|
||||
if (!script) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadedScripts.push({
|
||||
name: script.getAttribute('data-name').replace(/\.js$/, ''),
|
||||
obj: func()
|
||||
});
|
||||
|
||||
if (loadedScripts.length === 9) {
|
||||
report();
|
||||
}
|
||||
}
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
if (!useInteractive) {
|
||||
finishScript(node, waitingFunc);
|
||||
}
|
||||
|
||||
//Clean up
|
||||
if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
}
|
||||
}
|
||||
function attachScript(url, name, useDocWrite) {
|
||||
if (noCache) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
}
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
} else {
|
||||
//Probably IE.
|
||||
useInteractive = true;
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
}
|
||||
currentlyAddingScript = node;
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
currentlyAddingScript = null;
|
||||
}
|
||||
|
||||
loadUrls = function () {
|
||||
for (var i = 0, url; (url = urls[i]); i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
};
|
||||
|
||||
function def(func) {
|
||||
var scripts, i, script = currentlyAddingScript;
|
||||
if (useInteractive) {
|
||||
scripts = document.getElementsByTagName('script');
|
||||
var states = [];
|
||||
for (i = scripts.length - 1; i > -1; i--) {
|
||||
states.push(i + scripts[i].readyState + scripts[i].src);
|
||||
//log('script with name ' + scripts[i].getAttribute('data-name') + ' has readyState = ' + scripts[i].readyState + ' for func: ' + func);
|
||||
if (scripts[i].readyState === 'interactive') {
|
||||
script = scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!script) {
|
||||
log("ERROR: No matching script interactive for " + func);
|
||||
log("script readyStates are: " + states);
|
||||
}
|
||||
//log('calling finishScript for interactive dat-name: ' + script.getAttribute('data-name'));
|
||||
finishScript(script, func);
|
||||
} else {
|
||||
waitingFunc = func;
|
||||
}
|
||||
}
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Load Interactive Test (PHP used to delay two scripts)</h1>
|
||||
|
||||
<p>This test checks to see if a function call can be associated with a specific script tag.</p>
|
||||
<p>For non-IE 6-8 browsers, the script onload event may not fire right after the the script
|
||||
is evaluated. Kris Zyp found for IE though that in a function call that is called while the
|
||||
script is executed, it could query the script nodes and the one that is in "interactive" mode
|
||||
indicates the current script.</p>
|
||||
<p>So this test tries to see to use interactive state if possible, and if that does not work,
|
||||
falls back to using script onload to associate the scripts.</p>
|
||||
<p>Check the console for output. Expected result, all scripts are matched up with their calls.</p>
|
||||
</body>
|
||||
</html>
|
||||
153
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/index.html
vendored
Normal file
153
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/index.html
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Script Load Interactive Test: attachEvent</title>
|
||||
<script src="../common.js"></script>
|
||||
<script>
|
||||
/*jslint plusplus: false, strict: false */
|
||||
/*global log: false, dumpLogs: false */
|
||||
//cache bust?
|
||||
var noCache = location.href.indexOf("nocache") !== -1;
|
||||
|
||||
log("noCache: " + noCache);
|
||||
|
||||
var readyRegExp = /complete|loaded/,
|
||||
useInteractive = false,
|
||||
loadedScripts = [],
|
||||
callCount = 0,
|
||||
currentlyAddingScript,
|
||||
waitingFunc, loadUrls,
|
||||
urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.js",
|
||||
"five.js",
|
||||
"six.js",
|
||||
"seven.js",
|
||||
"eight.js",
|
||||
"nine.js"
|
||||
];
|
||||
|
||||
function report() {
|
||||
var i, module;
|
||||
for (i = 0; i < loadedScripts.length; i++) {
|
||||
module = loadedScripts[i];
|
||||
log("module " + module.name + " === " + module.obj.name);
|
||||
}
|
||||
callCount += 1;
|
||||
//dumpLogs();
|
||||
if (callCount === 1) {
|
||||
log("-------Trying cache hits now--------");
|
||||
loadedScripts = [];
|
||||
setTimeout(loadUrls, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function finishScript(script, func) {
|
||||
if (!script) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadedScripts.push({
|
||||
name: script.getAttribute('data-name').replace(/\.js$/, ''),
|
||||
obj: func()
|
||||
});
|
||||
|
||||
if (loadedScripts.length === 9) {
|
||||
report();
|
||||
}
|
||||
}
|
||||
|
||||
function onTestScriptLoad(evt) {
|
||||
var node = evt.target || evt.srcElement;
|
||||
if (evt.type === "load" || readyRegExp.test(node.readyState)) {
|
||||
if (!useInteractive) {
|
||||
finishScript(node, waitingFunc);
|
||||
}
|
||||
|
||||
//Clean up
|
||||
if (node.detachEvent) {
|
||||
//Probably IE.
|
||||
node.detachEvent("onreadystatechange", onTestScriptLoad);
|
||||
} else if (node.removeEventListener) {
|
||||
node.removeEventListener("load", onTestScriptLoad, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
function attachScript(url, name, useDocWrite) {
|
||||
if (noCache) {
|
||||
url += "?stamp=" + (new Date()).getTime();
|
||||
}
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
//Set up load listener.
|
||||
if (node.attachEvent) {
|
||||
//Probably IE.
|
||||
useInteractive = true;
|
||||
node.attachEvent("onreadystatechange", onTestScriptLoad);
|
||||
} else if (node.addEventListener) {
|
||||
node.addEventListener("load", onTestScriptLoad, false);
|
||||
}
|
||||
currentlyAddingScript = node;
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
currentlyAddingScript = null;
|
||||
}
|
||||
|
||||
loadUrls = function () {
|
||||
for (var i = 0, url; (url = urls[i]); i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
};
|
||||
|
||||
function def(func) {
|
||||
var scripts, i, script = currentlyAddingScript;
|
||||
if (useInteractive) {
|
||||
scripts = document.getElementsByTagName('script');
|
||||
var states = [];
|
||||
for (i = scripts.length - 1; i > -1; i--) {
|
||||
states.push(i + scripts[i].readyState + scripts[i].src);
|
||||
//log('script with name ' + scripts[i].getAttribute('data-name') + ' has readyState = ' + scripts[i].readyState + ' for func: ' + func);
|
||||
if (scripts[i].readyState === 'interactive') {
|
||||
script = scripts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!script) {
|
||||
log("ERROR: No matching script interactive for " + func);
|
||||
log("script readyStates are: " + states);
|
||||
}
|
||||
//log('calling finishScript for interactive dat-name: ' + script.getAttribute('data-name'));
|
||||
finishScript(script, func);
|
||||
} else {
|
||||
waitingFunc = func;
|
||||
}
|
||||
}
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Script Load Interactive Test: attachEvent</h1>
|
||||
|
||||
<p><b>This test difffers from scriptloadinteractive in that attachEvent is preferred over
|
||||
addEventListener to work around an IE9 issue where its addEventListener behavior does not match
|
||||
all other addEventListener browsers that fire the script onload event right after executing a
|
||||
script (at least before executing any other script).</b></p>
|
||||
<p>This test checks to see if a function call can be associated with a specific script tag.</p>
|
||||
<p>For non-IE 6-8 browsers, the script onload event may not fire right after the the script
|
||||
is evaluated. Kris Zyp found for IE though that in a function call that is called while the
|
||||
script is executed, it could query the script nodes and the one that is in "interactive" mode
|
||||
indicates the current script.</p>
|
||||
<p>So this test tries to see to use interactive state if possible, and if that does not work,
|
||||
falls back to using script onload to associate the scripts.</p>
|
||||
<p>Check the console for output. Expected result, all scripts are matched up with their calls.</p>
|
||||
</body>
|
||||
</html>
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/nine.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/nine.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'nine'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/one.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/one.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'one'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/seven.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/seven.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'seven'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/six.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/six.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'six'
|
||||
};
|
||||
});
|
||||
9
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/six.php
vendored
Normal file
9
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/six.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
sleep(2)
|
||||
?>
|
||||
|
||||
def(function () {
|
||||
return {
|
||||
name: 'six'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/three.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/three.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'three'
|
||||
};
|
||||
});
|
||||
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/two.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/browsertests/scriptloadinteractiveattach/two.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
def(function () {
|
||||
return {
|
||||
name: 'two'
|
||||
};
|
||||
});
|
||||
9
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/define.js
vendored
Normal file
9
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/define.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
function define(message) {
|
||||
log(message);
|
||||
}
|
||||
|
||||
|
||||
function badDefine(message) {
|
||||
log("BAD DEFINE! " + message);
|
||||
}
|
||||
13
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/four.js
vendored
Normal file
13
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/four.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
(function () {
|
||||
|
||||
function define(msg) {
|
||||
log('STILL GOOD, inner define: ' + msg);
|
||||
}
|
||||
|
||||
if (typeof define !== 'function') { var define = window.badDefine; }
|
||||
|
||||
define("four.js script");
|
||||
|
||||
|
||||
}());
|
||||
|
||||
47
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/index.html
vendored
Normal file
47
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/index.html
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>var define Test</title>
|
||||
<script type="text/javascript" src="../common.js"></script>
|
||||
<script type="text/javascript" src="define.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var attachScript = function(url, name){
|
||||
var node = document.createElement("script");
|
||||
node.src = url;
|
||||
node.type = "text/javascript";
|
||||
node.charset = "utf-8";
|
||||
node.setAttribute("data-name", name);
|
||||
|
||||
document.getElementsByTagName("head")[0].appendChild(node);
|
||||
}
|
||||
|
||||
var urls = [
|
||||
"one.js",
|
||||
"two.js",
|
||||
"three.js",
|
||||
"four.js"
|
||||
]
|
||||
|
||||
var loadUrls = function() {
|
||||
for (var i = 0, url; url = urls[i]; i++) {
|
||||
attachScript(url, url);
|
||||
}
|
||||
}
|
||||
|
||||
//Do appendChilds
|
||||
loadUrls();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>var define Test</h1>
|
||||
|
||||
<p>This test checks if doing a var define in a module file is hoisted
|
||||
and if it causes any problems in a way that would shadow the real define.</p>
|
||||
|
||||
<p>Check the console for output</p>
|
||||
|
||||
<p>If you see "BAD DEFINE" in the output, then it means there is a problem,
|
||||
and the real define was shadowed by something else.</p>
|
||||
</body>
|
||||
</html>
|
||||
4
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/one.js
vendored
Normal file
4
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/one.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
if (typeof define !== 'function') { var define = window.badDefine; }
|
||||
|
||||
define("one.js script");
|
||||
3
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/three.js
vendored
Normal file
3
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/three.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
if (typeof define !== 'function') { var define = window.badDefine; }
|
||||
|
||||
define("three.js script");
|
||||
7
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/two.js
vendored
Normal file
7
OfficeWeb/vendor/requirejs/tests/browsertests/vardefine/two.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
if (typeof define !== 'function') { var define = window.badDefine; }
|
||||
|
||||
define("two.js script");
|
||||
setTimeout(function () {
|
||||
define("two.js timeout, expected");
|
||||
}, 13);
|
||||
Reference in New Issue
Block a user