3.0 source code
This commit is contained in:
5
OfficeWeb/vendor/requirejs/tests/text/local.js
vendored
Normal file
5
OfficeWeb/vendor/requirejs/tests/text/local.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
define(['text!./resources/local.html'], function (localHtml) {
|
||||
return {
|
||||
localHtml: localHtml
|
||||
}
|
||||
});
|
||||
1
OfficeWeb/vendor/requirejs/tests/text/plain.txt
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/text/plain.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
hello world
|
||||
1
OfficeWeb/vendor/requirejs/tests/text/resources/local.html
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/text/resources/local.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<h1>Local</h1>
|
||||
8
OfficeWeb/vendor/requirejs/tests/text/resources/sample.html
vendored
Normal file
8
OfficeWeb/vendor/requirejs/tests/text/resources/sample.html
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>sample.html</title>
|
||||
<script type="text/javascript" src="../require.js"></script>
|
||||
</head>
|
||||
<body class="foo" onload="alert('hello')"><span>Hello World!</span></body>
|
||||
</html>
|
||||
2
OfficeWeb/vendor/requirejs/tests/text/separate.js
vendored
Normal file
2
OfficeWeb/vendor/requirejs/tests/text/separate.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
//Stub file for testing optimization of all plugin resources in a build.
|
||||
define(['text!resources/sample.html!strip'], function () {});
|
||||
8
OfficeWeb/vendor/requirejs/tests/text/subwidget.html
vendored
Normal file
8
OfficeWeb/vendor/requirejs/tests/text/subwidget.html
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>sample.html</title>
|
||||
<script type="text/javascript" src="../require.js"></script>
|
||||
</head>
|
||||
<body class="foo" onload="alert('hello')"><div data-type="subwidget"><h1>This is a subwidget</h1></div></body>
|
||||
</html>
|
||||
10
OfficeWeb/vendor/requirejs/tests/text/subwidget.js
vendored
Normal file
10
OfficeWeb/vendor/requirejs/tests/text/subwidget.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
define("subwidget",
|
||||
["text!subwidget.html!strip", "text!subwidget2.html"],
|
||||
function(template, template2) {
|
||||
return {
|
||||
name: "subwidget",
|
||||
template: template,
|
||||
template2: template2
|
||||
};
|
||||
}
|
||||
);
|
||||
1
OfficeWeb/vendor/requirejs/tests/text/subwidget2.html
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/text/subwidget2.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<span>This! is template2</span>
|
||||
53
OfficeWeb/vendor/requirejs/tests/text/text.html
vendored
Normal file
53
OfficeWeb/vendor/requirejs/tests/text/text.html
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: Text Test</title>
|
||||
<script type="text/javascript" src="../../require.js"></script>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
<script type="text/javascript">
|
||||
require({
|
||||
baseUrl: "./",
|
||||
paths: {
|
||||
text: "../../../text/text"
|
||||
} //, priority: ['widgetlayer']
|
||||
});
|
||||
require(
|
||||
["require", "widget", "local", "text!resources/sample.html!strip"],
|
||||
function(require, widget, local, sampleText) {
|
||||
doh.register(
|
||||
"text",
|
||||
[
|
||||
function text(t){
|
||||
t.is("<span>Hello World!</span>", sampleText);
|
||||
t.is('<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>', widget.template);
|
||||
t.is('subwidget', widget.subWidgetName);
|
||||
t.is('<div data-type="subwidget"><h1>This is a subwidget</h1></div>', widget.subWidgetTemplate);
|
||||
t.is('<span>This! is template2</span>', widget.subWidgetTemplate2);
|
||||
t.is('<h1>Local</h1>', local.localHtml);
|
||||
},
|
||||
|
||||
function textLocalXhr(t){
|
||||
var text = require('text');
|
||||
t.is(true, text.useXhr('./some/thing.html', 'http', 'some.domain.com'));
|
||||
t.is(false, text.useXhr('https://some.domain.com/some/thing.html', 'http', 'some.domain.com'));
|
||||
t.is(false, text.useXhr('http://domain.com/some/thing.html', 'http', 'some.domain.com'));
|
||||
t.is(true, text.useXhr('//some.domain.com/some/thing.html', 'http', 'some.domain.com'));
|
||||
t.is(true, text.useXhr('https://some.domain.com:444/some/thing.html', 'https', 'some.domain.com', '444'));
|
||||
t.is(false, text.useXhr('https://some.domain.com/some/thing.html', 'https', 'some.domain.com', '444'));
|
||||
t.is(true, text.useXhr('http://localhost/some/thing.html', 'http', 'localhost'));
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: Text Test</h1>
|
||||
<p>Test for usage of text! require plugin.
|
||||
<p>Check console for messages</p>
|
||||
</body>
|
||||
</html>
|
||||
14
OfficeWeb/vendor/requirejs/tests/text/textBuilt.html
vendored
Normal file
14
OfficeWeb/vendor/requirejs/tests/text/textBuilt.html
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: Text Built Test</title>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
<script type="text/javascript" data-main="textBuilt" src="../../require.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: Text Built Test</h1>
|
||||
<p>Test for usage of text! require plugin in a build scenario where text resources are inlined.
|
||||
<p>Check console for messages</p>
|
||||
</body>
|
||||
</html>
|
||||
64
OfficeWeb/vendor/requirejs/tests/text/textBuilt.js
vendored
Normal file
64
OfficeWeb/vendor/requirejs/tests/text/textBuilt.js
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
(function () {
|
||||
define('text',[],function () {
|
||||
var text = {
|
||||
load: function (name, req, onLoad, config) {
|
||||
throw "THE TEXT PLUGIN LOAD() FUNCTION SHOULD NOT BE CALLED";
|
||||
}
|
||||
};
|
||||
|
||||
return text;
|
||||
});
|
||||
}());
|
||||
define('text!subwidget.html!strip', function () { return '<div data-type="subwidget"><h1>This is a subwidget</h1></div>';});
|
||||
define('text!subwidget2.html', function () { return '<span>This! is template2</span>';});
|
||||
|
||||
define("subwidget",
|
||||
["text!subwidget.html!strip", "text!subwidget2.html"],
|
||||
function(template, template2) {
|
||||
return {
|
||||
name: "subwidget",
|
||||
template: template,
|
||||
template2: template2
|
||||
};
|
||||
}
|
||||
);
|
||||
define('text!widget.html', function () { return '<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>';});
|
||||
|
||||
define("widget",
|
||||
["subwidget", "text!widget.html"],
|
||||
function(subwidget, template) {
|
||||
return {
|
||||
subWidgetName: subwidget.name,
|
||||
subWidgetTemplate: subwidget.template,
|
||||
subWidgetTemplate2: subwidget.template2,
|
||||
template: template
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
/****************** TEST CODE IS BELOW ******************/
|
||||
|
||||
require({
|
||||
baseUrl: "./",
|
||||
paths: {
|
||||
text: "../../../text/text"
|
||||
}
|
||||
});
|
||||
require(
|
||||
["widget"],
|
||||
function(widget) {
|
||||
doh.register(
|
||||
"text",
|
||||
[
|
||||
function text(t){
|
||||
t.is('<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>', widget.template);
|
||||
t.is('subwidget', widget.subWidgetName);
|
||||
t.is('<div data-type="subwidget"><h1>This is a subwidget</h1></div>', widget.subWidgetTemplate);
|
||||
t.is('<span>This! is template2</span>', widget.subWidgetTemplate2);
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
|
||||
}
|
||||
);
|
||||
49
OfficeWeb/vendor/requirejs/tests/text/textOnError.html
vendored
Normal file
49
OfficeWeb/vendor/requirejs/tests/text/textOnError.html
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: Text onError Test</title>
|
||||
<script type="text/javascript" src="../../require.js"></script>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
<script type="text/javascript">
|
||||
require({
|
||||
baseUrl: "./",
|
||||
paths: {
|
||||
text: "../../../text/text"
|
||||
}
|
||||
});
|
||||
|
||||
var master = new doh.Deferred();
|
||||
doh.register(
|
||||
"textOnError",
|
||||
[
|
||||
{
|
||||
name: "textOnError",
|
||||
timeout: 2000,
|
||||
runTest: function () {
|
||||
return master;
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
|
||||
require(
|
||||
["text!doesnotexist.html"],
|
||||
function(doesNotExist) {
|
||||
doh.is(false, true, "This should not fire");
|
||||
master.callback(false);
|
||||
|
||||
}, function (err) {
|
||||
doh.is(404, err.xhr.status);
|
||||
master.callback(true);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: Text Test</h1>
|
||||
<p>Test for text! plugin triggering an error.
|
||||
<p>Check console for messages</p>
|
||||
</body>
|
||||
</html>
|
||||
53
OfficeWeb/vendor/requirejs/tests/text/textOnXhr.html
vendored
Normal file
53
OfficeWeb/vendor/requirejs/tests/text/textOnXhr.html
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: Text onXhr Test</title>
|
||||
<script type="text/javascript" src="../../require.js"></script>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
<script type="text/javascript">
|
||||
var fired = false;
|
||||
|
||||
require({
|
||||
baseUrl: "./",
|
||||
paths: {
|
||||
text: "../../../text/text"
|
||||
},
|
||||
config: {
|
||||
text: {
|
||||
onXhr: function (xhr, url) {
|
||||
doh.is(true, !!xhr);
|
||||
doh.is(true, url.indexOf('plain.txt') !== -1);
|
||||
fired = true;
|
||||
if (/\.txt$/.test(url) && xhr.overrideMimeType) {
|
||||
xhr.overrideMimeType('text/plain; charset=utf8');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
require(
|
||||
["text!plain.txt"],
|
||||
function(plainText) {
|
||||
doh.register(
|
||||
"textonXhr",
|
||||
[
|
||||
function textOnXhr(t){
|
||||
t.is(true, plainText.indexOf('hello world') === 0);
|
||||
t.is(true, fired);
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: Text onXhr Test</h1>
|
||||
<p>Test onXhr for the text plugin.
|
||||
<p>Check console for messages</p>
|
||||
</body>
|
||||
</html>
|
||||
35
OfficeWeb/vendor/requirejs/tests/text/textOnly.html
vendored
Normal file
35
OfficeWeb/vendor/requirejs/tests/text/textOnly.html
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: Text Test</title>
|
||||
<script type="text/javascript" src="../../require.js"></script>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
<script type="text/javascript">
|
||||
require({
|
||||
baseUrl: "./",
|
||||
paths: {
|
||||
text: "../../../text/text"
|
||||
}
|
||||
},
|
||||
["text!resources/sample.html!strip"],
|
||||
function(sampleText) {
|
||||
doh.register(
|
||||
"textOnly",
|
||||
[
|
||||
function textOnly(t){
|
||||
t.is("<span>Hello World!</span>", sampleText);
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: Text Test</h1>
|
||||
<p>Test for usage of text! require plugin.
|
||||
<p>Check console for messages</p>
|
||||
</body>
|
||||
</html>
|
||||
1
OfficeWeb/vendor/requirejs/tests/text/widget.html
vendored
Normal file
1
OfficeWeb/vendor/requirejs/tests/text/widget.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>
|
||||
11
OfficeWeb/vendor/requirejs/tests/text/widget.js
vendored
Normal file
11
OfficeWeb/vendor/requirejs/tests/text/widget.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
define("widget",
|
||||
["subwidget", "text!widget.html"],
|
||||
function(subwidget, template) {
|
||||
return {
|
||||
subWidgetName: subwidget.name,
|
||||
subWidgetTemplate: subwidget.template,
|
||||
subWidgetTemplate2: subwidget.template2,
|
||||
template: template
|
||||
};
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user