⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286949 in webkit


Ignore:
Timestamp:
Dec 13, 2021, 8:50:00 AM (5 years ago)
Author:
Antti Koivisto
Message:

[CSS Cascade Layers] Unflake and fix web-platform-tests/css/css-cascade/layer-statement-before-import.html
https://bugs.webkit.org/show_bug.cgi?id=233944

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-cascade/layer-statement-before-import-expected.txt:
  • web-platform-tests/css/css-cascade/layer-statement-before-import.html:

Data URLs in @imports are not guaranteed to decode synchronously so make the test async.
Also catch exceptions from asserts for cleanup so failures don't affect other subtests.

Source/WebCore:

Inserting rules before early layer statements may be legal if they are moved to the regular rule list.

  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::wrapperInsertRule):

LayoutTests:

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286948 r286949  
     12021-12-13  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Cascade Layers] Unflake and fix web-platform-tests/css/css-cascade/layer-statement-before-import.html
     4        https://bugs.webkit.org/show_bug.cgi?id=233944
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestExpectations:
     9
    1102021-12-13  Tyler Wilcock  <tyler_w@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r286942 r286949  
    21862186webkit.org/b/233937 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-011.html [ ImageOnlyFailure ]
    21872187webkit.org/b/233937 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-012.html [ ImageOnlyFailure ]
    2188 webkit.org/b/233944 imported/w3c/web-platform-tests/css/css-cascade/layer-statement-before-import.html [ Pass Failure ]
    21892188
    21902189webkit.org/b/148801 imported/w3c/web-platform-tests/css/css-color/t422-rgba-onscreen-b.xht [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r286940 r286949  
     12021-12-13  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Cascade Layers] Unflake and fix web-platform-tests/css/css-cascade/layer-statement-before-import.html
     4        https://bugs.webkit.org/show_bug.cgi?id=233944
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/css-cascade/layer-statement-before-import-expected.txt:
     9        * web-platform-tests/css/css-cascade/layer-statement-before-import.html:
     10
     11        Data URLs in @imports are not guaranteed to decode synchronously so make the test async.
     12        Also catch exceptions from asserts for cleanup so failures don't affect other subtests.
     13
    1142021-12-13  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-statement-before-import-expected.txt

    r286647 r286949  
    1 CONSOLE MESSAGE: TypeError: Illegal constructor
    21
    3 Harness Error (FAIL), message = TypeError: Illegal constructor
     2PASS length and item
     3PASS insertRule before imports
     4PASS insertRule after imports
     5PASS insert other rules to pre-import layer statements fails
     6PASS insert other rules before the first layer statement without imports
     7PASS deleteRule before imports
     8PASS deleteRule after imports
     9FAIL replaceSync clears stale layer statements promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    410
    5 FAIL length and item assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    6 FAIL insertRule before imports assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    7 FAIL insertRule after imports assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    8 FAIL insert other rules to pre-import layer statements fails assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    9 FAIL insert other rules before the first layer statement without imports The operation would yield an incorrect node tree.
    10 FAIL deleteRule before imports assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    11 FAIL deleteRule after imports assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    12 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-statement-before-import.html

    r286647 r286949  
    160160
    161161for (let testCase of testCases) {
    162   let styleElement;
    163   let sheet;
    164   if (!testCase.constructedStyleSheet) {
    165     styleElement = document.createElement('style');
    166     styleElement.textContent = testCase.style;
    167     document.head.append(styleElement);
    168     sheet = styleElement.sheet;
    169   } else {
    170     sheet = new CSSStyleSheet();
    171     sheet.replaceSync(testCase.style);
    172     document.adoptedStyleSheets = [sheet];
    173   }
     162  promise_test(async t => {
     163    let styleElement;
     164    let sheet;
     165    if (!testCase.constructedStyleSheet) {
     166      styleElement = document.createElement('style');
     167      styleElement.textContent = testCase.style;
     168      await new Promise(resolve => {
     169        styleElement.onload = resolve;
     170        styleElement.onerror = resolve;
     171        document.head.append(styleElement);
     172      });
     173      sheet = styleElement.sheet;
     174    } else {
     175      sheet = new CSSStyleSheet();
     176      sheet.replaceSync(testCase.style);
     177      document.adoptedStyleSheets = [sheet];
     178    }
    174179
    175   test(() => {
    176     testCase.operations(sheet);
    177     assert_equals(getComputedStyle(target).color, getComputedStyle(reference).color);
    178   },testCase.title);
    179 
    180   if (styleElement)
    181     styleElement.remove();
    182   document.adoptedStyleSheets = [];
     180    try {
     181      testCase.operations(sheet);
     182      assert_equals(getComputedStyle(target).color, getComputedStyle(reference).color);
     183    } finally {
     184      if (styleElement)
     185        styleElement.remove();
     186      document.adoptedStyleSheets = [];
     187    }
     188  }, testCase.title);
    183189}
    184190</script>
  • trunk/Source/WebCore/ChangeLog

    r286945 r286949  
     12021-12-13  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Cascade Layers] Unflake and fix web-platform-tests/css/css-cascade/layer-statement-before-import.html
     4        https://bugs.webkit.org/show_bug.cgi?id=233944
     5
     6        Reviewed by Simon Fraser.
     7
     8        Inserting rules before early layer statements may be legal if they are moved to the regular rule list.
     9
     10        * css/StyleSheetContents.cpp:
     11        (WebCore::StyleSheetContents::wrapperInsertRule):
     12
    1132021-12-13  Adrian Perez de Castro  <aperez@igalia.com>
    214
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r286916 r286949  
    238238    // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
    239239    ASSERT(!rule->isCharsetRule());
    240    
     240
     241    // Maybe the insert will be legal if we treat early layer statement rules as normal child rules?
     242    auto shouldMoveLayerRulesBeforeImportToNormalChildRules = [&] {
     243        if (index >= m_layerRulesBeforeImportRules.size())
     244            return false;
     245        if (!m_importRules.isEmpty() || !m_namespaceRules.isEmpty())
     246            return false;
     247        bool isLayerStatement = is<StyleRuleLayer>(rule) && downcast<StyleRuleLayer>(rule.get()).isStatement();
     248        return !rule->isImportRule() && !rule->isNamespaceRule() && !isLayerStatement;
     249    };
     250
     251    if (shouldMoveLayerRulesBeforeImportToNormalChildRules())
     252        m_childRules.insertVector(0, std::exchange(m_layerRulesBeforeImportRules, { }));
     253
    241254    unsigned childVectorIndex = index;
    242255    if (childVectorIndex < m_layerRulesBeforeImportRules.size() || (childVectorIndex == m_layerRulesBeforeImportRules.size() && is<StyleRuleLayer>(rule))) {
     
    269282
    270283    if (childVectorIndex < m_namespaceRules.size() || (childVectorIndex == m_namespaceRules.size() && rule->isNamespaceRule())) {
    271         // Inserting non-namespace rules other than import rule before @namespace is
     284        // Inserting non-namespace rules other than import and layer statement rules before @namespace is
    272285        // not allowed.
    273286        if (!is<StyleRuleNamespace>(rule))
Note: See TracChangeset for help on using the changeset viewer.