Skip to content

Commit

Permalink
Update tests for NavigatorID
Browse files Browse the repository at this point in the history
  • Loading branch information
foolip committed Oct 6, 2016
1 parent 1341204 commit ade9e8c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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) {
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");
}
22 changes: 0 additions & 22 deletions workers/interfaces/WorkerUtils/navigator/window-only.worker.js

This file was deleted.

0 comments on commit ade9e8c

Please sign in to comment.