Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Regression(r201970): productSub / vendor / vendorSub should not be ex…
…posed on WorkerNavigator

https://bugs.webkit.org/show_bug.cgi?id=163124

Reviewed by Ryosuke Niwa.

Source/WebCore:

productSub / vendor / vendorSub should not be exposed on WorkerNavigator:
- https://html.spec.whatwg.org/#navigatorid

Test case:
- http://w3c-test.org/submissions/3881/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker

Note that the specification also restricts NavigatorID's appCodeName and
product attributes to Window. However, it seems the HTML specification is
about to get updated so that these get exposed to workers:
- whatwg/html#1870

No new tests, updated existing test.

* bindings/scripts/generate-bindings.pl:
(shouldPropertyBeExposed):
* page/NavigatorID.idl:

LayoutTests:

Update existing test to reflect behavior change.

* fast/workers/resources/worker-navigator.js:
* fast/workers/worker-navigator-expected.txt:


Canonical link: https://commits.webkit.org/180976@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Oct 7, 2016
1 parent 9163069 commit bc3ab8f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 9 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
2016-10-07 Chris Dumez <cdumez@apple.com>

Regression(r201970): productSub / vendor / vendorSub should not be exposed on WorkerNavigator
https://bugs.webkit.org/show_bug.cgi?id=163124

Reviewed by Ryosuke Niwa.

Update existing test to reflect behavior change.

* fast/workers/resources/worker-navigator.js:
* fast/workers/worker-navigator-expected.txt:

2016-10-07 Ryan Haddad <ryanhaddad@apple.com>

Marking http/tests/xmlhttprequest/auth-reject-protection-space.html as flaky on mac-wk2.
Expand Down
6 changes: 3 additions & 3 deletions LayoutTests/fast/workers/resources/worker-navigator.js
Expand Up @@ -21,10 +21,10 @@ worker.postMessage("eval navigator.appName === 'Netscape'");
worker.postMessage("eval navigator.appVersion.indexOf('WebKit') != 0");
worker.postMessage("eval typeof navigator.platform == 'string'");
worker.postMessage("eval navigator.product === 'Gecko'");
worker.postMessage("eval navigator.productSub === '20030107'");
worker.postMessage("eval navigator.productSub === undefined");
worker.postMessage("eval navigator.userAgent.indexOf('WebKit') != 0");
worker.postMessage("eval navigator.vendor === 'Apple Computer, Inc.'");
worker.postMessage("eval navigator.vendorSub === ''");
worker.postMessage("eval navigator.vendor === undefined");
worker.postMessage("eval navigator.vendorSub === undefined");

// NavigatorLanguage
worker.postMessage("eval typeof navigator.language == 'string'");
Expand Down
6 changes: 3 additions & 3 deletions LayoutTests/fast/workers/worker-navigator-expected.txt
Expand Up @@ -8,10 +8,10 @@ navigator.appName === 'Netscape': true
navigator.appVersion.indexOf('WebKit') != 0: true
typeof navigator.platform == 'string': true
navigator.product === 'Gecko': true
navigator.productSub === '20030107': true
navigator.productSub === undefined: true
navigator.userAgent.indexOf('WebKit') != 0: true
navigator.vendor === 'Apple Computer, Inc.': true
navigator.vendorSub === '': true
navigator.vendor === undefined: true
navigator.vendorSub === undefined: true
typeof navigator.language == 'string': true
typeof navigator.onLine == 'boolean': true
DONE
Expand Down
24 changes: 24 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
2016-10-07 Chris Dumez <cdumez@apple.com>

Regression(r201970): productSub / vendor / vendorSub should not be exposed on WorkerNavigator
https://bugs.webkit.org/show_bug.cgi?id=163124

Reviewed by Ryosuke Niwa.

productSub / vendor / vendorSub should not be exposed on WorkerNavigator:
- https://html.spec.whatwg.org/#navigatorid

Test case:
- http://w3c-test.org/submissions/3881/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker

