forked from requirejs/requirejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextOnXhr.html
More file actions
53 lines (50 loc) · 1.43 KB
/
textOnXhr.html
File metadata and controls
53 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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>