blob: 2c9e525952c9181e0f682173bb7617ac045ac578 (
plain)
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
54
55
56
57
58
59
|
<!DOCTYPE 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>
|