@@ -32,4 +32,87 @@ describe('WebOSDriver', function () {
32
32
it ( 'should be importable and instantiable' , function ( ) {
33
33
should . exist ( new WebOSDriver ( ) ) ;
34
34
} ) ;
35
+
36
+
37
+ describe ( 'useUAForBrowserIfNotPresent' , function ( ) {
38
+ it ( 'should use Browser as-is if the given value had the exact value' , function ( ) {
39
+ const driver = new WebOSDriver ( ) ;
40
+ const jsonResponse = {
41
+ 'Browser' : 'Chrome/87.0.4280.88' ,
42
+ 'Protocol-Version' : '1.3' ,
43
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' ,
44
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
45
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
46
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
47
+ } ;
48
+ driver . useUAForBrowserIfNotPresent ( jsonResponse ) . should . eql ( {
49
+ 'Browser' : 'Chrome/87.0.4280.88' ,
50
+ 'Protocol-Version' : '1.3' ,
51
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' ,
52
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
53
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
54
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
55
+ } ) ;
56
+ } ) ,
57
+
58
+ it ( 'should use UA for the Browser if the Browser was an empty string' , function ( ) {
59
+ const driver = new WebOSDriver ( ) ;
60
+ const jsonResponse = {
61
+ 'Browser' : '' ,
62
+ 'Protocol-Version' : '1.3' ,
63
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' ,
64
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
65
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
66
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
67
+ } ;
68
+ driver . useUAForBrowserIfNotPresent ( jsonResponse ) . should . eql ( {
69
+ 'Browser' : 'Chrome/87.0.4280.88' ,
70
+ 'Protocol-Version' : '1.3' ,
71
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' ,
72
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
73
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
74
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
75
+ } ) ;
76
+ } ) ,
77
+
78
+ it ( 'should use Browser as-is if the Browser was an empty string AND the UA did not exist' , function ( ) {
79
+ const driver = new WebOSDriver ( ) ;
80
+ const jsonResponse = {
81
+ 'Browser' : '' ,
82
+ 'Protocol-Version' : '1.3' ,
83
+ 'User-Agent' : '' ,
84
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
85
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
86
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
87
+ } ;
88
+ driver . useUAForBrowserIfNotPresent ( jsonResponse ) . should . eql ( {
89
+ 'Browser' : '' ,
90
+ 'Protocol-Version' : '1.3' ,
91
+ 'User-Agent' : '' ,
92
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
93
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
94
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
95
+ } ) ;
96
+ } ) ,
97
+
98
+ it ( 'should use Browser as-is if the Browser was an empty string AND the UA did not have chrome' , function ( ) {
99
+ const driver = new WebOSDriver ( ) ;
100
+ const jsonResponse = {
101
+ 'Browser' : '' ,
102
+ 'Protocol-Version' : '1.3' ,
103
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36' ,
104
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
105
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
106
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
107
+ } ;
108
+ driver . useUAForBrowserIfNotPresent ( jsonResponse ) . should . eql ( {
109
+ 'Browser' : '' ,
110
+ 'Protocol-Version' : '1.3' ,
111
+ 'User-Agent' : 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36' ,
112
+ 'V8-Version' : '8.7.220.(29*1000 + 2)' ,
113
+ 'WebKit-Version' : '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)' ,
114
+ 'webSocketDebuggerUrl' : 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
115
+ } ) ;
116
+ } ) ;
117
+ } ) ;
35
118
} ) ;
0 commit comments