sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
58 lines (45 loc) • 1.69 kB
HTML
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
Author: nicksantos@google.com (Nick Santos)
-->
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JsUnit tests for goog.module.ModuleLoadCallback</title>
<script src="../base.js"></script>
<script>
goog.require('goog.debug.ErrorHandler');
goog.require('goog.debug.entryPointRegistry');
goog.require('goog.functions');
goog.require('goog.module.ModuleLoadCallback');
goog.require('goog.testing.jsunit');
goog.require('goog.testing.recordFunction');
</script>
</head>
<body>
<script type='text/javascript'>
function testProtectEntryPoint() {
// Test a callback created before the protect method is called.
var callback1 = new goog.module.ModuleLoadCallback(
goog.functions.error('callback1'));
var errorFn = goog.testing.recordFunction();
var errorHandler = new goog.debug.ErrorHandler(errorFn);
goog.debug.entryPointRegistry.monitorAll(errorHandler);
assertEquals(0, errorFn.getCallCount());
assertThrows(goog.bind(callback1.execute, callback1));
assertEquals(1, errorFn.getCallCount());
assertContains('callback1', errorFn.getLastCall().getArguments()[0].message);
// Test a callback created after the protect method is called.
var callback2 = new goog.module.ModuleLoadCallback(
goog.functions.error('callback2'));
assertThrows(goog.bind(callback1.execute, callback2));
assertEquals(2, errorFn.getCallCount());
assertContains('callback2', errorFn.getLastCall().getArguments()[0].message);
}
</script>
</body>
</html>