Note that the specification also restricts NavigatorID's appCodeName and
product attributes to Window. However, it seems the HTML specification is
about to get updated so that these get exposed to workers:
- https://github.com/whatwg/html/pull/1870

No new tests, updated existing test.

* bindings/scripts/generate-bindings.pl:
(shouldPropertyBeExposed):
* page/NavigatorID.idl:

2016-10-07 Alex Christensen <achristensen@webkit.org>

Disable URLParser logs by default in all builds
Expand Down
29 changes: 29 additions & 0 deletions Source/WebCore/bindings/scripts/generate-bindings.pl
Expand Up @@ -143,16 +143,22 @@
foreach my $interface (@{$document->interfaces}) {
if (!$interface->isPartial || $interface->name eq $targetInterfaceName) {
my $targetDataNode;
my @targetGlobalContexts;
foreach my $interface (@{$targetDocument->interfaces}) {
if ($interface->name eq $targetInterfaceName) {
$targetDataNode = $interface;
my $exposedAttribute = $targetDataNode->extendedAttributes->{"Exposed"} || "Window";
$exposedAttribute = substr($exposedAttribute, 1, -1) if substr($exposedAttribute, 0, 1) eq "(";
@targetGlobalContexts = split(",", $exposedAttribute);
last;
}
}
die "Not found an interface ${targetInterfaceName} in ${targetInterfaceName}.idl." unless defined $targetDataNode;

# Support for attributes of partial interfaces.
foreach my $attribute (@{$interface->attributes}) {
next unless shouldPropertyBeExposed($attribute->signature, \@targetGlobalContexts);

# Record that this attribute is implemented by $interfaceName.
$attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;

Expand All @@ -165,6 +171,8 @@

# Support for methods of partial interfaces.
foreach my $function (@{$interface->functions}) {
next unless shouldPropertyBeExposed($function->signature, \@targetGlobalContexts);

# Record that this method is implemented by $interfaceName.
$function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;

Expand All @@ -177,6 +185,8 @@

# Support for constants of partial interfaces.
foreach my $constant (@{$interface->constants}) {
next unless shouldPropertyBeExposed($constant, \@targetGlobalContexts);

# Record that this constant is implemented by $interfaceName.
$constant->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;

Expand All @@ -196,6 +206,25 @@
my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, $preprocessor, $writeDependencies, $verbose, $targetIdlFile);
$codeGen->ProcessDocument($targetDocument, $defines);

# Attributes / Operations / Constants of supplemental interfaces can have an [Exposed=XX] attribute which restricts
# on which global contexts they should be exposed.
sub shouldPropertyBeExposed
{
my ($signature, $targetGlobalContexts) = @_;

my $exposed = $signature->extendedAttributes->{Exposed};

return 1 unless $exposed;

$exposed = substr($exposed, 1, -1) if substr($exposed, 0, 1) eq "(";
my @sourceGlobalContexts = split(",", $exposed);

for my $targetGlobalContext (@$targetGlobalContexts) {
return 1 if grep(/^$targetGlobalContext$/, @sourceGlobalContexts);
}
return 0;
}

sub generateEmptyHeaderAndCpp
{
my ($prefix, $targetInterfaceName, $outputHeadersDirectory, $outputDirectory) = @_;
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/page/NavigatorID.idl
Expand Up @@ -34,8 +34,8 @@
[Nondeterministic] readonly attribute DOMString appVersion;
[Nondeterministic] readonly attribute DOMString platform;
[Nondeterministic] readonly attribute DOMString product;
[Nondeterministic] readonly attribute DOMString productSub;
[Nondeterministic, Exposed=Window] readonly attribute DOMString productSub;
[Nondeterministic] readonly attribute DOMString userAgent;
[Nondeterministic] readonly attribute DOMString vendor;
[Nondeterministic] readonly attribute DOMString vendorSub;
[Nondeterministic, Exposed=Window] readonly attribute DOMString vendor;
[Nondeterministic, Exposed=Window] readonly attribute DOMString vendorSub;
};

0 comments on commit bc3ab8f

Please sign in to comment.