-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update tests for NavigatorID #3881
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,7 @@ function run_test() { | |
}, "appCodeName"); | ||
|
||
test(function() { | ||
assert_equals(typeof navigator.appName, "string", | ||
"navigator.appName should be a string"); | ||
assert_equals(navigator.appName, "Netscape"); | ||
}, "appName"); | ||
|
||
test(function() { | ||
|
@@ -23,31 +22,25 @@ function run_test() { | |
}, "product"); | ||
|
||
test(function() { | ||
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555 | ||
if ("window" in self) { | ||
// If you identify as WebKit, taintEnabled should not exist. | ||
if (navigator.userAgent.indexOf("WebKit") != -1) { | ||
assert_false("taintEnabled" in navigator); | ||
} | ||
// Otherwise it should exist and return false. | ||
else { | ||
assert_false(navigator.taintEnabled()); | ||
if (navigator.userAgent.indexOf("Chrome") != -1 || | ||
navigator.userAgent.indexOf("WebKit") != -1) { | ||
// "If the navigator compatibility mode is Chrome or WebKit" | ||
assert_equals(navigator.productSub, "20030107"); | ||
} else { | ||
// "If the navigator compatibility mode is Gecko" | ||
assert_equals(navigator.productSub, "20100101"); | ||
} | ||
} else { | ||
// taintEnabled should not exist in workers. | ||
assert_false("taintEnabled" in navigator); | ||
assert_false("productSub" in navigator); | ||
} | ||
}, "taintEnabled"); | ||
}, "productSub"); | ||
|
||
test(function() { | ||
assert_equals(typeof navigator.userAgent, "string", | ||
"navigator.userAgent should be a string"); | ||
}, "userAgent type"); | ||
|
||
test(function() { | ||
assert_equals(navigator.vendorSub, ""); | ||
}, "vendorSub"); | ||
|
||
async_test(function() { | ||
var request = new XMLHttpRequest(); | ||
request.onload = this.step_func_done(function() { | ||
|
@@ -60,4 +53,51 @@ function run_test() { | |
"filter_name=User-Agent"); | ||
request.send(); | ||
}, "userAgent value"); | ||
|
||
test(function() { | ||
if ("window" in self) { | ||
if (navigator.userAgent.indexOf("Chrome") != -1) { | ||
// "If the navigator compatibility mode is Chrome" | ||
assert_equals(navigator.vendor, "Google Inc."); | ||
} else if (navigator.userAgent.indexOf("WebKit") != -1) { | ||
// "If the navigator compatibility mode is WebKit" | ||
assert_equals(navigator.vendor, "Apple Computer, Inc."); | ||
} else { | ||
// "If the navigator compatibility mode is Gecko" | ||
assert_equals(navigator.vendor, ""); | ||
} | ||
} else { | ||
assert_false("vendor" in navigator); | ||
} | ||
}, "vendor"); | ||
|
||
test(function() { | ||
if ("window" in self) { | ||
assert_equals(navigator.vendorSub, ""); | ||
} else { | ||
assert_false("vendorSub" in navigator); | ||
} | ||
}, "vendorSub"); | ||
|
||
// "If the navigator compatibility mode is Gecko, then the user agent must | ||
// also support the following partial interface" (taintEnabled() and oscpu) | ||
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555 and | ||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27820 | ||
|
||
test(function() { | ||
if ("window" in self && navigator.userAgent.indexOf("WebKit") == -1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file uses several different ways of testing navigator compatibility mode, not all of which are compatible. E.g. here Gecko means "does not have the string WebKit", where above Gecko means "does not have the string WebKit or the string Chrome". It would be good to factor this out into a variable (in the test file) that is one of "Chrome", "WebKit", or "Gecko", and then the test code proper could say |
||
assert_false(navigator.taintEnabled()); | ||
} else { | ||
assert_false("taintEnabled" in navigator); | ||
} | ||
}, "taintEnabled"); | ||
|
||
test(function() { | ||
if ("window" in self && navigator.userAgent.indexOf("WebKit") == -1) { | ||
assert_equals(typeof navigator.oscpu, "string", | ||
"navigator.oscpu should be a string"); | ||
} else { | ||
assert_false("oscpu" in navigator); | ||
} | ||
}, "oscpu"); | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this could be
navigator.userAgent.includes("Chrome")
for clarity.