Changeset 232733 in webkit


Ignore:
Timestamp:
Jun 11, 2018 3:15:05 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

Add support for webkit-test-runner jscOptions in DumpRenderTree and WebKitTestRunner.
https://bugs.webkit.org/show_bug.cgi?id=186451
<rdar://problem/40875792>

Reviewed by Tim Horton.

Source/JavaScriptCore:

Enhance setOptions() to be able to take a comma separated options string in
addition to white space separated options strings.

  • runtime/Options.cpp:

(JSC::isSeparator):
(JSC::Options::setOptions):

Tools:

This jscOptions option can be used by a layout test to specify some JSC runtime
options needed by the test e.g. by adding something like this to the top of the
html file after the DOCTYPE tag:

<!-- webkit-test-runner [ jscOptions=--useIntlPluralRules=true ] -->

If more than one option is needed, the options can be specified as a comma
separated string e.g.

<!-- webkit-test-runner [ jscOptions=--useIntlPluralRules=true,--useZombieMode=true ] -->

This only works with JSC options that can be changed at runtime. Not all JSC
options can be changed this way as some options are only checked and set once at
VM / process initialization time: changing this type of options may have no
effect. It's the test writer's responsibility to determine which options are
appropriate for with this webkit-test-runner jscOptions option.

This implementation is a workaround until we can change the run-webkit-tests
scripts to parse the option and apply it to a new launch of DRT or WKTR:
https://bugs.webkit.org/show_bug.cgi?id=186452

  • DumpRenderTree/TestOptions.cpp:

(TestOptions::TestOptions):
(TestOptions::webViewIsCompatibleWithOptions const):

  • DumpRenderTree/TestOptions.h:
  • DumpRenderTree/mac/DumpRenderTree.mm:

(setJSCOptions):
(resetWebViewToConsistentStateBeforeTesting):

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::didReceiveMessageToPage):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetStateToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):

  • WebKitTestRunner/TestOptions.h:

(WTR::TestOptions::hasSameInitializationOptions const):

