Bug 1347425 - Part 2: Add a test for replacing multiple occurrences of a regex in the site-specific UA override; r=mcmanus
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 24 Mar 2017 23:47:20 -0400
changeset 350289 c4a14403d17a7b41b9d96ae7e3a563c0d29c9b3a
parent 350288 9206126bc23284918193314e0ef0692afe8b16c5
child 350290 35a915c6babcb9c9ea287d86dbbfa37c6dcd59d6
push id31570
push userryanvm@gmail.com
push dateWed, 29 Mar 2017 13:42:06 +0000
treeherdermozilla-central@6ea713ccc9ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1347425
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1347425 - Part 2: Add a test for replacing multiple occurrences of a regex in the site-specific UA override; r=mcmanus
netwerk/test/mochitests/test_user_agent_overrides.html
--- a/netwerk/test/mochitests/test_user_agent_overrides.html
+++ b/netwerk/test/mochitests/test_user_agent_overrides.html
@@ -24,16 +24,21 @@ const UA_WHOLE_OVERRIDE = "DummyUserAgen
 const UA_WHOLE_EXPECTED = UA_WHOLE_OVERRIDE;
 
 const UA_PARTIAL_FROM = "\\wozilla"; // /\wozilla
 const UA_PARTIAL_SEP = "#";
 const UA_PARTIAL_TO = UA_WHOLE_OVERRIDE;
 const UA_PARTIAL_OVERRIDE = UA_PARTIAL_FROM + UA_PARTIAL_SEP + UA_PARTIAL_TO;
 const UA_PARTIAL_EXPECTED = DEFAULT_UA.replace(new RegExp(UA_PARTIAL_FROM, 'g'), UA_PARTIAL_TO);
 
+const UA_PARTIAL_FROM2 = "[0-9]+";
+const UA_PARTIAL_TO2 = "number";
+const UA_PARTIAL_OVERRIDE2 = UA_PARTIAL_FROM2 + UA_PARTIAL_SEP + UA_PARTIAL_TO2;
+const UA_PARTIAL_EXPECTED2 = DEFAULT_UA.replace(new RegExp(UA_PARTIAL_FROM2, 'g'), UA_PARTIAL_TO2);
+
 function testUAIFrame(host, expected, sameQ, message, testNavQ, navSameQ, navMessage, callback) {
   let url = location.pathname;
   url = host + url.slice(0, url.lastIndexOf('/')) + '/user_agent.sjs';
   let ifr = document.createElement('IFRAME');
 
   ifr.src = url;
 
   document.getElementById('content').appendChild(ifr);
@@ -117,16 +122,23 @@ var tests = [
   // should support partial overrides
   {
     domain: location.hostname,
     override: UA_PARTIAL_OVERRIDE,
     test_hosts: [location.origin],
     expected: UA_PARTIAL_EXPECTED
   },
 
+  {
+    domain: location.hostname,
+    override: UA_PARTIAL_OVERRIDE2,
+    test_hosts: [location.origin],
+    expected: UA_PARTIAL_EXPECTED2
+  },
+
   // should match domain and subdomains
   {
     domain: 'example.org',
     override: UA_WHOLE_OVERRIDE,
     test_hosts: ['http://example.org',
                  'http://test1.example.org',
                  'http://sub1.test1.example.org'],
     expected: UA_WHOLE_EXPECTED