Changeset 206926 in webkit


Ignore:
Timestamp:
Oct 7, 2016 12:37:30 PM (8 years ago)
Author:
Chris Dumez
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:

Test case:

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:

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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206925 r206926  
     12016-10-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r201970): productSub / vendor / vendorSub should not be exposed on WorkerNavigator
     4        https://bugs.webkit.org/show_bug.cgi?id=163124
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update existing test to reflect behavior change.
     9
     10        * fast/workers/resources/worker-navigator.js:
     11        * fast/workers/worker-navigator-expected.txt:
     12
    1132016-10-07  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/fast/workers/resources/worker-navigator.js

    r201970 r206926  
    2222worker.postMessage("eval typeof navigator.platform == 'string'");
    2323worker.postMessage("eval navigator.product === 'Gecko'");
    24 worker.postMessage("eval navigator.productSub === '20030107'");
     24worker.postMessage("eval navigator.productSub === undefined");
    2525worker.postMessage("eval navigator.userAgent.indexOf('WebKit') != 0");
    26 worker.postMessage("eval navigator.vendor === 'Apple Computer, Inc.'");
    27 worker.postMessage("eval navigator.vendorSub === ''");
     26worker.postMessage("eval navigator.vendor === undefined");
     27worker.postMessage("eval navigator.vendorSub === undefined");
    2828
    2929// NavigatorLanguage
  • trunk/LayoutTests/fast/workers/worker-navigator-expected.txt

    r201970 r206926  
    99typeof navigator.platform == 'string': true
    1010navigator.product === 'Gecko': true
    11 navigator.productSub === '20030107': true
     11navigator.productSub === undefined: true
    1212navigator.userAgent.indexOf('WebKit') != 0: true
    13 navigator.vendor === 'Apple Computer, Inc.': true
    14 navigator.vendorSub === '': true
     13navigator.vendor === undefined: true
     14navigator.vendorSub === undefined: true
    1515typeof navigator.language == 'string': true
    1616typeof navigator.onLine == 'boolean': true
  • trunk/Source/WebCore/ChangeLog

    r206924 r206926  
     12016-10-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r201970): productSub / vendor / vendorSub should not be exposed on WorkerNavigator
     4        https://bugs.webkit.org/show_bug.cgi?id=163124
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        productSub / vendor / vendorSub should not be exposed on WorkerNavigator:
     9        - https://html.spec.whatwg.org/#navigatorid
     10
     11        Test case:
     12        - http://w3c-test.org/submissions/3881/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker
     13
     14        Note that the specification also restricts NavigatorID's appCodeName and
     15        product attributes to Window. However, it seems the HTML specification is
     16        about to get updated so that these get exposed to workers:
     17        - https://github.com/whatwg/html/pull/1870
     18
     19        No new tests, updated existing test.
     20
     21        * bindings/scripts/generate-bindings.pl:
     22        (shouldPropertyBeExposed):
     23        * page/NavigatorID.idl:
     24
    1252016-10-07  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebCore/bindings/scripts/generate-bindings.pl

    r206904 r206926  
    144144        if (!$interface->isPartial || $interface->name eq $targetInterfaceName) {
    145145            my $targetDataNode;
     146            my @targetGlobalContexts;
    146147            foreach my $interface (@{$targetDocument->interfaces}) {
    147148                if ($interface->name eq $targetInterfaceName) {
    148149                    $targetDataNode = $interface;
     150                    my $exposedAttribute = $targetDataNode->extendedAttributes->{"Exposed"} || "Window";
     151                    $exposedAttribute = substr($exposedAttribute, 1, -1) if substr($exposedAttribute, 0, 1) eq "(";
     152                    @targetGlobalContexts = split(",", $exposedAttribute);
    149153                    last;
    150154                }
     
    154158            # Support for attributes of partial interfaces.
    155159            foreach my $attribute (@{$interface->attributes}) {
     160                next unless shouldPropertyBeExposed($attribute->signature, \@targetGlobalContexts);
     161
    156162                # Record that this attribute is implemented by $interfaceName.
    157163                $attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;
     
    166172            # Support for methods of partial interfaces.
    167173            foreach my $function (@{$interface->functions}) {
     174                next unless shouldPropertyBeExposed($function->signature, \@targetGlobalContexts);
     175
    168176                # Record that this method is implemented by $interfaceName.
    169177                $function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;
     
    178186            # Support for constants of partial interfaces.
    179187            foreach my $constant (@{$interface->constants}) {
     188                next unless shouldPropertyBeExposed($constant, \@targetGlobalContexts);
     189
    180190                # Record that this constant is implemented by $interfaceName.
    181191                $constant->extendedAttributes->{"ImplementedBy"} = $interfaceName if $interface->isPartial;
     
    196206my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, $preprocessor, $writeDependencies, $verbose, $targetIdlFile);
    197207$codeGen->ProcessDocument($targetDocument, $defines);
     208
     209# Attributes / Operations / Constants of supplemental interfaces can have an [Exposed=XX] attribute which restricts
     210# on which global contexts they should be exposed.
     211sub shouldPropertyBeExposed
     212{
     213    my ($signature, $targetGlobalContexts) = @_;
     214
     215    my $exposed = $signature->extendedAttributes->{Exposed};
     216
     217    return 1 unless $exposed;
     218
     219    $exposed = substr($exposed, 1, -1) if substr($exposed, 0, 1) eq "(";
     220    my @sourceGlobalContexts = split(",", $exposed);
     221
     222    for my $targetGlobalContext (@$targetGlobalContexts) {
     223        return 1 if grep(/^$targetGlobalContext$/, @sourceGlobalContexts);
     224    }
     225    return 0;
     226}
    198227
    199228sub generateEmptyHeaderAndCpp
  • trunk/Source/WebCore/page/NavigatorID.idl

    r201970 r206926  
    3535    [Nondeterministic] readonly attribute DOMString platform;
    3636    [Nondeterministic] readonly attribute DOMString product;
    37     [Nondeterministic] readonly attribute DOMString productSub;
     37    [Nondeterministic, Exposed=Window] readonly attribute DOMString productSub;
    3838    [Nondeterministic] readonly attribute DOMString userAgent;
    39     [Nondeterministic] readonly attribute DOMString vendor;
    40     [Nondeterministic] readonly attribute DOMString vendorSub;
     39    [Nondeterministic, Exposed=Window] readonly attribute DOMString vendor;
     40    [Nondeterministic, Exposed=Window] readonly attribute DOMString vendorSub;
    4141};
Note: See TracChangeset for help on using the changeset viewer.