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
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Helper routines for generating bad load tests.
// Webpage must have an 'embeds' div for injecting NaCl modules.
// Depends on nacltest.js.
function createModule(id, src, type) {
return createNaClEmbed({
id: id,
src: src,
width: 100,
height: 20,
type: type
});
}
function addModule(module) {
$('embeds').appendChild(module);
}
function removeModule(module) {
$('embeds').removeChild(module);
}
function badLoadTest(tester, id, src, type, error_string) {
tester.addAsyncTest(id, function(test){
var module = createModule(id, src, type);
test.expectEvent(module, 'load', function(e) {
removeModule(module);
test.fail('Module loaded successfully.');
});
test.expectEvent(module, 'error', function(e) {
test.assertEqual(module.readyState, 4);
test.assertEqual(module.lastError, error_string);
test.expectEvent(module, 'loadend', function(e) {
removeModule(module);
test.pass();
});
});
addModule(module);
});
}
|