1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Helper routines for generating bad load tests.
6 // Webpage must have an 'embeds' div for injecting NaCl modules.
7 // Depends on nacltest.js.
9 function createModule(id
, src
, type
) {
10 return createNaClEmbed({
20 function addModule(module
) {
21 $('embeds').appendChild(module
);
25 function removeModule(module
) {
26 $('embeds').removeChild(module
);
30 function badLoadTest(tester
, id
, src
, type
, error_string
) {
31 tester
.addAsyncTest(id
, function(test
){
32 var module
= createModule(id
, src
, type
);
34 test
.expectEvent(module
, 'load', function(e
) {
36 test
.fail('Module loaded successfully.');
38 test
.expectEvent(module
, 'error', function(e
) {
39 test
.assertEqual(module
.readyState
, 4);
40 if (error_string
instanceof RegExp
)
41 test
.assertRegexMatches(module
.lastError
, error_string
);
43 test
.assertEqual(module
.lastError
, error_string
);
44 test
.expectEvent(module
, 'loadend', function(e
) {