Title: [206926] trunk
Revision
206926
Author
[email protected]
Date
2016-10-07 12:37:30 -0700 (Fri, 07 Oct 2016)

Log Message

Regression(r201970): productSub / vendor / vendorSub should not be exposed 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:
- https://github.com/whatwg/html/pull/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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206925 => 206926)


--- trunk/LayoutTests/ChangeLog	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/LayoutTests/ChangeLog	2016-10-07 19:37:30 UTC (rev 206926)
@@ -1,3 +1,15 @@
+2016-10-07  Chris Dumez  <[email protected]>
+
+        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  <[email protected]>
 
         Marking http/tests/xmlhttprequest/auth-reject-protection-space.html as flaky on mac-wk2.

Modified: trunk/LayoutTests/fast/workers/resources/worker-navigator.js (206925 => 206926)


--- trunk/LayoutTests/fast/workers/resources/worker-navigator.js	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/LayoutTests/fast/workers/resources/worker-navigator.js	2016-10-07 19:37:30 UTC (rev 206926)
@@ -21,10 +21,10 @@
 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'");

Modified: trunk/LayoutTests/fast/workers/worker-navigator-expected.txt (206925 => 206926)


--- trunk/LayoutTests/fast/workers/worker-navigator-expected.txt	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/LayoutTests/fast/workers/worker-navigator-expected.txt	2016-10-07 19:37:30 UTC (rev 206926)
@@ -8,10 +8,10 @@
 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

Modified: trunk/Source/WebCore/ChangeLog (206925 => 206926)


--- trunk/Source/WebCore/ChangeLog	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/Source/WebCore/ChangeLog	2016-10-07 19:37:30 UTC (rev 206926)
@@ -1,3 +1,27 @@
+2016-10-07  Chris Dumez  <[email protected]>
+
+        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  <[email protected]>
 
         Disable URLParser logs by default in all builds

Modified: trunk/Source/WebCore/bindings/scripts/generate-bindings.pl (206925 => 206926)


--- trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2016-10-07 19:37:30 UTC (rev 206926)
@@ -143,9 +143,13 @@
     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;
                 }
             }
@@ -153,6 +157,8 @@
 
             # 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;
 
@@ -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;
 
@@ -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;
 
@@ -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) = @_;

Modified: trunk/Source/WebCore/page/NavigatorID.idl (206925 => 206926)


--- trunk/Source/WebCore/page/NavigatorID.idl	2016-10-07 19:03:53 UTC (rev 206925)
+++ trunk/Source/WebCore/page/NavigatorID.idl	2016-10-07 19:37:30 UTC (rev 206926)
@@ -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;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to