sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
60 lines (47 loc) • 1.57 kB
HTML
<html>
<!--
Copyright 2008 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 andybons@google.com (Andrew Bonventre)
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.testing.MockUserAgent</title>
<script src="../base.js"></script>
<script>
goog.require('goog.testing.MockUserAgent');
goog.require('goog.testing.jsunit');
goog.require('goog.userAgent');
</script>
</head>
<body>
<script>
function testMockUserAgentInstall() {
var userAgent = new goog.testing.MockUserAgent();
var originalUserAgentFunction = goog.userAgent.getUserAgentString;
assertFalse(!!userAgent.installed_);
userAgent.install();
assertTrue(userAgent.installed_);
assertNotEquals(goog.userAgent.getUserAgentString,
originalUserAgentFunction);
userAgent.uninstall();
assertFalse(userAgent.installed_);
assertEquals(originalUserAgentFunction, goog.userAgent.getUserAgentString);
}
function testMockUserAgentGetAgent() {
var uaString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) ' +
'AppleWebKit/525.13 (KHTML, like Gecko) ' +
'Chrome/0.2.149.27 Safari/525.13';
var userAgent = new goog.testing.MockUserAgent();
userAgent.setUserAgentString(uaString);
userAgent.install();
assertTrue(userAgent.installed_);
assertEquals(uaString, goog.userAgent.getUserAgentString());
}
</script>
</body>
</html>