LayoutTests:

  • js/intl-numberformat-format-to-parts.html:
  • js/intl-pluralrules.html:
  • js/script-tests/intl-numberformat-format-to-parts.js:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232730 r232733  
     12018-06-11  Mark Lam  <mark.lam@apple.com>
     2
     3        Add support for webkit-test-runner jscOptions in DumpRenderTree and WebKitTestRunner.
     4        https://bugs.webkit.org/show_bug.cgi?id=186451
     5        <rdar://problem/40875792>
     6
     7        Reviewed by Tim Horton.
     8
     9        * js/intl-numberformat-format-to-parts.html:
     10        * js/intl-pluralrules.html:
     11        * js/script-tests/intl-numberformat-format-to-parts.js:
     12
    1132018-06-11  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/js/intl-numberformat-format-to-parts.html

    r231867 r232733  
    1 <!doctype html>
     1<!doctype html><!-- webkit-test-runner [ jscOptions=--useIntlNumberFormatToParts=true ] -->
    22<html>
    33<head>
  • trunk/LayoutTests/js/intl-pluralrules.html

    r231047 r232733  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useIntlPluralRules=true ] -->
    22<html>
    33<head>
  • trunk/LayoutTests/js/script-tests/intl-numberformat-format-to-parts.js

    r231892 r232733  
    11//@ skip if $hostOS == "windows" or $hostOS == "darwin" or $hostOS == "linux"
     2//@ requireOptions("--useIntlNumberFormatToParts=true")
     3
    24description("This test checks the behavior of Intl.NumberFormat.prototype.formatToParts as described in the ECMAScript Internationalization API Specification.");
    35
  • trunk/Source/JavaScriptCore/ChangeLog

    r232719 r232733  
     12018-06-11  Mark Lam  <mark.lam@apple.com>
     2
     3        Add support for webkit-test-runner jscOptions in DumpRenderTree and WebKitTestRunner.
     4        https://bugs.webkit.org/show_bug.cgi?id=186451
     5        <rdar://problem/40875792>
     6
     7        Reviewed by Tim Horton.
     8
     9        Enhance setOptions() to be able to take a comma separated options string in
     10        addition to white space separated options strings.
     11
     12        * runtime/Options.cpp:
     13        (JSC::isSeparator):
     14        (JSC::Options::setOptions):
     15
    1162018-06-11  Michael Saboff  <msaboff@apple.com>
    217
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r232719 r232733  
    600600}
    601601
     602static bool isSeparator(char c)
     603{
     604    return isASCIISpace(c) || (c == ',');
     605}
     606
    602607bool Options::setOptions(const char* optionsStr)
    603608{
     
    610615
    611616    while (p < end) {
    612         // Skip white space.
    613         while (p < end && isASCIISpace(*p))
     617        // Skip separators (white space or commas).
     618        while (p < end && isSeparator(*p))
    614619            p++;
    615620        if (p == end)
     
    638643        }
    639644
    640         // Find next white space.
    641         while (p < end && !isASCIISpace(*p))
     645        // Find next separator (white space or commas).
     646        while (p < end && !isSeparator(*p))
    642647            p++;
    643648        if (!p)
  • trunk/Tools/ChangeLog

    r232732 r232733  
     12018-06-11  Mark Lam  <mark.lam@apple.com>
     2
     3        Add support for webkit-test-runner jscOptions in DumpRenderTree and WebKitTestRunner.
     4        https://bugs.webkit.org/show_bug.cgi?id=186451
     5        <rdar://problem/40875792>
     6
     7        Reviewed by Tim Horton.
     8
     9        This jscOptions option can be used by a layout test to specify some JSC runtime
     10        options needed by the test e.g. by adding something like this to the top of the
     11        html file after the DOCTYPE tag:
     12            <!-- webkit-test-runner [ jscOptions=--useIntlPluralRules=true ] -->
     13
     14        If more than one option is needed, the options can be specified as a comma
     15        separated string e.g.
     16            <!-- webkit-test-runner [ jscOptions=--useIntlPluralRules=true,--useZombieMode=true ] -->
     17
     18        This only works with JSC options that can be changed at runtime.  Not all JSC
     19        options can be changed this way as some options are only checked and set once at
     20        VM / process initialization time: changing this type of options may have no
     21        effect.  It's the test writer's responsibility to determine which options are
     22        appropriate for with this webkit-test-runner jscOptions option.
     23
     24        This implementation is a workaround until we can change the run-webkit-tests
     25        scripts to parse the option and apply it to a new launch of DRT or WKTR:
     26        https://bugs.webkit.org/show_bug.cgi?id=186452
     27
     28        * DumpRenderTree/TestOptions.cpp:
     29        (TestOptions::TestOptions):
     30        (TestOptions::webViewIsCompatibleWithOptions const):
     31        * DumpRenderTree/TestOptions.h:
     32        * DumpRenderTree/mac/DumpRenderTree.mm:
     33        (setJSCOptions):
     34        (resetWebViewToConsistentStateBeforeTesting):
     35        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     36        (WTR::InjectedBundle::didReceiveMessageToPage):
     37        * WebKitTestRunner/TestController.cpp:
     38        (WTR::TestController::resetStateToConsistentValues):
     39        (WTR::updateTestOptionsFromTestHeader):
     40        * WebKitTestRunner/TestOptions.h:
     41        (WTR::TestOptions::hasSameInitializationOptions const):
     42
    1432018-06-11  Brady Eidson  <beidson@apple.com>
    244
  • trunk/Tools/DumpRenderTree/TestOptions.cpp

    r232559 r232733  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    104104        else if (key == "enableColorFilter")
    105105            enableColorFilter = parseBooleanTestHeaderValue(value);
     106        else if (key == "jscOptions")
     107            jscOptions = value;
    106108        pairStart = pairEnd + 1;
    107109    }
     
    110112bool TestOptions::webViewIsCompatibleWithOptions(const TestOptions& other) const
    111113{
    112     return other.layerBackedWebView == layerBackedWebView;
     114    return other.layerBackedWebView == layerBackedWebView
     115        && other.jscOptions == jscOptions;
    113116}
  • trunk/Tools/DumpRenderTree/TestOptions.h

    r232559 r232733  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444    bool allowCrossOriginSubresourcesToAskForCredentials { false };
    4545    bool enableColorFilter { false };
     46    std::string jscOptions;
    4647
    4748    TestOptions(const std::string& pathOrURL, const std::string& absolutePath);
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r232559 r232733  
    5858#import "WorkQueueItem.h"
    5959#import <CoreFoundation/CoreFoundation.h>
     60#import <JavaScriptCore/Options.h>
    6061#import <JavaScriptCore/TestRunnerUtils.h>
    6162#import <WebCore/LogInitialization.h>
     
    9798#import <wtf/RetainPtr.h>
    9899#import <wtf/Threading.h>
     100#import <wtf/text/StringBuilder.h>
    99101#import <wtf/text/WTFString.h>
    100102
     
    17701772#endif
    17711773
     1774static void setJSCOptions(const TestOptions& options)
     1775{
     1776    static WTF::StringBuilder savedOptions;
     1777
     1778    if (!savedOptions.isEmpty()) {
     1779        JSC::Options::setOptions(savedOptions.toString().ascii().data());
     1780        savedOptions.clear();
     1781    }
     1782
     1783    if (options.jscOptions.length()) {
     1784        JSC::Options::dumpAllOptionsInALine(savedOptions);
     1785        JSC::Options::setOptions(options.jscOptions.c_str());
     1786    }
     1787}
     1788
    17721789static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
    17731790{
     
    18491866#endif
    18501867
     1868    setJSCOptions(options);
     1869
    18511870    [mainFrame _clearOpener];
    18521871
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r231222 r232733  
    11/*
    2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include "StringFunctions.h"
    3232#include "WebCoreTestSupport.h"
     33#include <JavaScriptCore/Options.h>
    3334#include <WebKit/WKBundle.h>
    3435#include <WebKit/WKBundlePage.h>
     
    222223        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    223224        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     225        WKRetainPtr<WKStringRef> jscOptionsKey(AdoptWK, WKStringCreateWithUTF8CString("JSCOptions"));
     226        WKRetainPtr<WKStringRef> jscOptionsString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, jscOptionsKey.get()));
     227        if (jscOptionsString) {
     228            String options = toWTFString(jscOptionsString);
     229            JSC::Options::setOptions(options.utf8().data());
     230        }
    224231
    225232        WKRetainPtr<WKStringRef> shouldGCKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldGC"));
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r232732 r232733  
    11/*
    2  * Copyright (C) 2010, 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    806806    WKDictionarySetItem(resetMessageBody.get(), allowedHostsKey.get(), allowedHostsValue.get());
    807807
     808    if (options.jscOptions.length()) {
     809        WKRetainPtr<WKStringRef> jscOptionsKey = adoptWK(WKStringCreateWithUTF8CString("JSCOptions"));
     810        WKRetainPtr<WKStringRef> jscOptionsValue = adoptWK(WKStringCreateWithUTF8CString(options.jscOptions.c_str()));
     811        WKDictionarySetItem(resetMessageBody.get(), jscOptionsKey.get(), jscOptionsValue.get());
     812    }
     813
    808814    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), resetMessageBody.get());
    809815
     
    10801086        if (key == "language")
    10811087            String(value.c_str()).split(",", false, testOptions.overrideLanguages);
    1082         if (key == "useThreadedScrolling")
     1088        else if (key == "useThreadedScrolling")
    10831089            testOptions.useThreadedScrolling = parseBooleanTestHeaderValue(value);
    1084         if (key == "useAcceleratedDrawing")
     1090        else if (key == "useAcceleratedDrawing")
    10851091            testOptions.useAcceleratedDrawing = parseBooleanTestHeaderValue(value);
    1086         if (key == "useFlexibleViewport")
     1092        else if (key == "useFlexibleViewport")
    10871093            testOptions.useFlexibleViewport = parseBooleanTestHeaderValue(value);
    1088         if (key == "useDataDetection")
     1094        else if (key == "useDataDetection")
    10891095            testOptions.useDataDetection = parseBooleanTestHeaderValue(value);
    1090         if (key == "useMockScrollbars")
     1096        else if (key == "useMockScrollbars")
    10911097            testOptions.useMockScrollbars = parseBooleanTestHeaderValue(value);
    1092         if (key == "needsSiteSpecificQuirks")
     1098        else if (key == "needsSiteSpecificQuirks")
    10931099            testOptions.needsSiteSpecificQuirks = parseBooleanTestHeaderValue(value);
    1094         if (key == "ignoresViewportScaleLimits")
     1100        else if (key == "ignoresViewportScaleLimits")
    10951101            testOptions.ignoresViewportScaleLimits = parseBooleanTestHeaderValue(value);
    1096         if (key == "useCharacterSelectionGranularity")
     1102        else if (key == "useCharacterSelectionGranularity")
    10971103            testOptions.useCharacterSelectionGranularity = parseBooleanTestHeaderValue(value);
    1098         if (key == "enableAttachmentElement")
     1104        else if (key == "enableAttachmentElement")
    10991105            testOptions.enableAttachmentElement = parseBooleanTestHeaderValue(value);
    1100         if (key == "enableIntersectionObserver")
     1106        else if (key == "enableIntersectionObserver")
    11011107            testOptions.enableIntersectionObserver = parseBooleanTestHeaderValue(value);
    1102         if (key == "enableMenuItemElement")
     1108        else if (key == "enableMenuItemElement")
    11031109            testOptions.enableMenuItemElement = parseBooleanTestHeaderValue(value);
    1104         if (key == "enableModernMediaControls")
     1110        else if (key == "enableModernMediaControls")
    11051111            testOptions.enableModernMediaControls = parseBooleanTestHeaderValue(value);
    1106         if (key == "enablePointerLock")
     1112        else if (key == "enablePointerLock")
    11071113            testOptions.enablePointerLock = parseBooleanTestHeaderValue(value);
    1108         if (key == "enableWebAuthentication")
     1114        else if (key == "enableWebAuthentication")
    11091115            testOptions.enableWebAuthentication = parseBooleanTestHeaderValue(value);
    1110         if (key == "enableIsSecureContextAttribute")
     1116        else if (key == "enableIsSecureContextAttribute")
    11111117            testOptions.enableIsSecureContextAttribute = parseBooleanTestHeaderValue(value);
    1112         if (key == "enableInspectorAdditions")
     1118        else if (key == "enableInspectorAdditions")
    11131119            testOptions.enableInspectorAdditions = parseBooleanTestHeaderValue(value);
    1114         if (key == "dumpJSConsoleLogInStdErr")
     1120        else if (key == "dumpJSConsoleLogInStdErr")
    11151121            testOptions.dumpJSConsoleLogInStdErr = parseBooleanTestHeaderValue(value);
    1116         if (key == "applicationManifest")
     1122        else if (key == "applicationManifest")
    11171123            testOptions.applicationManifest = parseStringTestHeaderValueAsRelativePath(value, pathOrURL);
    1118         if (key == "allowCrossOriginSubresourcesToAskForCredentials")
     1124        else if (key == "allowCrossOriginSubresourcesToAskForCredentials")
    11191125            testOptions.allowCrossOriginSubresourcesToAskForCredentials = parseBooleanTestHeaderValue(value);
    1120         if (key == "enableWebAnimationsCSSIntegration")
     1126        else if (key == "enableWebAnimationsCSSIntegration")
    11211127            testOptions.enableWebAnimationsCSSIntegration = parseBooleanTestHeaderValue(value);
    1122         if (key == "enableProcessSwapOnNavigation")
     1128        else if (key == "enableProcessSwapOnNavigation")
    11231129            testOptions.enableProcessSwapOnNavigation = parseBooleanTestHeaderValue(value);
    1124         if (key == "enableProcessSwapOnWindowOpen")
     1130        else if (key == "enableProcessSwapOnWindowOpen")
    11251131            testOptions.enableProcessSwapOnWindowOpen = parseBooleanTestHeaderValue(value);
    1126         if (key == "enableColorFilter")
     1132        else if (key == "enableColorFilter")
    11271133            testOptions.enableColorFilter = parseBooleanTestHeaderValue(value);
     1134        else if (key == "jscOptions")
     1135            testOptions.jscOptions = value;
    11281136        pairStart = pairEnd + 1;
    11291137    }
  • trunk/Tools/WebKitTestRunner/TestOptions.h

    r232729 r232733  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6464    Vector<String> overrideLanguages;
    6565    std::string applicationManifest;
    66    
     66    std::string jscOptions;
     67
    6768    TestOptions(const std::string& pathOrURL);
    6869
     
    9394            || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation
    9495            || enableProcessSwapOnWindowOpen != options.enableProcessSwapOnWindowOpen
    95             || enableColorFilter != options.enableColorFilter)
     96            || enableColorFilter != options.enableColorFilter
     97            || jscOptions != options.jscOptions)
    9698            return false;
    9799
Note: See TracChangeset for help on using the changeset viewer.