diff options
Diffstat (limited to 'tests/wpt/tests')
280 files changed, 12841 insertions, 3721 deletions
diff --git a/tests/wpt/tests/.github/workflows/docker.yml b/tests/wpt/tests/.github/workflows/docker.yml index 06704fff106..12b5adc7ee9 100644 --- a/tests/wpt/tests/.github/workflows/docker.yml +++ b/tests/wpt/tests/.github/workflows/docker.yml @@ -40,7 +40,7 @@ jobs: latest type=raw,value=${{ inputs.tag }} - name: Build and push the Docker image - uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0 + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: ./tools/docker push: true diff --git a/tests/wpt/tests/.github/workflows/pull_request_test_jobs.yml b/tests/wpt/tests/.github/workflows/pull_request_test_jobs.yml new file mode 100644 index 00000000000..4a4f623e84b --- /dev/null +++ b/tests/wpt/tests/.github/workflows/pull_request_test_jobs.yml @@ -0,0 +1,59 @@ +name: "test-jobs" +on: + pull_request: + +jobs: + decision: + name: ./wpt test-jobs + runs-on: ubuntu-24.04 + outputs: + test_jobs: ${{ steps.test_jobs.outputs.test_jobs }} + steps: + - name: checkout + uses: actions/checkout@v4.1.0 + with: + fetch-depth: 2 + - name: ./wpt test-jobs + id: test_jobs + run: | + set -eux + echo "test_jobs=$( ./wpt test-jobs --json HEAD^1..HEAD )" >> $GITHUB_OUTPUT + + affected_safari_preview: + name: "affected tests: Safari Technology Preview" + needs: decision + if: contains(fromJSON(needs.decision.outputs.test_jobs), 'affected_tests') + uses: ./.github/workflows/safari-wptrunner.yml + with: + artifact-name: "safari-preview-affected-tests" + safari-technology-preview: true + safaridriver-diagnose: false + fetch-depth: 2 + extra-options: "--affected ${{ github.sha }}^1" + + affected_without_changes_safari_preview: + name: "affected tests without changes: Safari Technology Preview" + needs: decision + if: contains(fromJSON(needs.decision.outputs.test_jobs), 'affected_tests') + uses: ./.github/workflows/safari-wptrunner.yml + with: + artifact-name: safari-preview-affected-tests-without-changes + safari-technology-preview: true + safaridriver-diagnose: false + fetch-depth: 2 + test-rev: "HEAD^1" + extra-options: "--affected ${{ github.sha }}" + + infrastructure_mac: + name: "infrastructure/ tests: macOS" + needs: decision + if: contains(fromJSON(needs.decision.outputs.test_jobs), 'wptrunner_infrastructure') + uses: ./.github/workflows/safari-wptrunner.yml + with: + artifact-name: safari-infrastructure-results + safari-technology-preview: true + safaridriver-diagnose: false + extra-options: >- + --manifest MANIFEST.json + --metadata infrastructure/metadata/ + --include infrastructure/ diff --git a/tests/wpt/tests/.github/workflows/safari-wptrunner.yml b/tests/wpt/tests/.github/workflows/safari-wptrunner.yml index 9cfc8a7eeeb..d90414d5241 100644 --- a/tests/wpt/tests/.github/workflows/safari-wptrunner.yml +++ b/tests/wpt/tests/.github/workflows/safari-wptrunner.yml @@ -15,6 +15,26 @@ on: description: "Run safaridriver capturing diagnostics" required: true type: boolean + fetch-ref: + description: "The ref to fetch and initially checkout" + required: false + type: string + fetch-depth: + description: "The fetch-depth to checkout" + required: false + type: number + test-rev: + description: "The rev to checkout before running the tests" + required: false + type: string + matrix-include: + description: "Extra items to include in the matrix, to override test-type/current-chunk/total-chunks" + required: false + type: string + extra-options: + description: "Extra options to pass to wpt run" + required: false + type: string # We never interact with the GitHub API, thus we can simply disable all # permissions the GitHub token would have. @@ -29,13 +49,23 @@ jobs: timeout-minutes: 180 strategy: matrix: - current-chunk: [1, 2, 3, 4, 5, 6, 7, 8] - total-chunks: [8] + current-chunk: + - 1 + total-chunks: + - 1 + include: ${{ fromJSON(inputs.matrix-include || '[]') }} steps: - name: checkout uses: actions/checkout@v4.1.0 with: - fetch-depth: 1 + fetch-depth: ${{ inputs.fetch-depth || 1 }} + ref: ${{ inputs.fetch-ref }} + - name: test-checkout + if: inputs.test-rev + env: + REV: ${{ inputs.test-rev }} + run: |- + git switch --force --progress -d "$REV" - name: Set display color profile run: |- ./wpt macos-color-profile @@ -71,8 +101,9 @@ jobs: --no-manifest-update \ --no-restart-on-unexpected \ --no-fail-on-unexpected \ - --this-chunk=${{ matrix.current-chunk }} \ - --total-chunks=${{ matrix.total-chunks }} \ + --no-pause \ + --this-chunk ${{ matrix.current-chunk }} \ + --total-chunks ${{ matrix.total-chunks }} \ --chunk-type hash \ --log-wptreport ${{ runner.temp }}/wpt_report_${{ matrix.current-chunk }}.json \ --log-wptscreenshot ${{ runner.temp }}/wpt_screenshot_${{ matrix.current-chunk }}.txt \ @@ -81,6 +112,8 @@ jobs: --channel ${{ inputs.safari-technology-preview && 'preview' || 'stable' }} \ --kill-safari \ --max-restarts 100 \ + ${{ inputs.extra-options }} \ + -- \ safari - name: Publish results uses: actions/upload-artifact@v4.1.0 @@ -105,8 +138,8 @@ jobs: - name: Cleanup if: always() run: |- - set -ux - sudo sed -i '' '/^# Start web-platform-tests hosts$/,/^# End web-platform-tests hosts$/d' /etc/hosts + set -ux + sudo sed -i '' '/^# Start web-platform-tests hosts$/,/^# End web-platform-tests hosts$/d' /etc/hosts safari-notify: needs: safari-results diff --git a/tests/wpt/tests/.github/workflows/safari_stable.yml b/tests/wpt/tests/.github/workflows/safari_stable.yml index 7c344fe667f..4c2acce5c27 100644 --- a/tests/wpt/tests/.github/workflows/safari_stable.yml +++ b/tests/wpt/tests/.github/workflows/safari_stable.yml @@ -7,7 +7,8 @@ permissions: {} on: workflow_dispatch: workflow_run: - workflows: [epochs] + workflows: + - epochs types: - completed push: @@ -34,3 +35,12 @@ jobs: artifact-name: "safari-results" safari-technology-preview: false safaridriver-diagnose: false + matrix-include: >- + [{"current-chunk": 1, "total-chunks": 8}, + {"current-chunk": 2, "total-chunks": 8}, + {"current-chunk": 3, "total-chunks": 8}, + {"current-chunk": 4, "total-chunks": 8}, + {"current-chunk": 5, "total-chunks": 8}, + {"current-chunk": 6, "total-chunks": 8}, + {"current-chunk": 7, "total-chunks": 8}, + {"current-chunk": 8, "total-chunks": 8}] diff --git a/tests/wpt/tests/.github/workflows/safari_technology_preview.yml b/tests/wpt/tests/.github/workflows/safari_technology_preview.yml index 70827a365ac..e2f4c64f460 100644 --- a/tests/wpt/tests/.github/workflows/safari_technology_preview.yml +++ b/tests/wpt/tests/.github/workflows/safari_technology_preview.yml @@ -7,7 +7,8 @@ permissions: {} on: workflow_dispatch: workflow_run: - workflows: [epochs] + workflows: + - epochs types: - completed push: @@ -34,3 +35,12 @@ jobs: artifact-name: "safari-technology-preview-results" safari-technology-preview: true safaridriver-diagnose: false + matrix-include: >- + [{"current-chunk": 1, "total-chunks": 8}, + {"current-chunk": 2, "total-chunks": 8}, + {"current-chunk": 3, "total-chunks": 8}, + {"current-chunk": 4, "total-chunks": 8}, + {"current-chunk": 5, "total-chunks": 8}, + {"current-chunk": 6, "total-chunks": 8}, + {"current-chunk": 7, "total-chunks": 8}, + {"current-chunk": 8, "total-chunks": 8}] diff --git a/tests/wpt/tests/ai/language_detection/detector-locale.https.window.js b/tests/wpt/tests/ai/language_detection/detector-locale.https.window.js index 80cbfa485e3..1e2efd11c62 100644 --- a/tests/wpt/tests/ai/language_detection/detector-locale.https.window.js +++ b/tests/wpt/tests/ai/language_detection/detector-locale.https.window.js @@ -1,4 +1,4 @@ -// META: title=Detect english +// META: title=LanguageDetector locale tests // META: global=window // META: timeout=long // META: script=resources/util.js @@ -12,23 +12,6 @@ function getAvailability(expectedInputLanguages) { return LanguageDetector.availability({expectedInputLanguages}); } -function assert_availability_consistent( - language_subtag_availability, base_availability) { - if (base_availability == 'unavailable') { - // If the language subtag is not available then no variation of it should - // be available. - assert_equals(language_subtag_availability, 'unavailable'); - } else { - // If the language subtag is available, then it definitely shouldn't be - // unavailable since whatever backing it has could support any variation of - // it. A variation could have a different availability if a more specific - // backing is required. - assert_in_array( - language_subtag_availability, - ['downloadable', 'downloading', 'available']); - } -} - promise_test(async t => { for (const [languageSubtag, variations] of Object.entries( valid_language_tags)) { diff --git a/tests/wpt/tests/ai/language_detection/detector.https.window.js b/tests/wpt/tests/ai/language_detection/detector.https.window.js index 379b8741534..ae21b463538 100644 --- a/tests/wpt/tests/ai/language_detection/detector.https.window.js +++ b/tests/wpt/tests/ai/language_detection/detector.https.window.js @@ -66,16 +66,7 @@ promise_test(async t => { }, 'LanguageDetector.detect() returns valid results'); promise_test(async t => { - const error = new Error('CreateMonitorCallback threw an error'); - function monitor(m) { - m.addEventListener('downloadprogress', e => { - assert_unreached( - 'This should never be reached since monitor throws an error.'); - }); - throw error; - } - - await promise_rejects_exactly(t, error, createLanguageDetector({monitor})); + await testCreateMonitorCallbackThrowsError(t, createLanguageDetector); }, 'If monitor throws an error, LanguageDetector.create() rejects with that error'); promise_test(async t => { diff --git a/tests/wpt/tests/ai/resources/locale-util.js b/tests/wpt/tests/ai/resources/locale-util.js index cacb11f4f25..70a00a5630b 100644 --- a/tests/wpt/tests/ai/resources/locale-util.js +++ b/tests/wpt/tests/ai/resources/locale-util.js @@ -42,3 +42,20 @@ function assert_is_variation(variation_language_tag, expected_language_tag) { const expected_locale = new Intl.Locale(expected_language_tag); assert_equals(variation_locale.language, expected_locale.language); } + +function assert_availability_consistent( + language_subtag_availability, variation_availability) { + if (variation_availability == 'unavailable') { + // If the language subtag is not available then no variation of it should + // be available. + assert_equals(language_subtag_availability, 'unavailable'); + } else { + // If the language subtag is available, then it definitely shouldn't be + // unavailable since whatever backing it has could support any variation of + // it. A variation could have a different availability if a more specific + // backing is required. + assert_in_array( + language_subtag_availability, + ['downloadable', 'downloading', 'available']); + } +} diff --git a/tests/wpt/tests/ai/resources/util.js b/tests/wpt/tests/ai/resources/util.js index 84507a409e9..eda6a17a24f 100644 --- a/tests/wpt/tests/ai/resources/util.js +++ b/tests/wpt/tests/ai/resources/util.js @@ -182,6 +182,20 @@ async function testMonitor(createFunc, options = {}) { return result; } +async function testCreateMonitorCallbackThrowsError( + t, createFunc, options = {}) { + const error = new Error('CreateMonitorCallback threw an error'); + function monitor(m) { + m.addEventListener('downloadprogress', e => { + assert_unreached( + 'This should never be reached since monitor throws an error.'); + }); + throw error; + } + + await promise_rejects_exactly(t, error, createFunc({...options, monitor})); +} + function run_iframe_test(iframe, test_name) { const id = getId(); iframe.contentWindow.postMessage({id, type: test_name}, '*'); diff --git a/tests/wpt/tests/ai/translator/translator-locale.https.window.js b/tests/wpt/tests/ai/translator/translator-locale.https.window.js index 73e7eff20d2..27dd2605576 100644 --- a/tests/wpt/tests/ai/translator/translator-locale.https.window.js +++ b/tests/wpt/tests/ai/translator/translator-locale.https.window.js @@ -1,4 +1,4 @@ -// META: title=Detect english +// META: title=Translator locale tests // META: global=window // META: timeout=long // META: script=resources/util.js @@ -8,7 +8,68 @@ 'use strict'; -function assert_rejects_invalid_expected_input_languages( +function getAvailability(sourceLanguage, targetLanguage) { + return Translator.availability({sourceLanguage, targetLanguage}); +} + +promise_test(async t => { + for (const [sourceLanguageSubtag, sourceVariations] of Object.entries( + valid_language_tags)) { + for (const [targetLanguageSubtag, targetVariations] of Object.entries( + valid_language_tags)) { + const languageSubtagAvailability = + await getAvailability(sourceLanguageSubtag, targetLanguageSubtag); + + // All variations should be consistent with the language subtag. + for (const sourceVariation of sourceVariations) { + for (const targetVariation of targetVariations) { + assert_availability_consistent( + await getAvailability(sourceVariation, targetVariation), + languageSubtagAvailability); + } + } + } + } +}, 'Translator.availability() is consistent between language tag variations'); + +async function assert_valid_languages(inSourceLanguage, inTargetLanguage) { + if (['downloading', 'downloadable'].includes( + await getAvailability(inSourceLanguage, inTargetLanguage))) { + await test_driver.bless(); + } + + const {sourceLanguage: outSourceLanguage, targetLanguage: outTargetLanguage} = + await Translator.create( + {sourceLanguage: inSourceLanguage, targetLanguage: inTargetLanguage}); + + assert_is_variation(inSourceLanguage, outSourceLanguage); + assert_is_canonical(outSourceLanguage); + assert_is_variation(inTargetLanguage, outTargetLanguage); + assert_is_canonical(outTargetLanguage); +} + +promise_test(async t => { + for (const [sourceLanguageSubtag, sourceVariations] of Object.entries( + valid_language_tags)) { + for (const [targetLanguageSubtag, targetVariations] of Object.entries( + valid_language_tags)) { + if (await getAvailability(sourceLanguageSubtag, targetLanguageSubtag) === + 'unavailable') { + continue; + } + + await assert_valid_languages(sourceLanguageSubtag, targetLanguageSubtag); + + for (const sourceVariation of sourceVariations) { + for (const targetVariation of targetVariations) { + await assert_valid_languages(sourceVariation, targetVariation); + } + } + } + } +}, 'Translator has valid source and target languages'); + +function assert_rejects_invalid_languages( t, method, sourceLanguage, targetLanguage) { return promise_rejects_js( t, RangeError, method({sourceLanguage, targetLanguage})); @@ -19,21 +80,21 @@ function testInvalidLanguagePairs(t, method) { // Invalid source language. for (const sourceLanguage of invalid_language_tags) { for (const targetLanguage of allValidLanguageTags) { - assert_rejects_invalid_expected_input_languages( + assert_rejects_invalid_languages( t, method, sourceLanguage, targetLanguage); } } // Invalid target language. for (const sourceLanguage of allValidLanguageTags) { for (const targetLanguage of invalid_language_tags) { - assert_rejects_invalid_expected_input_languages( + assert_rejects_invalid_languages( t, method, sourceLanguage, targetLanguage); } } // Invalid source and target language for (const sourceLanguage of invalid_language_tags) { for (const targetLanguage of invalid_language_tags) { - assert_rejects_invalid_expected_input_languages( + assert_rejects_invalid_languages( t, method, sourceLanguage, targetLanguage); } } @@ -43,8 +104,8 @@ promise_test(async t => { // We don't need to consume user activation since it should throw a RangeError // before it even can check if it needs to consume user activation. testInvalidLanguagePairs(t, Translator.create); -}, 'LanguageDetector.create() throws RangeError for invalid language tags'); +}, 'Translator.create() throws RangeError for invalid language tags'); promise_test(async t => { testInvalidLanguagePairs(t, Translator.availability); -}, 'LanguageDetector.availability() throws RangeError for invalid language tags'); +}, 'Translator.availability() throws RangeError for invalid language tags'); diff --git a/tests/wpt/tests/ai/translator/translator.https.window.js b/tests/wpt/tests/ai/translator/translator.https.window.js new file mode 100644 index 00000000000..722430fe631 --- /dev/null +++ b/tests/wpt/tests/ai/translator/translator.https.window.js @@ -0,0 +1,16 @@ +// META: title=Translator tests +// META: global=window +// META: timeout=long +// META: script=../resources/util.js +// META: script=/resources/testdriver.js +// META: script=resources/util.js +// +// Setting `timeout=long` as this test may require downloading the translation +// library and the language models. + +promise_test(async t => { + // Can pass in valid but unsupported languages since the create monitor error + // should be thrown before language support is checked. + await testCreateMonitorCallbackThrowsError( + t, createTranslator, {sourceLanguage: 'und', targetLanguage: 'und'}); +}, 'If monitor throws an error, LanguageDetector.create() rejects with that error'); diff --git a/tests/wpt/tests/ai/translator/translator.optional.https.window.js b/tests/wpt/tests/ai/translator/translator.optional.https.window.js index 2a4c5a6c5dd..ce01efed143 100644 --- a/tests/wpt/tests/ai/translator/translator.optional.https.window.js +++ b/tests/wpt/tests/ai/translator/translator.optional.https.window.js @@ -1,8 +1,7 @@ -// META: title=Translator Translate +// META: title=Optional Translator tests // META: global=window // META: timeout=long // META: script=../resources/util.js -// META: script=../resources/language_codes.js // META: script=/resources/testdriver.js // META: script=resources/util.js // diff --git a/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html b/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html new file mode 100644 index 00000000000..8e4d04399ff --- /dev/null +++ b/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html @@ -0,0 +1,6 @@ +<!DOCTYPE html> +<link rel="author" title="Oriol Brufau" href="obrufau@igalia.com"> +<link rel="help" href="https://github.com/servo/servo/issues/37312"> + +<div style="float: left"></div> +<div style="width: 10000000000px; overflow: scroll"></div> diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-function-pseudo-element-basic.html b/tests/wpt/tests/css/css-anchor-position/anchor-function-pseudo-element-basic.html new file mode 100644 index 00000000000..70977ca4c40 --- /dev/null +++ b/tests/wpt/tests/css/css-anchor-position/anchor-function-pseudo-element-basic.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<title>Positioning pseudo-elements using anchor functions</title> +<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#positioning"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +body { margin: 0 } +#anchor, #target::before, #target::after { + width: 100px; + height: 100px; + position: absolute; +} +#anchor.moved { + left: 200px; + top: 200px; +} +#anchor { + left: 50px; + top: 100px; + anchor-name: --a; + background: blue; +} +#target::before { + position-anchor: --a; + left: anchor(right); + top: anchor(top); + background: green; + content:''; +} +#target::after { + position-anchor: --a; + left: anchor(left); + top: anchor(bottom); + background: green; + content:''; +} +</style> +<div id=anchor></div> +<div id=target></div> +<script> +test(() => { + assert_equals(getComputedStyle(target, '::before').top, '100px', "#target::before top is positioned against anchor"); + assert_equals(getComputedStyle(target, '::before').left, '150px', "#target::before left is positioned against anchor"); + assert_equals(getComputedStyle(target, '::after').top, '200px', "#target::after top is positioned against anchor"); + assert_equals(getComputedStyle(target, '::after').left, '50px', "#target::after left is positioned against anchor"); +}, "Initial anchored position"); + +test(() => { + anchor.classList.add("moved"); + assert_equals(getComputedStyle(target, '::before').top, '200px', "#target::before top is positioned against anchor"); + assert_equals(getComputedStyle(target, '::before').left, '300px', "#target::before left is positioned against anchor"); + assert_equals(getComputedStyle(target, '::after').top, '300px', "#target::after top is positioned against anchor"); + assert_equals(getComputedStyle(target, '::after').left, '200px', "#target::after left is positioned against anchor"); +}, "Anchored position after moving"); +</script> diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-position-non-anchored-fallback.html b/tests/wpt/tests/css/css-anchor-position/anchor-position-non-anchored-fallback.html new file mode 100644 index 00000000000..26965fe8bf4 --- /dev/null +++ b/tests/wpt/tests/css/css-anchor-position/anchor-position-non-anchored-fallback.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>CSS Anchor Positioning Test: Invalidation of fallback without anchor references</title> +<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-apply"> +<link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> +<style> + #anchor { + anchor-name: --anchor; + background: green; + width: 100px; + height: 100vh; + } + #anchored { + background: green; + top: anchor(--anchor bottom); + width: 100px; + height: 50px; + position: absolute; + position-try: --bottom; + } + + @position-try --bottom { + top: auto; + bottom: 0px; + } +</style> +<p>Test passes if there is a filled green square.</p> +<div id="anchor"></div> +<div id="anchored"></div> +<script> + anchor.offsetTop; + anchor.style.height = "50px"; +</script> diff --git a/tests/wpt/tests/css/css-anchor-position/inherit-height-from-fallback.html b/tests/wpt/tests/css/css-anchor-position/inherit-height-from-fallback.html new file mode 100644 index 00000000000..a1179c62ed0 --- /dev/null +++ b/tests/wpt/tests/css/css-anchor-position/inherit-height-from-fallback.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>CSS Anchor Positioning Test: inherit height from fallback height</title> +<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-try-fallbacks"> +<link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> +<style> + #container { + position: relative; + } + #anchor { + anchor-name: --a1; + width: 0px; + height: 100px; + } + #anchored { + position-area: left center; + position: absolute; + position-anchor: --a1; + position-try-fallbacks: --f1; + width: 100px; + } + #child { + height: inherit; + background: green; + } + @position-try --f1 { + position-area: right center; + height: 100px; + } +</style> +<p>Test passes if there is a filled green square.</p> +<div id="container"> + <div id="anchor"></div> + <div id="anchored"> + <div id="child"></div> + </div> +</div> diff --git a/tests/wpt/tests/css/css-break/WEB_FEATURES.yml b/tests/wpt/tests/css/css-break/WEB_FEATURES.yml index 49ecf06d287..1f47ce3fbaf 100644 --- a/tests/wpt/tests/css/css-break/WEB_FEATURES.yml +++ b/tests/wpt/tests/css/css-break/WEB_FEATURES.yml @@ -2,3 +2,6 @@ features: - name: box-decoration-break files: - box-decoration-break-* +- name: page-break-aliases + files: + - page-break-legacy-shorthands.html diff --git a/tests/wpt/tests/css/css-cascade/scope-visited-cssom.html b/tests/wpt/tests/css/css-cascade/scope-visited-cssom.html index aba4b752b2f..3dc29da6dd3 100644 --- a/tests/wpt/tests/css/css-cascade/scope-visited-cssom.html +++ b/tests/wpt/tests/css/css-cascade/scope-visited-cssom.html @@ -50,8 +50,8 @@ test((t) => { test((t) => { main.append(test_visited.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':visited as scoped selector'); </script> @@ -68,8 +68,8 @@ test((t) => { test((t) => { main.append(test_not_link.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':not(:link) as scoped selector'); </script> @@ -86,8 +86,8 @@ test((t) => { test((t) => { main.append(test_not_visited.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':not(:visited) as scoped selector'); </script> @@ -106,8 +106,8 @@ test((t) => { test((t) => { main.append(test_link_root.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':link as scoping root'); </script> @@ -124,8 +124,8 @@ test((t) => { test((t) => { main.append(test_visited_root.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':visited as scoping root'); </script> @@ -142,8 +142,8 @@ test((t) => { test((t) => { main.append(test_not_visited_root.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':not(:visited) as scoping root'); </script> @@ -160,8 +160,8 @@ test((t) => { test((t) => { main.append(test_not_link_root.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':not(:link) as scoping root'); </script> @@ -180,8 +180,8 @@ test((t) => { test((t) => { main.append(test_link_root_scope.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':link as scoping root, :scope'); </script> @@ -198,8 +198,8 @@ test((t) => { test((t) => { main.append(test_visited_root_scope.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':visited as scoping root, :scope'); </script> @@ -216,8 +216,8 @@ test((t) => { test((t) => { main.append(test_not_visited_root_scope.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':not(:visited) as scoping root, :scope'); </script> @@ -234,8 +234,8 @@ test((t) => { test((t) => { main.append(test_not_link_root_scope.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':not(:link) as scoping root, :scope'); </script> @@ -254,8 +254,8 @@ test((t) => { test((t) => { main.append(test_link_scoping_limit.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':link as scoping limit'); </script> @@ -272,8 +272,8 @@ test((t) => { test((t) => { main.append(test_visited_scoping_limit.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':visited as scoping limit'); </script> @@ -290,8 +290,8 @@ test((t) => { test((t) => { main.append(test_not_link_scoping_limit.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)', 'unvisited'); }, ':not(:link) as scoping limit'); </script> @@ -308,7 +308,7 @@ test((t) => { test((t) => { main.append(test_not_visited_scoping_limit.content.cloneNode(true)); t.add_cleanup(() => main.replaceChildren()); - assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)'); - assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)'); + assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)', 'visited'); + assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)', 'unvisited'); }, ':not(:visited) as scoping limit'); </script> diff --git a/tests/wpt/tests/css/css-contain/parsing/contain-invalid.html b/tests/wpt/tests/css/css-contain/parsing/contain-invalid.html index 9f96bbc2fed..d73e4b4c357 100644 --- a/tests/wpt/tests/css/css-contain/parsing/contain-invalid.html +++ b/tests/wpt/tests/css/css-contain/parsing/contain-invalid.html @@ -25,6 +25,7 @@ test_invalid_value("contain", "size layout size"); test_invalid_value("contain", "paint content"); test_invalid_value("contain", "size inline-size"); test_invalid_value("contain", "inline-size inline-size"); +test_invalid_value("contain", "view-transition view-transition"); </script> </body> </html> diff --git a/tests/wpt/tests/css/css-contain/parsing/contain-valid.tentative.html b/tests/wpt/tests/css/css-contain/parsing/contain-valid.tentative.html new file mode 100644 index 00000000000..da358741b7b --- /dev/null +++ b/tests/wpt/tests/css/css-contain/parsing/contain-valid.tentative.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<link rel="help" href="https://drafts.csswg.org/css-contain-3/#contain-property"> +<!-- TODO link scoped-view-transition-spec once available --> +<meta name="assert" content="contain supports view-transition'."> +<meta name="assert" content="contain serializes in canonical order."> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +</body> +<script> +/* Note this test is an extension of contain-valid. Once + contain: view-transition" is resolved, this test should be moved or + replaced, depending on the resolution. */ +test_valid_value("contain", "view-transition"); +test_valid_value("contain", "view-transition layout", "layout view-transition"); +test_valid_value("contain", + "paint view-transition style", + "style paint view-transition"); +</script> +</html> diff --git a/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-007-crash.html b/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-007-crash.html new file mode 100644 index 00000000000..46306a8ffaa --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-007-crash.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<title>Crash test found by fuzzer. Multicol, non visible overflow without scrollable container and a visible gap rule +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +<div style="columns:2; column-fill:auto; height:100px; column-rule:solid; contain:paint;"> + <div style="height:101px;"></div> +</div> diff --git a/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-008-crash.html b/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-008-crash.html new file mode 100644 index 00000000000..9c03f592cfe --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/agnostic/gap-decorations-008-crash.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<head> + <title>Crash test found by fuzzer.</title> + <link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> + <link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +</head> +<style> + body > * { + column-rule: repeat(5, 100px); + } +</style> +<body> + <fieldset> +</body> diff --git a/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025-ref.html b/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025-ref.html new file mode 100644 index 00000000000..d4cbf509854 --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025-ref.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +<style> + body { + margin: 0; + } + + main { + display: flex; + flex-wrap: wrap; + gap: 10px; + } + + .item { + background-color: teal; + height: 50px; + flex-basis: 100%; + } + + .row-gap { + position: absolute; + top: 50px; + left: 0px; + background: gold; + width: 100%; + height: 10px; + } +</style> +<main> + <div class="item"></div> + <div class="item"></div> + <div class="row-gap"></div> +</main> diff --git a/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025.html b/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025.html new file mode 100644 index 00000000000..42b46a301c3 --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/flex/flex-gap-decorations-025.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title> + CSS Gap Decorations: flex gaps are painted when there's only one flex line +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="match" href="flex-gap-decorations-025-ref.html"> +<link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +<style> + body { + margin: 0; + } + + main { + display: flex; + flex-wrap: wrap; + gap: 10px; + row-rule: 10px solid gold; + } + + .item { + background-color: teal; + height: 50px; + flex-basis: 100%; + } +</style> +<main> + <div class="item"></div> + <div class="item"></div> +</main> diff --git a/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-043-crash.html b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-043-crash.html new file mode 100644 index 00000000000..920e1b4d05a --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-043-crash.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title> + CSS Gap Decorations: Column gutter with no column gaps and row gaps with no row gutter should not crash. +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="author" title="Sam Davis Omekara Jr." href="mailto:samomekarajr@microsoft.com"> +<style> + .grid-container { + display: grid; + column-gap: 40px; + + grid-template: 1fr 1fr / 1fr; + column-rule: solid blue; + } +</style> + +<div class="grid-container"></div> diff --git a/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-044-crash.html b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-044-crash.html new file mode 100644 index 00000000000..b4e69929d2d --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-044-crash.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title> + CSS Gap Decorations: Row gutter with no row gaps and column gaps with no column gutter should not crash. +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="author" title="Sam Davis Omekara Jr." href="mailto:samomekarajr@microsoft.com"> +<style> + .grid-container { + display: grid; + row-gap: 40px; + + grid-template: 1fr/ 1fr 1fr; + row-rule: solid red; + } +</style> + +<div class="grid-container"></div> diff --git a/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045-ref.html b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045-ref.html new file mode 100644 index 00000000000..b002cf0fb3a --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045-ref.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/#break"> +<link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +<style> + #container, + body { + overflow: hidden; + margin: 0px; + } + + #container { + display: grid; + grid-template-rows: 4rem 2rem auto; + width: 80%; + gap: 2px; + border: solid 2px black; + row-rule: 2px solid hotpink, 1px dashed grey; + background-color: teal; + } + + #one { + height: 100px; + width: 100px; + } +</style> +<div id="container"> + <div id="one"></div> +</div> diff --git a/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045.html b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045.html new file mode 100644 index 00000000000..a90d45df442 --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-045.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<title> + CSS Gap Decorations: Make sure decorations resize when container/window resizes. +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="match" href="grid-gap-decorations-045-ref.html"> +<link rel="author" title="Javier Contreras" href="mailto:javiercon@microsoft.com"> +<style> + #container, + body { + overflow: hidden; + margin: 0px; + } + + #container { + display: grid; + grid-template-rows: 4rem 2rem auto; + width: 50%; + gap: 2px; + border: solid 2px black; + row-rule: 2px solid hotpink, 1px dashed grey; + background-color: teal; + } + + #one { + height: 100px; + width: 100px; + } +</style> +<div id="container"> + <div id="one"></div> +</div> +<script> + window.addEventListener('load', function () { + const container = document.getElementById('container'); + container.style.width = '80%'; + }); +</script> diff --git a/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-046.html b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-046.html new file mode 100644 index 00000000000..64ca1cdddff --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/grid/grid-gap-decorations-046.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<title> + CSS Gap Decorations: rules are painted when container contains an OOF child. +</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1/"> +<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> +<link rel="author" title="Sam Davis Omekara Jr." href="mailto:samomekarajr@microsoft.com"> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div style="position: relative; display: grid; grid-template-columns: 0px 0px; grid-template-rows: 100px; column-gap: 100px; column-rule: solid green 100px; width: max-content; background:red;"> + <div id="target" style="position: absolute; left: 0; top: 0;"></div> +</div> +<script> +document.body.offsetTop; +target.style.left = '10px'; +</script> diff --git a/tests/wpt/tests/css/css-gaps/parsing/gap-decorations-rule-initial-value-crash.html b/tests/wpt/tests/css/css-gaps/parsing/gap-decorations-rule-initial-value-crash.html new file mode 100644 index 00000000000..19309e87efc --- /dev/null +++ b/tests/wpt/tests/css/css-gaps/parsing/gap-decorations-rule-initial-value-crash.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Gap Decoration: renderer doesn't crash when rule values are set to initial</title> +<link rel="help" href="https://drafts.csswg.org/css-gaps-1"> +<link rel="author" title="Sam Davis Omekara Jr." href="mailto:samomekarajr@microsoft.com"> +</head> +<body> +<div id="target" style="column-rule-width: initial; column-rule-color: initial; column-rule-style: solid;"></div> +</body> +<script> + document.getElementById("target").style.columnRule; +</script> +</html> diff --git a/tests/wpt/tests/css/css-highlight-api/Highlight-setlike.html b/tests/wpt/tests/css/css-highlight-api/Highlight-setlike.html index 0093f9be232..26b30d2a0be 100644 --- a/tests/wpt/tests/css/css-highlight-api/Highlight-setlike.html +++ b/tests/wpt/tests/css/css-highlight-api/Highlight-setlike.html @@ -62,6 +62,15 @@ }, 'Highlight add and has methods work as expected' + rangesCombinationDescription); test(() => { + let customHighlight = new Highlight(); + customHighlight.add(rangeCollections[i][0]).add(rangeCollections[i][1]); + assert_true(customHighlight.has(rangeCollections[i][0]), 'Highlight.has returns true when it contains the first range added'); + assert_true(customHighlight.has(rangeCollections[i][1]), 'Highlight.has returns true when it contains the second range added'); + assert_false(customHighlight.has(rangeCollections[i][2]), 'Highlight.has returns false when it doesn\'t contain the range which is passed as the argument'); + assert_equals(customHighlight.size, 2, 'Highlight.size is 2 after adding two different ranges by chaining the add method'); + }, "Highlight add method is chainable" + rangesCombinationDescription); + + test(() => { let customHighlight = new Highlight(rangeCollections[i][0], rangeCollections[i][1]); assert_false(customHighlight.delete(rangeCollections[i][2]), 'Highlight.delete returns false when trying to delete a range that is not in the highlight'); assert_true(customHighlight.delete(rangeCollections[i][1]), 'Highlight.delete returns true when trying to delete a range that is in the highlight'); diff --git a/tests/wpt/tests/css/css-highlight-api/HighlightRegistry-maplike.html b/tests/wpt/tests/css/css-highlight-api/HighlightRegistry-maplike.html index d8bbe4731f6..50fccd2347d 100644 --- a/tests/wpt/tests/css/css-highlight-api/HighlightRegistry-maplike.html +++ b/tests/wpt/tests/css/css-highlight-api/HighlightRegistry-maplike.html @@ -70,6 +70,9 @@ assert_equals(CSS.highlights.size, 0, 'HighlightRegistry.clear empties the map.'); CSS.highlights.clear(); assert_equals(CSS.highlights.size, 0, 'HighlightRegistry.clear called with an empty registry keeps it empty.'); + + CSS.highlights.set(name1, h1).set(name2, h2); + assert_equals(CSS.highlights.size, 2, 'HighlightRegistry.size is 2 after inserting two different Highlights by chaining the set method.'); }, 'HighlightRegistry has a maplike interface.'); </script> diff --git a/tests/wpt/tests/css/css-images/image-orientation/image-orientation-exif-png-3.html b/tests/wpt/tests/css/css-images/image-orientation/image-orientation-exif-png-3.html index 536b7d2560c..355c2f601fa 100644 --- a/tests/wpt/tests/css/css-images/image-orientation/image-orientation-exif-png-3.html +++ b/tests/wpt/tests/css/css-images/image-orientation/image-orientation-exif-png-3.html @@ -7,7 +7,7 @@ <link rel="help" href="https://w3c.github.io/PNG-spec/#eXIf"> <link rel="match" href="reference/image-orientation-exif-png-ref.html"> <style> - div { width: 400px; height: 400px } + div { width: 400px; height: 400px; display: inline-block; } div.early { background-image: url(support/F-exif-chunk-early.png)} div.late {background-image: url(support/F-exif-late.png)} </style> diff --git a/tests/wpt/tests/css/css-masking/animations/clip-path-interpolation-shape-control-points.tentative.html b/tests/wpt/tests/css/css-masking/animations/clip-path-interpolation-shape-control-points.html index 03545a15583..03545a15583 100644 --- a/tests/wpt/tests/css/css-masking/animations/clip-path-interpolation-shape-control-points.tentative.html +++ b/tests/wpt/tests/css/css-masking/animations/clip-path-interpolation-shape-control-points.html diff --git a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-007.tentative.html b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-007.html index 5e71923c01b..5e71923c01b 100644 --- a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-007.tentative.html +++ b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-007.html diff --git a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-008.tentative.html b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-008.html index fdeb7971429..fdeb7971429 100644 --- a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-008.tentative.html +++ b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-008.html diff --git a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-009.tentative.html b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-009.html index 8fda73b055e..8fda73b055e 100644 --- a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-009.tentative.html +++ b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-009.html diff --git a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-010.tentative.html b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-010.html index d089a90104c..d089a90104c 100644 --- a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-010.tentative.html +++ b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-010.html diff --git a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.tentative.html b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.html index 11c28021741..11c28021741 100644 --- a/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.tentative.html +++ b/tests/wpt/tests/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.html diff --git a/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-001.html b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-001.html new file mode 100644 index 00000000000..37c6c44f57b --- /dev/null +++ b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-001.html @@ -0,0 +1,33 @@ +<!doctype html> +<meta charset="utf-8" /> +<title> + Contextually invalid selectors due to implicit :is() in nesting should not match and have no + specificity +</title> +<link rel="help" href="https://drafts.csswg.org/css-nesting/#nest-selector" /> +<link + rel="match" + href="/css/reference/ref-filled-green-100px-square-only.html" +/> +<style> + div { + color: green; + background-color: currentColor; + width: 100px; + height: 100px; + } + + p { + color: initial; + } + + *, + ::before { + & * { + color: red; + } + } +</style> + +<p>Test passes if there is a filled green square.</p> +<div></div> diff --git a/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors.html b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-002.html index f3cdc674fd5..7c722468e1c 100644 --- a/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors.html +++ b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-002.html @@ -21,13 +21,6 @@ color: initial; } - *, - ::before { - & * { - color: red; - } - } - :is(*, ::before) * { color: purple; } diff --git a/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-003.html b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-003.html new file mode 100644 index 00000000000..01d0a819fa5 --- /dev/null +++ b/tests/wpt/tests/css/css-nesting/contextually-invalid-selectors-003.html @@ -0,0 +1,33 @@ +<!doctype html> +<meta charset="utf-8" /> +<title> + Contextually invalid selectors due to :is() should not match and have no + specificity +</title> +<link rel="help" href="https://drafts.csswg.org/css-nesting/#nest-selector" /> +<link rel="help" href="https://bugs.webkit.org/show_bug.cgi?id=293230"> +<link + rel="match" + href="/css/reference/ref-filled-green-100px-square-only.html" +/> +<style> + div { + color: green; + background-color: currentColor; + width: 100px; + height: 100px; + } + + p { + color: initial; + } + + div::before { + & { /* `&` must not match the originating element */ + color: red; + } + } +</style> + +<p>Test passes if there is a filled green square.</p> +<div></div> diff --git a/tests/wpt/tests/css/css-overflow/chrome-421199213-crash.html b/tests/wpt/tests/css/css-overflow/chrome-421199213-crash.html new file mode 100644 index 00000000000..1ab02f1a787 --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/chrome-421199213-crash.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<link rel="help" href="https://crbug.com/421199213"> +<style> + #scroller { + overflow: scroll; + scroll-marker-group: before; + } + #item::scroll-marker { content: counter(x); } +</style> +<p>Pass if no crash</p> +<div id="scroller"> + <div id="item"></div> +</div> diff --git a/tests/wpt/tests/css/css-overflow/clip-008.html b/tests/wpt/tests/css/css-overflow/clip-008.html new file mode 100644 index 00000000000..8fb45252aa7 --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/clip-008.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<title>border-radius should not clip contents if overflow is clipped in only one direction</title> +<link rel="author" title="Psychpsyo" href="mailto:psychpsyo@gmail.com" /> +<link rel="help" href="https://www.w3.org/TR/css-overflow-3/#corner-clipping"> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<style> + #testHolder { + width: 100px; + height: 100px; + background-color: red; + } + #clipped { + width: 100px; + height: 100px; + overflow-x: clip; + background-color: wheat; + border-radius: 50%; + } + #contents { + width: 100px; + height: 100px; + background-color: green; + } +</style> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div id="testHolder"> + <div id="clipped"> + <div id="contents"></div> + </div> +</div> diff --git a/tests/wpt/tests/css/css-overflow/overflow-rtl-scroll-left.html b/tests/wpt/tests/css/css-overflow/overflow-rtl-scroll-left.html new file mode 100644 index 00000000000..0c837737546 --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/overflow-rtl-scroll-left.html @@ -0,0 +1,49 @@ +<!doctype html> +<meta charset="utf-8"> +<title>overflow: rtl scroll left should return 0 when overflow size is empty</title> +<link rel="author" href="mailto:perryuwang@gmail.com"> +<link rel="help" href="https://issues.chromium.org/issues/40064904"> +<script src="/css/css-transitions/support/helper.js"></script> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #rtl-parent { + direction: rtl; + overflow: auto; + width: 300px; + height: 200px; + } + #rtl-child { + width: 500px; + height: 200px; + } +</style> + +<div id="rtl-parent"> + <div id="rtl-child"></div> +</div> + +<script> +promise_test(async () => { + const parent = document.getElementById('rtl-parent'); + const child = document.getElementById('rtl-child'); + + await waitForAnimationFrames(5); + assert_equals(parent.offsetWidth, 300); + assert_equals(parent.offsetHeight, 200); + assert_equals(child.offsetWidth, 500); + assert_equals(child.offsetHeight, 200); + + assert_equals(parent.scrollWidth, 500); + assert_equals(parent.scrollHeight, 200); + assert_equals(parent.scrollLeft, 0); + + child.style.height = '0px'; + parent.style.height = '0px'; + + await waitForAnimationFrames(5); + assert_equals(parent.offsetHeight, 0); + assert_equals(parent.scrollHeight, 0); + assert_equals(parent.scrollLeft, 0); +}, 'rtl scroll left should be 0 when overflow size is empty'); +</script> diff --git a/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-computed.html b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-computed.html new file mode 100644 index 00000000000..589ae8835da --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-computed.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: parsing scroll-target-group property computed values</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/computed-testcommon.js"></script> +<div id="target"></div> +<script> + test_computed_value('scroll-target-group', 'initial', 'none'); + test_computed_value('scroll-target-group', 'inherit', 'none'); + test_computed_value('scroll-target-group', 'unset', 'none'); + test_computed_value('scroll-target-group', 'revert', 'none'); + + test_computed_value('scroll-target-group', 'none'); + test_computed_value('scroll-target-group', 'auto'); + + test(() => { + let style = getComputedStyle(document.getElementById('target')); + assert_not_equals(Array.from(style).indexOf('scroll-target-group'), -1); + }, 'The scroll-target-group property shows up in CSSStyleDeclaration enumeration'); + + test(() => { + let style = document.getElementById('target').style; + assert_not_equals(style.cssText.indexOf('scroll-target-group'), -1); + }, 'The scroll-target-group property shows up in CSSStyleDeclaration.cssText'); +</script> diff --git a/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-invalid.html b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-invalid.html new file mode 100644 index 00000000000..ac6a6fa3191 --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-invalid.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: parsing scroll-target-group property invalid values</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<div id="target"></div> +<script> + test_invalid_value('scroll-target-group', '10'); + test_invalid_value('scroll-target-group', 'true'); + test_invalid_value('scroll-target-group', 'default'); + test_invalid_value('scroll-target-group', 'all'); + test_invalid_value('scroll-target-group', 'auto, auto'); +</script> diff --git a/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-valid.html b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-valid.html new file mode 100644 index 00000000000..0da79fc118c --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/parsing/parsing/scroll-target-group-valid.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Overflow: parsing scroll-target-group property valid values</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<div id="target"></div> +<script> + test_valid_value('scroll-target-group', 'initial'); + test_valid_value('scroll-target-group', 'inherit'); + test_valid_value('scroll-target-group', 'unset'); + test_valid_value('scroll-target-group', 'revert'); + + test_valid_value("scroll-target-group", 'none'); + test_valid_value("scroll-target-group", 'auto'); +</script> diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-focus-scroll-crash.html b/tests/wpt/tests/css/css-overflow/scroll-marker-focus-scroll-crash.html new file mode 100644 index 00000000000..97b3be1e8fb --- /dev/null +++ b/tests/wpt/tests/css/css-overflow/scroll-marker-focus-scroll-crash.html @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<html class="reftest-wait"> +<meta charset="utf-8"> +<link rel="help" href="crbug.com/421471058"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<style> + body { + margin: 0; + } + + #scroller { + width: 600px; + height: 300px; + overflow: auto; + scroll-marker-group: before; + white-space: nowrap; + } + + #scroller div { + background: blue; + display: inline-block; + width: 600px; + height: 270px; + } + + #scroller::scroll-marker-group { + height: 20px; + width: 200px; + } + + #scroller div::scroll-marker { + content: "Marker"; + width: 100px; + height: 20px; + display: inline-block; + } + + #scroller::scroll-button(left) { + content: "<"; + } +</style> +<div id="scroller"> + <div></div> + <div></div> +</div> +<script> + async function run() { + const kTab = '\uE004'; + await new test_driver.Actions() + .keyDown(kTab) + .keyUp(kTab) + .send(); + // With a focused scroll marker, scroll to next target. + document.querySelector('#scroller').scrollLeft = 600; + document.documentElement.classList.remove('reftest-wait'); + } + run(); +</script> + +</html> diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-001-ref.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-001-ref.html index 69e9167cc33..ed2cb595c9a 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-001-ref.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-001-ref.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test Reference: scroll-marker-contain property makes anchor elements scroll markers</title> +<title>CSS Overflow Test Reference: scroll-target-group property makes anchor elements scroll markers</title> <style> #scroller { overflow: auto; @@ -35,4 +35,3 @@ <div id="target3"></div> <div id="target4"></div> </div> - diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-001.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-001.html index 93d7df72508..c0f96cc5574 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-001.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-001.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property makes anchor elements scroll markers</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-001-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property makes anchor elements scroll markers</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-001-ref.html"> <style> #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { @@ -41,4 +41,3 @@ <div id="target3"></div> <div id="target4"></div> </div> - diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-002-ref.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-002-ref.html index 3fa777f7863..8571b11ba6a 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-002-ref.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-002-ref.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test Reference: scroll-marker-contain property makes anchor elements scroll markers and does scroll tracking</title> +<title>CSS Overflow Test Reference: scroll-target-group property makes anchor elements scroll markers and does scroll tracking</title> <style> #scroller { overflow: auto; @@ -38,4 +38,3 @@ <script> scroller.scrollTop = 400; </script> - diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-002.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-002.html index af2a5e668be..e3e83769db2 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-002.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-002.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property makes anchor elements scroll markers and does scroll tracking</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-002-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property makes anchor elements scroll markers and does scroll tracking</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-002-ref.html"> <style> #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { @@ -45,4 +45,3 @@ scroller.scrollTop = 400; assert_equals(getComputedStyle(link4).color, "rgb(0, 128, 0)", "link4 should be :target-current"); </script> - diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-003-ref.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-003-ref.html index 09bb93d4ebc..09bb93d4ebc 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-003-ref.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-003-ref.html diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-003.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-003.html index 59daa5cf5ce..39e1beff02a 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-003.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-003.html @@ -1,9 +1,9 @@ <!DOCTYPE html> <meta charset="utf-8"> <title>CSS Overflow Test: anchor scroll markers and pseudo element scroll markers</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> <link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-marker"> -<link rel="match" href="scroll-marker-contain-003-ref.tentative.html"> +<link rel="match" href="scroll-target-group-003-ref.html"> <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> <style> :root { @@ -11,7 +11,7 @@ } #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { @@ -63,4 +63,3 @@ scroller.scrollTop = 400; assert_equals(getComputedStyle(link4).color, "rgb(0, 128, 0)", "link4 should be :target-current"); </script> - diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-004.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-004.html index 2ec6f6bde76..3a61a6d8c8c 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-004.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-004.html @@ -1,15 +1,15 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property makes anchor elements scroll markers inside size containers</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-001-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property makes anchor elements scroll markers inside size containers</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-001-ref.html"> <style> html { container: my-container / size; } #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-005.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-005.html index 3d435bf74cb..c7da0d404ec 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-005.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-005.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - reparenting nested anchors</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-001-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - reparenting nested anchors</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-001-ref.html"> <style> .wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-006.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-006.html index 234b57e5bbe..6154845199a 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-006.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-006.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - anchor and target removal and addition</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-001-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - anchor and target removal and addition</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-001-ref.html"> <style> .wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-007.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-007.html index 5f15c85819a..9c736381c34 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-007.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-007.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - dynamic creation</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-001-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - dynamic creation</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-001-ref.html"> <style> .wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-008-ref.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-008-ref.html index d74777d3bbf..d2ba909f644 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-008-ref.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-008-ref.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test Reference: scroll-marker-contain property makes anchor elements scroll markers - </title> +<title>CSS Overflow Test Reference: scroll-target-group property makes anchor elements scroll markers - </title> <style> #scroller { overflow: auto; diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-008.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-008.html index 80801854a0f..217ff1aabe6 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-008.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-008.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - dynamic removal</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-008-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - dynamic removal</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-008-ref.html"> <style> .wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } #scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-009-ref.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-009-ref.html index 07b797ff789..82fbb988dfa 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-009-ref.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-009-ref.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test Reference: scroll-marker-contain property invalidation - dynamic change of href</title> +<title>CSS Overflow Test Reference: scroll-target-group property invalidation - dynamic change of href</title> <style> .scroller { overflow: auto; diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-009.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-009.html index 8037adf8441..c9df1e3ca4c 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-009.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-009.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - dynamic change of href</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-009-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - dynamic change of href</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-009-ref.html"> <style> #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } .scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-010.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-010.html index fbdad62f846..fa311bf9fee 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-010.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-010.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - dynamic addition of href</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-009-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - dynamic addition of href</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-009-ref.html"> <style> #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } .scroller { diff --git a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-011.tentative.html b/tests/wpt/tests/css/css-overflow/scroll-target-group-011.html index 8cfc78130e0..9062fef7a81 100644 --- a/tests/wpt/tests/css/css-overflow/scroll-marker-contain-011.tentative.html +++ b/tests/wpt/tests/css/css-overflow/scroll-target-group-011.html @@ -1,11 +1,11 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>CSS Overflow Test: scroll-marker-contain property invalidation - dynamic removal of href</title> -<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/10916"> -<link rel="match" href="scroll-marker-contain-009-ref.tentative.html"> +<title>CSS Overflow Test: scroll-target-group property invalidation - dynamic removal of href</title> +<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-target-group"> +<link rel="match" href="scroll-target-group-009-ref.html"> <style> #wrapper { - scroll-marker-contain: auto; + scroll-target-group: auto; } .scroller { diff --git a/tests/wpt/tests/css/css-scoping/host-defined.html b/tests/wpt/tests/css/css-scoping/host-defined.html index 9e9776754a3..563bc52e527 100644 --- a/tests/wpt/tests/css/css-scoping/host-defined.html +++ b/tests/wpt/tests/css/css-scoping/host-defined.html @@ -13,10 +13,10 @@ :host div { width: 100px; height: 100px; - background-color: red; + background-color: green; } :not(:defined) div { - background-color: green; + background-color: red; } </style> <div></div> diff --git a/tests/wpt/tests/css/css-scroll-snap/scroll-start/scroll-start-with-text-fragment-navigation-target.html b/tests/wpt/tests/css/css-scroll-snap/scroll-start/scroll-start-with-text-fragment-navigation-target.html index c399a975732..8b9fab96697 100644 --- a/tests/wpt/tests/css/css-scroll-snap/scroll-start/scroll-start-with-text-fragment-navigation-target.html +++ b/tests/wpt/tests/css/css-scroll-snap/scroll-start/scroll-start-with-text-fragment-navigation-target.html @@ -51,7 +51,7 @@ if (document.scrollingElement.scrollTop == 100) { scroll_position = "AT_SCROLL_START"; - } else if (document.scrollingElement.scrollTop == expected_scroll_top) { + } else if (document.scrollingElement.scrollTop - expected_scroll_top < 1.0) { scroll_position = "AT_TEXT_FRAGMENT"; } @@ -71,4 +71,4 @@ </script> </body> -</html>
\ No newline at end of file +</html> diff --git a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-computed.tentative.html b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-computed.html index a87bc2391a8..a87bc2391a8 100644 --- a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-computed.tentative.html +++ b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-computed.html diff --git a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-invalid.tentative.html b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-invalid.html index 9abe483c703..9abe483c703 100644 --- a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-invalid.tentative.html +++ b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-invalid.html diff --git a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-valid.tentative.html b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-valid.html index 2372290cb69..2372290cb69 100644 --- a/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-valid.tentative.html +++ b/tests/wpt/tests/css/css-shapes/shape-functions/shape-function-valid.html diff --git a/tests/wpt/tests/css/css-sizing/replaced-aspect-ratio-stretch-fit-003.html b/tests/wpt/tests/css/css-sizing/replaced-aspect-ratio-stretch-fit-003.html index 06dac275cab..0f6bffc2dce 100644 --- a/tests/wpt/tests/css/css-sizing/replaced-aspect-ratio-stretch-fit-003.html +++ b/tests/wpt/tests/css/css-sizing/replaced-aspect-ratio-stretch-fit-003.html @@ -3,6 +3,6 @@ <link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes"> <link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> <p>Test passes if there is a filled green square.</p> -<div style="width: 100px;"> - <svg viewBox="0 0 1 1" style="background: green; min-width: max-content; max-width: 50px;"></svg> +<div style="width: 100px; height: 100px;"> + <svg viewBox="0 0 1 1" style="background: green; min-width: max-content; max-width: 50px; height: 100%;"></svg> </div> diff --git a/tests/wpt/tests/css/css-sizing/stretch/flex-line-001.html b/tests/wpt/tests/css/css-sizing/stretch/flex-line-001.html new file mode 100644 index 00000000000..04c12f20cda --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/stretch/flex-line-001.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784"> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src="/resources/check-layout-th.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<meta name="assert" + content="An item's cross-size:stretch should stretch to the line size, not the container size"> +<style> + .container { + /* inline just so they don't overflow on each other */ + display: inline-flex; + width: 100px; + height: 100px; + border: solid; + flex-wrap: wrap; + /* Prevent the lines from stretching. */ + align-content: start; + font: 20px/1 Ahem; + } + + .container > div { + border: 3px solid; + } + + .stretch { + width: -moz-available; + width: -webkit-fill-available; + width: stretch; + } +</style> + +<div class="container"> + <div class="stretch" style="width: 75px; border-color: cyan" + data-expected-height="26">a</div> + <div class="stretch" style="width: 75px; border-color: magenta" + data-expected-height="26">b</div> +</div> +<div class="container"> + <div class="stretch" style="width: 75px; border-color: cyan" + data-expected-height="156">a</div> + <div style="border-color: orange; height: 150px"></div> + <div class="stretch" style="width: 75px; border-color: magenta" + data-expected-height="26">b</div> +</div> + +<script> + document.fonts.ready.then(() => checkLayout(".stretch")); +</script> diff --git a/tests/wpt/tests/css/css-sizing/stretch/flex-line-002.html b/tests/wpt/tests/css/css-sizing/stretch/flex-line-002.html new file mode 100644 index 00000000000..232554d7eaf --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/stretch/flex-line-002.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784"> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src="/resources/check-layout-th.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<meta name="assert" + content="An item's cross-size:stretch should stretch to the line size, not the container size; container has indefinite height"> +<style> + .container { + /* inline just so they don't overflow on each other */ + display: inline-flex; + width: 100px; + border: solid; + flex-wrap: wrap; + /* Prevent the lines from stretching. */ + align-content: start; + font: 20px/1 Ahem; + } + + .container>div { + border: 3px solid; + } + + .stretch { + height: -moz-available; + height: -webkit-fill-available; + height: stretch; + } +</style> + +<div class="container"> + <div class="stretch" style="width: 75px; border-color: cyan" + data-expected-height="26">a</div> + <div class="stretch" style="width: 75px; border-color: magenta" + data-expected-height="26">b</div> +</div> +<div class="container"> + <div class="stretch" style="width: 75px; border-color: cyan" + data-expected-height="156">a</div> + <div style="border-color: orange; height: 150px"></div> + <div class="stretch" style="width: 75px; border-color: magenta" + data-expected-height="26">b</div> +</div> + +<script> + document.fonts.ready.then(() => checkLayout(".stretch")); +</script> diff --git a/tests/wpt/tests/css/css-sizing/stretch/flex-line-003.html b/tests/wpt/tests/css/css-sizing/stretch/flex-line-003.html new file mode 100644 index 00000000000..9aeb014ac16 --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/stretch/flex-line-003.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784"> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src="/resources/check-layout-th.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<meta name="assert" + content="width:stretch item stretches to container width during the measure pass; container has definite width"> +<style> + .container { + display: flex; + flex-direction: column; + width: 100px; + height: 100px; + border: solid; + flex-wrap: wrap; + /* Prevent the lines from stretching. */ + align-content: start; + font: 20px/1 Ahem; + } + + .container>div { + border: 3px solid; + } + + .stretch { + width: -moz-available; + width: -webkit-fill-available; + width: stretch; + } +</style> + +<div class="container"> + <div class="stretch" style="height: 75px; border-color: cyan" + data-expected-width="100">a</div> + <div class="stretch" style="height: 75px; border-color: magenta" + data-expected-width="100">b</div> +</div> +<div class="container"> + <div class="stretch" style="height: 75px; border-color: cyan" + data-expected-width="156">a</div> + <div style="border-color: orange; width: 150px"></div> + <div class="stretch" style="height: 75px; border-color: magenta" + data-expected-width="100">b</div> +</div> + +<script> + document.fonts.ready.then(() => checkLayout(".stretch")); +</script> diff --git a/tests/wpt/tests/css/css-sizing/stretch/flex-line-004.html b/tests/wpt/tests/css/css-sizing/stretch/flex-line-004.html new file mode 100644 index 00000000000..4be0d02c393 --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/stretch/flex-line-004.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784"> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src="/resources/check-layout-th.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<meta name="assert" + content="width:stretch item stretches to container width during the measure pass; container has min-content width"> +<style> + .container { + display: flex; + flex-direction: column; + max-width: 100px; + width: min-content; + height: 100px; + border: solid; + flex-wrap: wrap; + /* Prevent the lines from stretching. */ + align-content: start; + font: 20px/1 Ahem; + } + + .container>div { + border: 3px solid; + } + + .stretch { + width: -moz-available; + width: -webkit-fill-available; + width: stretch; + } +</style> + +<div class="container"> + <div class="stretch" style="height: 75px; border-color: cyan" + data-expected-width="26">a</div> + <div class="stretch" style="height: 75px; border-color: magenta" + data-expected-width="26">b</div> +</div> +<div class="container"> + <div class="stretch" style="height: 75px; border-color: cyan" + data-expected-width="156">c</div> + <div style="border-color: orange; width: 150px"></div> + <div class="stretch" style="height: 75px; border-color: magenta" + data-expected-width="100">d</div> +</div> + +<script> + document.fonts.ready.then(() => checkLayout(".stretch")); +</script> diff --git a/tests/wpt/tests/css/css-sizing/stretch/flex-line-005.html b/tests/wpt/tests/css/css-sizing/stretch/flex-line-005.html new file mode 100644 index 00000000000..99cd3310492 --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/stretch/flex-line-005.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11784"> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src="/resources/check-layout-th.js"></script> +<meta name="assert" + content="An item's cross-size:stretch should stretch to the line size, not the container size; single-line container has indefinite height"> +<style> + .container { + display: inline-flex; + width: 100px; + border: solid; + margin: 10px; + } + + .container>div { + border: 3px solid; + } + + .stretch { + height: -moz-available; + height: -webkit-fill-available; + height: stretch; + } +</style> + +<div class="container"> + <div class="stretch" style="width: 75px; border-color: cyan" + data-expected-height="156"></div> + <div style="border-color: orange; height: 150px"></div> +</div> + +<script> + checkLayout(".stretch"); +</script> diff --git a/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2-ref.html b/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2-ref.html index 503e999788c..6d824e73d56 100644 --- a/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2-ref.html +++ b/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2-ref.html @@ -3,6 +3,7 @@ <title>CSS text decoration test: emphasis marks and punctuation</title> <style> +:root { text-autospace: no-autospace; } span { text-emphasis: filled circle; } </style> diff --git a/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2.html b/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2.html index 1a48f9d32cb..53d261e9c8c 100644 --- a/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2.html +++ b/tests/wpt/tests/css/css-text-decor/text-emphasis-punctuation-2.html @@ -6,6 +6,7 @@ <meta name="assert" content="emphasis marks are not drawn for punctuation (with a small set of exceptions)"> <style> +:root { text-autospace: no-autospace; } .emph { text-emphasis: filled circle; } </style> diff --git a/tests/wpt/tests/css/css-text/i18n/zh/css-text-line-break-zh-in-loose.html b/tests/wpt/tests/css/css-text/i18n/zh/css-text-line-break-zh-in-loose.html index 56fec0bd3ed..54ce3c15735 100644 --- a/tests/wpt/tests/css/css-text/i18n/zh/css-text-line-break-zh-in-loose.html +++ b/tests/wpt/tests/css/css-text/i18n/zh/css-text-line-break-zh-in-loose.html @@ -9,6 +9,7 @@ <script src="/resources/testharnessreport.js"></script> <meta name="assert" content="When the language is Chinese, and line-break:loose, a browser allows a break before an inseparable character."> <style type="text/css"> +:root { text-autospace: no-autospace; } @font-face { font-family: 'mplus-1p-regular'; src: url('/fonts/mplus-1p-regular.woff') format('woff'); diff --git a/tests/wpt/tests/css/css-text/parsing/text-autospace-computed.html b/tests/wpt/tests/css/css-text/parsing/text-autospace-computed.html index 9656f70956e..c8a4091eb99 100644 --- a/tests/wpt/tests/css/css-text/parsing/text-autospace-computed.html +++ b/tests/wpt/tests/css/css-text/parsing/text-autospace-computed.html @@ -11,6 +11,8 @@ <body> <div id="target"></div> <script> +test_computed_value("text-autospace", "initial", "normal"); + test_computed_value("text-autospace", "normal"); test_computed_value("text-autospace", "no-autospace"); test_computed_value("text-autospace", "auto"); diff --git a/tests/wpt/tests/css/css-text/parsing/text-spacing-computed.html b/tests/wpt/tests/css/css-text/parsing/text-spacing-computed.html index 845cf075a9b..2ba02e87c9f 100644 --- a/tests/wpt/tests/css/css-text/parsing/text-spacing-computed.html +++ b/tests/wpt/tests/css/css-text/parsing/text-spacing-computed.html @@ -11,6 +11,8 @@ <body> <div id="target"></div> <script> +test_computed_value("text-spacing", "initial", "normal"); + test_computed_value("text-spacing", "normal"); test_computed_value("text-spacing", "none"); test_computed_value("text-spacing", "auto"); diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001-ref.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001-ref.html index d26fae09b03..499f8322fe4 100644 --- a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001-ref.html +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001-ref.html @@ -1,2 +1,3 @@ <!DOCTYPE html> -<div id="target">国国AA国国AA国々</div> +<meta charset="utf-8"> +<div id="target">国国AA国国AA国国</div> diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001.html index dfde20a265a..32c9c175d97 100644 --- a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001.html +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-001.html @@ -1,6 +1,7 @@ <!DOCTYPE html> +<meta charset="utf-8"> <link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property"> -<link rel="help" href="text-autospace-dynamic-text-001-ref.html"> +<link rel="match" href="text-autospace-dynamic-text-001-ref.html"> <div id="target">国国</div> <script> const target_text = document.getElementById('target').firstChild; diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-002.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-002.html index ffc3d907ee5..bd0a1107dae 100644 --- a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-002.html +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-002.html @@ -1,6 +1,7 @@ <!DOCTYPE html> +<meta charset="utf-8"> <link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property"> -<link rel="help" href="text-autospace-dynamic-text-001-ref.html"> +<link rel="match" href="text-autospace-dynamic-text-001-ref.html"> <div id="target">国国国国</div> <script> const target_text = document.getElementById('target').firstChild; diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-003.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-003.html index cf2237d48ef..d53762233cc 100644 --- a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-003.html +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-003.html @@ -1,6 +1,7 @@ <!DOCTYPE html> +<meta charset="utf-8"> <link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property"> -<link rel="help" href="text-autospace-dynamic-text-001-ref.html"> +<link rel="match" href="text-autospace-dynamic-text-001-ref.html"> <div id="target">国国国国国</div> <script> const target_text = document.getElementById('target').firstChild; diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-004.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-004.html index c1057fc9005..4b3854c9608 100644 --- a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-004.html +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-dynamic-text-004.html @@ -1,6 +1,7 @@ <!DOCTYPE html> +<meta charset="utf-8"> <link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property"> -<link rel="help" href="text-autospace-dynamic-text-001-ref.html"> +<link rel="match" href="text-autospace-dynamic-text-001-ref.html"> <div id="target">国国AAAA国国AAAA国国</div> <script> const target_text = document.getElementById('target').firstChild; diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001-ref.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001-ref.html new file mode 100644 index 00000000000..266a69b298e --- /dev/null +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001-ref.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<style> +.test { + font-family: Ahem; + font-size: 40px; + text-autospace: no-autospace; + + span { + margin-left: calc(1em / 8); + margin-right: calc(1em / 8); + } +} +</style> +<div id="container"> + <div lang="zh" class="test normal">国<span>!</span>国<span>#</span>国</div> +</div> diff --git a/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001.html b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001.html new file mode 100644 index 00000000000..e8afdca9310 --- /dev/null +++ b/tests/wpt/tests/css/css-text/text-autospace/text-autospace-zh-001.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<link rel="match" href="text-autospace-zh-001-ref.html"> +<style> +.test { + font-family: Ahem; + font-size: 40px; + text-autospace: normal; +} +</style> +<div id="container"> + <div lang="zh" class="test">国!国#国</div> +</div> diff --git a/tests/wpt/tests/css/css-values/acos-asin-atan-atan2-invalid.html b/tests/wpt/tests/css/css-values/acos-asin-atan-atan2-invalid.html index 727fc4df18a..5f894e35a56 100644 --- a/tests/wpt/tests/css/css-values/acos-asin-atan-atan2-invalid.html +++ b/tests/wpt/tests/css/css-values/acos-asin-atan-atan2-invalid.html @@ -74,4 +74,6 @@ test_invalid_angle('atan2( 0 ,)'); test_invalid_angle('atan2( () 30deg - 0.523599rad )'); test_invalid_angle('atan2(45deg )'); test_invalid_angle('atan2(30deg, + 0.261799rad)'); +test_invalid_angle('atan2(2, 1px)'); +test_invalid_angle('atan2(2, 1%)'); </script> diff --git a/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-ref.html b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-ref.html new file mode 100644 index 00000000000..4f994bd03f6 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-ref.html @@ -0,0 +1,51 @@ +<!doctype html> +<html> +<title>Nested View Transitions: group children sizing (ref)</title> +<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> + +<style> +#wrapper { + position: relative; +} + +#clipper { + height: 200px; + width: 200px; + overflow: clip; +} + +.item { + background: blue; + position: relative; + top: -25px; + left: -10px; + + height: 50px; + width: 250px; + margin: 1px; + border: 1px solid black; +} + +.popout { + position: absolute; + left: -9px; + top: 81px; + background: blue; + + height: 50px; + width: 250px; + border: 1px solid black; +} + +</style> + +<div id=wrapper> + <div id=clipper> + <div class=item></div> + <div class=item></div> + <div class=item></div> + <div class=item></div> + <div class=item></div> + </div> + <div class=popout></div> +</div> diff --git a/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border-ref.html b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border-ref.html new file mode 100644 index 00000000000..f1a484400e7 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border-ref.html @@ -0,0 +1,55 @@ +<!doctype html> +<html> +<title>Nested View Transitions: group children sizing (ref)</title> +<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> + +<style> +#wrapper { + position: relative; +} + +#clipper { + height: 200px; + width: 200px; + overflow: clip; + + border-width: 5px 10px 15px 20px; + border-style: solid; + border-color: green; +} + +.item { + background: blue; + position: relative; + top: -25px; + left: -10px; + + height: 50px; + width: 250px; + margin: 1px; + border: 1px solid black; +} + +.popout { + position: absolute; + left: 11px; + top: 87px; + background: blue; + + height: 50px; + width: 250px; + border: 1px solid black; +} + +</style> + +<div id=wrapper> + <div id=clipper> + <div class=item></div> + <div class=item></div> + <div class=item></div> + <div class=item></div> + <div class=item></div> + </div> + <div class=popout></div> +</div> diff --git a/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border.html b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border.html new file mode 100644 index 00000000000..cb0cf819b42 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing-with-border.html @@ -0,0 +1,70 @@ +<!doctype html> +<html class=reftest-wait> +<title>Nested View Transitions: group children sizing with border</title> +<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> +<link rel="match" href="group-children-sizing-with-border-ref.html"> +<script src="/common/reftest-wait.js"></script> +<script src="resources/compute-test.js"></script> +<script src="/dom/events/scrolling/scroll_support.js"></script> + +<style> +#clipper { + view-transition-group: contain; + view-transition-name: clipper; + + border-width: 5px 10px 15px 20px; + border-style: solid; + border-color: green; + + height: 200px; + width: 200px; +} + +.item { + view-transition-name: match-element; + background: blue; + position: relative; + top: -25px; + left: -10px; + + height: 50px; + width: 250px; + margin: 1px; + border: 1px solid black; +} + +.item.popout { + view-transition-group: none; +} + +::view-transition-group(*), +::view-transition-old(*), +::view-transition-new(*) { + animation-play-state: paused; +} + +::view-transition-group-children(clipper) { + overflow: clip; +} +</style> + +<div id=clipper> + <div class=item></div> + <div class=item></div> + <div class="item popout"></div> + <div class=item></div> + <div class=item></div> +</div> + +<script> + +function runTest() { + document.startViewTransition().ready.then(takeScreenshot); +} + +onload = () => { + waitForCompositorReady().then(runTest); +} +</script> + + diff --git a/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing.html b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing.html new file mode 100644 index 00000000000..88916ddf486 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/nested/group-children-sizing.html @@ -0,0 +1,66 @@ +<!doctype html> +<html class=reftest-wait> +<title>Nested View Transitions: group children sizing</title> +<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> +<link rel="match" href="group-children-sizing-ref.html"> +<script src="/common/reftest-wait.js"></script> +<script src="resources/compute-test.js"></script> +<script src="/dom/events/scrolling/scroll_support.js"></script> + +<style> +#clipper { + view-transition-group: contain; + view-transition-name: clipper; + + height: 200px; + width: 200px; +} + +.item { + view-transition-name: match-element; + background: blue; + position: relative; + top: -25px; + left: -10px; + + height: 50px; + width: 250px; + margin: 1px; + border: 1px solid black; +} + +.item.popout { + view-transition-group: root; +} + +::view-transition-group(*), +::view-transition-old(*), +::view-transition-new(*) { + animation-play-state: paused; +} + +::view-transition-group-children(clipper) { + overflow: clip; +} +</style> + +<div id=clipper> + <div class=item></div> + <div class=item></div> + <div class="item popout"></div> + <div class=item></div> + <div class=item></div> +</div> + +<script> + +function runTest() { + document.startViewTransition().ready.then(takeScreenshot); +} + +onload = () => { + waitForCompositorReady().then(runTest); +} +</script> + + diff --git a/tests/wpt/tests/css/css-view-transitions/nested/rounded-border-clipper.html b/tests/wpt/tests/css/css-view-transitions/nested/rounded-border-clipper.html index 098e5566585..239bcdd791d 100644 --- a/tests/wpt/tests/css/css-view-transitions/nested/rounded-border-clipper.html +++ b/tests/wpt/tests/css/css-view-transitions/nested/rounded-border-clipper.html @@ -33,9 +33,6 @@ ::view-transition-group(clipper) { animation-play-state: paused; -} - -::view-transition-group-children(clipper) { overflow: clip; border-radius: 20px; } diff --git a/tests/wpt/tests/css/css-view-transitions/no-crash-set-exception.html b/tests/wpt/tests/css/css-view-transitions/no-crash-set-exception.html index cc401b8bd6f..b57fce0d73f 100644 --- a/tests/wpt/tests/css/css-view-transitions/no-crash-set-exception.html +++ b/tests/wpt/tests/css/css-view-transitions/no-crash-set-exception.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <html> -<title>View transitions: author styles ignored during prepare</title> +<title>View transitions: exception thrown during transition</title> <link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/"> <link rel="author" href="mailto:khushalsagar@chromium.org"> @@ -32,12 +32,26 @@ html::view-transition-new(shared) { promise_test(async t => { assert_implements(document.startViewTransition, "Missing document.startViewTransition"); await waitForCompositorReady(); - return new Promise((resolve, reject) => { - document.startViewTransition(() => { - resolve(); - throw 'error'; - }); + const vt = document.startViewTransition(() => { + throw "error"; }); + let update_callback_resolution; + let ready_resolution; + let finished_resolution; + + await vt.updateCallbackDone.then( + () => { update_callback_resolution = "fulfilled" }, + () => { update_callback_resolution = "rejected" }); + await vt.ready.then( + () => { ready_resolution = "fulfilled" }, + () => { ready_resolution = "rejected" }); + await vt.finished.then( + () => { finished_resolution = "fulfilled" }, + () => { finished_resolution = "rejected" }); + + assert_equals(update_callback_resolution, "rejected"); + assert_equals(ready_resolution, "rejected"); + assert_equals(finished_resolution, "rejected"); }, "An exception thrown during a transition shouldn't crash."); </script> diff --git a/tests/wpt/tests/css/css-view-transitions/pseudo-computed-style-stays-in-sync-with-new-element.html b/tests/wpt/tests/css/css-view-transitions/pseudo-computed-style-stays-in-sync-with-new-element.html index 0a34a4b73ff..9914097185b 100644 --- a/tests/wpt/tests/css/css-view-transitions/pseudo-computed-style-stays-in-sync-with-new-element.html +++ b/tests/wpt/tests/css/css-view-transitions/pseudo-computed-style-stays-in-sync-with-new-element.html @@ -29,12 +29,12 @@ promise_test(async t => { let viewbox = window.getComputedStyle( document.documentElement, "::view-transition-new(target)").objectViewBox; - assert_equals(viewbox, "none", "incorrect viewbox " + viewbox); + assert_in_array(viewbox, ["none", undefined], "incorrect viewbox " + viewbox); first.style.filter = "blur(5px)"; viewbox = window.getComputedStyle( document.documentElement, "::view-transition-new(target)").objectViewBox; - assert_equals(viewbox, "none", "incorrect viewbox " + viewbox); + assert_in_array(viewbox, ["none", undefined], "incorrect viewbox " + viewbox); transition.finished.then(resolve, reject); }); diff --git a/tests/wpt/tests/css/css-view-transitions/scoped/contain-view-transition-name-discovery.html b/tests/wpt/tests/css/css-view-transitions/scoped/contain-view-transition-name-discovery.html new file mode 100644 index 00000000000..10a1a1197b1 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/scoped/contain-view-transition-name-discovery.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <!-- TODO update link --> + <link rel="help" href="https://www.w3.org/TR/css-view-transitions-2/"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Contain and name discovery</title> +</head> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #outer { + view-transition-name: outer; + } + + #inner { + view-transition-name: inner; + } + + .containment { + contain: view-transition; + } +</style> +<body> + <div id="outer"> + <div id="inner"></div> + </div> +</body> +<script> + function capturedNames() { + const regexp = /\((?<name>[^\)]+)/; + const names = document.getAnimations() + .map(a => a.effect.pseudoElement) + .map(name => name.match(regexp).groups.name); + return [...new Set(names)].sort(); + } + + promise_test(async t => { + const outer = document.getElementById('outer'); + const inner = document.getElementById('inner'); + + let vt = document.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['inner', 'outer', 'root'], + 'Retrieve all names in absence of contain style'); + vt.skipTransition(); + + document.documentElement.classList.toggle('containment'); + vt = document.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['inner', 'outer', 'root'], + 'contain on the root element does not affect tag discovery'); + vt.skipTransition(); + + outer.classList.toggle('containment'); + vt = document.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['root'], + 'contain on outer element blocks tag discovery in subtree'); + vt.skipTransition(); + + vt = outer.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['inner', 'outer'], + 'contain on the scoped element includes self'); + vt.skipTransition(); + + vt = inner.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['inner'], + 'contain on ancestor of the scoped element does not affect tag ' + + 'discovery'); + vt.skipTransition(); + + outer.classList.toggle('containment'); + inner.classList.toggle('containment'); + vt = document.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['outer', 'root'], + 'contain on inner element still permits tag discovery of ancestor ' + + 'elements'); + vt.skipTransition(); + + vt = outer.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['outer'], + 'contain on inner element limits tag discovery on outer element'); + vt.skipTransition(); + + vt = inner.startViewTransition(() => {}); + await vt.ready; + assert_array_equals( + capturedNames(), ['inner'], + 'contain permits tag discovery on scoped element'); + vt.skipTransition(); + }, 'Contain: view-transition blocks propagation of name discovery.'); +</script> +</html> diff --git a/tests/wpt/tests/css/css-view-transitions/scoped/crashtests/shuffle.html b/tests/wpt/tests/css/css-view-transitions/scoped/crashtests/shuffle.html new file mode 100644 index 00000000000..fe110dbfe50 --- /dev/null +++ b/tests/wpt/tests/css/css-view-transitions/scoped/crashtests/shuffle.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html class="test-wait"> +<head> +<style> + +#s { + position: relative; + view-transition-name: wrapper; + border: 5px solid lightgrey; + height: 200px; + width: 250px; +} +.i { + position: relative; + width: 150px; height: 60px; + border: 5px solid #ace; +} +::view-transition-group(*), +::view-transition-old(*), +::view-transition-new(*) { animation: unset; } + +</style> +</head> +<body> +<div id="s"> + <div class="i">A</div> + <div class="i">B</div> +</div> +<script> + +onload = async () => { + await s.startViewTransition(() => { + s.appendChild(s.children[0]); + }).finished; + document.documentElement.classList.remove('test-wait'); +} + +</script> +</body> +</html> diff --git a/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip-ref.html b/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip-ref.html new file mode 100644 index 00000000000..73cfab22e7d --- /dev/null +++ b/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip-ref.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<style> +#wrapper { + position: absolute; + width: 200px; + height: 200px; + border-radius: 50px; + overflow: hidden; +} +#child { + position: absolute; + width: 300px; + height: 300px; + backdrop-filter: invert(100%); +} +</style> +<body> +<div id="wrapper"> + <div id="child"></div> +</div> +</body> diff --git a/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip.html b/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip.html new file mode 100644 index 00000000000..29e8ce71e5a --- /dev/null +++ b/tests/wpt/tests/css/filter-effects/css-backdrop-filter-transform-clip.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<html class='reftest-wait'> +<title>CSS Backdrop Filter with transform and clip</title> +<link rel="author" href="mailto:kevers@chromium.org"> +<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty"> +<link rel="match" href="css-backdrop-filter-transform-clip-ref.html"> +<link rel="help" href="https://crbug.com/401816608"> +<script src="/common/reftest-wait.js"></script> +<style> +#wrapper { + position: absolute; + width: 200px; + height: 200px; + border-radius: 50px; + overflow: hidden; +} + +#child { + position: absolute; + left: 50px; + width: 300px; + height: 300px; + backdrop-filter: invert(100%); +} +@keyframes a { + 0% { transform: translateX(0px); } + 50% { transform: translateX(-100px); } + 100% { transform: translateX(100px); } +} +#animation { + animation: a 2s linear paused; +} +</style> +<body> +<div id="wrapper"> + <div id="animation"> + <div id="child"></div> + </div> +</div> +</body> +<script> + function rAF() { + return new Promise(resolve => { + requestAnimationFrame(resolve); + }); + } + async function runTest() { + await rAF(); + const anim = document.getAnimations()[0]; + anim.ready.then(async () => { + await rAF(); + // Initially the backdrop filter does not completely cover the clip area + // because of left: 50px. Shift the backdrop filter 100px to left. + // Ensure the filter now completely covers the clip and is not applied + // outside the left boundary of the clip. + anim.currentTime = 1000; + await rAF(); + takeScreenshot(); + }); + } + window.onload = runTest; +</script> +</html> diff --git a/tests/wpt/tests/css/filter-effects/drop-shadow-currentcolor-inheritance.html b/tests/wpt/tests/css/filter-effects/drop-shadow-currentcolor-inheritance.html new file mode 100644 index 00000000000..92cf94e29b0 --- /dev/null +++ b/tests/wpt/tests/css/filter-effects/drop-shadow-currentcolor-inheritance.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html class="reftest-wait"> +<title>Filter Effects: Inheritance of 'currentcolor' in drop-shadow()</title> +<link rel="help" href="https://drafts.fxtf.org/filter-effects/#funcdef-filter-drop-shadow"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +#filter { + color: red; + filter: drop-shadow(100px 0px 0px currentcolor); +} +#target { + background-color: black; + color: green; + width: 100px; + height: 100px; + filter: inherit; +} +</style> +<div id="filter"> + <div id="target"></div> +</div> +<script> +test(function() { + assert_equals(getComputedStyle(target).filter, "drop-shadow(rgb(0, 128, 0) 100px 0px 0px)"); +}, "Test currentcolor inheritance in drop-shadow()"); + +test(function() { + target.style.color = "blue"; + assert_equals(getComputedStyle(target).filter, "drop-shadow(rgb(0, 0, 255) 100px 0px 0px)"); +}, "Test currentcolor inheritance in drop-shadow() after color mutation"); + +</script> diff --git a/tests/wpt/tests/custom-elements/registries/idlharness.window.js b/tests/wpt/tests/custom-elements/registries/idlharness.window.js deleted file mode 100644 index b2727e3a874..00000000000 --- a/tests/wpt/tests/custom-elements/registries/idlharness.window.js +++ /dev/null @@ -1,20 +0,0 @@ -// META: script=/resources/WebIDLParser.js -// META: script=/resources/idlharness.js - -idl_test( - ["scoped-custom-elements-registry"], - ["html", "dom"], - (idl_array) => { - let element = document.createElement("div"); - let shadowRoot = element.attachShadow({ mode: "open" }); - let customElementRegistry = new CustomElementRegistry(); - let templateElement = document.createElement("template"); - idl_array.add_objects({ - document, - element, - shadowRoot, - customElementRegistry, - templateElement, - }); - }, -); diff --git a/tests/wpt/tests/custom-elements/registries/valid-custom-element-names.tentative.html b/tests/wpt/tests/custom-elements/registries/valid-custom-element-names.tentative.html new file mode 100644 index 00000000000..72a5999e3a9 --- /dev/null +++ b/tests/wpt/tests/custom-elements/registries/valid-custom-element-names.tentative.html @@ -0,0 +1,138 @@ +<!DOCTYPE html> +<link rel=author href="mailto:jarhar@chromium.org"> +<link rel=help href="https://github.com/whatwg/html/pull/7991"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +function isAsciiLowerAlpha(codePoint) { + return codePoint >= 0x61 && codePoint <= 0x7A; +} +function isAsciiUpperAlpha(codePoint) { + return codePoint >= 0x41 && codePoint <= 0x5A; +} +function isAsciiAlpha(codePoint) { + return isAsciiLowerAlpha(codePoint) || isAsciiUpperAlpha(codePoint); +} +function isAsciiDigit(codePoint) { + return codePoint >= 0x30 && codePoint <= 0x39; +} +function isAsciiWhitespace(codePoint) { + return codePoint == 0x9 || codePoint == 0xA || codePoint == 0xC || codePoint == 0xD || codePoint == 0x20; +} + +function debugString(str) { + const codePoints = []; + for (const c of str) { + codePoints.push(c.codePointAt(0)); + } + return `code points: ${JSON.stringify(codePoints)}, string: "${str}"`; +} + +const validCustomElementNames = [ + 'annotation-xml-custom', +]; +const invalidCustomElementNames = [ + '', + 'annotation-xml', + 'color-profile', + 'font-face', + 'font-face-src', + 'font-face-uri', + 'font-face-format', + 'font-face-name', + 'missing-glyph', +]; + +const testCodePoints = [0x1F171, 0x1F196, 0x10000]; +for (let i = 0; i < 0x80; i++) { + testCodePoints.push(i); +} + +const elementLocalNameRegex = /^(?:[A-Za-z][^\0\t\n\f\r\u0020/>]*|[:_\u0080-\u{10FFFF}][A-Za-z0-9-.:_\u0080-\u{10FFFF}]*)$/u; + +function isValidCustomElementName(str) { + if (!str.length) { + return false; + } + + if (!str.includes('-')) { + return false; + } + + let first = true; + for (const c of str) { + const codePoint = c.codePointAt(0); + if (first) { + if (!isAsciiLowerAlpha(codePoint)) { + return false; + } + first = false; + } + if (isAsciiUpperAlpha(codePoint)) { + return false; + } + } + + return elementLocalNameRegex.test(str); +} + +// In order to test the branching logic of valid element local names and the +// requirement of having a '-' character, this method generates different +// variations of potential custom element names given two code points. +function createStringWithSeparatorMode(codePoint, prefix, separatorMode) { + const str = String.fromCodePoint(codePoint); + if (separatorMode == 0) { + return `${prefix}${str}`; + } else if (separatorMode == 1) { + return `${prefix}-${str}`; + } else if (separatorMode == 2) { + return `${prefix}${str}-element`; + } +} + +for (const prefix of ['', 'a', 'A', ' ', '\0']) { + for (const codePoint of testCodePoints) { + for (const separatorMode of [0, 1, 2]) { + const str = createStringWithSeparatorMode( + codePoint, prefix, separatorMode); + if (isValidCustomElementName(str)) { + validCustomElementNames.push(str); + } else { + invalidCustomElementNames.push(str); + } + } + } +} + +let nextClassNumber = 1; +function createElementClass() { + const name = `CustomElement${nextClassNumber++}`; + const newClass = function() {}; + newClass.prototype = HTMLElement; + return newClass; +} + +promise_test(async t => { + for (const validName of validCustomElementNames) { + try { + const newClass = createElementClass(); + customElements.define(validName, newClass); + await customElements.whenDefined(validName); + } catch (error) { + assert_unreached(`Custom element name should have been valid but threw error: ${debugString(validName)} ${error.toString()}`); + } + } + + for (const invalidName of invalidCustomElementNames) { + const newClass = createElementClass(); + assert_throws_dom( + 'SyntaxError', + () => customElements.define(invalidName, newClass), + `customElements.define should have thrown for invalid name: ${debugString(invalidName)}`); + await promise_rejects_dom(t, 'SyntaxError', + customElements.whenDefined(invalidName), + `customElements.whenDefined should have thrown for invalid name: ${debugString(invalidName)}`); + } +}); +</script> diff --git a/tests/wpt/tests/device-bound-session-credentials/refresh_session.py b/tests/wpt/tests/device-bound-session-credentials/refresh_session.py index d05340a318c..ab491e30104 100644 --- a/tests/wpt/tests/device-bound-session-credentials/refresh_session.py +++ b/tests/wpt/tests/device-bound-session-credentials/refresh_session.py @@ -9,7 +9,8 @@ def main(request, response): session_id_header = request.headers.get("Sec-Session-Id") if session_id_header == None: return (400, response.headers, "") - session_id = int(session_id_header.decode('utf-8')) + session_id_header = session_id_header.decode('utf-8') + session_id = int(session_id_header) if test_session_manager.get_should_refresh_end_session(): response_body = { @@ -36,4 +37,7 @@ def main(request, response): if not verified or jwt_payload.get("jti") != challenge: return (400, response.headers, "") + if jwt_payload.get("sub") != session_id_header: + return (400, response.headers, "") + return test_session_manager.get_session_instructions_response(session_id, request) diff --git a/tests/wpt/tests/device-bound-session-credentials/start_session.py b/tests/wpt/tests/device-bound-session-credentials/start_session.py index b9d745e3ed6..d2b7ee87818 100644 --- a/tests/wpt/tests/device-bound-session-credentials/start_session.py +++ b/tests/wpt/tests/device-bound-session-credentials/start_session.py @@ -19,4 +19,7 @@ def main(request, response): if jwt_payload.get("authorization") != test_session_manager.get_authorization_value(): return (400, response.headers, "") + if jwt_payload.get("sub") is not None: + return (400, response.headers, "") + return test_session_manager.get_session_instructions_response(session_id, request) diff --git a/tests/wpt/tests/dom/nodes/name-validation.tentative.html b/tests/wpt/tests/dom/nodes/name-validation.tentative.html new file mode 100644 index 00000000000..ca5e9c11824 --- /dev/null +++ b/tests/wpt/tests/dom/nodes/name-validation.tentative.html @@ -0,0 +1,296 @@ +<!DOCTYPE html> +<meta name=timeout content=long> +<link rel=author href="mailto:jarhar@chromium.org"> +<link rel=help href="https://github.com/whatwg/dom/pull/1079"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +function isAsciiAlpha(codePoint) { + return (codePoint >= 0x41 && codePoint <= 0x5A) || (codePoint >= 0x61 && codePoint <= 0x7A); +} +function isAsciiDigit(codePoint) { + return codePoint >= 0x30 && codePoint <= 0x39; +} +function isAsciiWhitespace(codePoint) { + return codePoint == 0x9 || codePoint == 0xA || codePoint == 0xC || codePoint == 0xD || codePoint == 0x20; +} + +function debugString(str) { + const codePoints = []; + for (let i = 0; i < str.length; i++) { + codePoints.push(str.charCodeAt(i)); + } + return `code points: ${JSON.stringify(codePoints)}, string: "${str}"`; +} + +const latin1CodePoint = 100; +const latin1 = String.fromCodePoint(latin1CodePoint); +const smallEmoji = 'smallEmoji🆖'; +const bigEmoji = 'bigEmoji🅱️'; + +// Testing every variation of a namespace prefix with every variation of a +// local name would make the test take too long to run, so use these instead when +// combining with a namespace prefix. +const validElementLocalNamesShortened = [ + 'div', `latin1${latin1}`, smallEmoji, bigEmoji +]; +const invalidElementLocalNamesShortened = [ + '', 'space ', 'newline\n', 'null\0', `:soh${String.fromCodePoint(1)}`, '5' +]; +const validAttributeLocalNamesShortened = [ + 'attr', `latin1${latin1}`, smallEmoji, bigEmoji +]; +const invalidAttributeLocalNamesShortened = [ + '', 'space ', 'newline\n', 'null\0' +]; + +const validElementLocalNames = validElementLocalNamesShortened.slice(); +const invalidElementLocalNames = invalidElementLocalNamesShortened.slice(); +const validAttributeLocalNames = validAttributeLocalNamesShortened.slice(); +const invalidAttributeLocalNames = invalidAttributeLocalNamesShortened.slice(); +const validNamespacePrefixes = ['', smallEmoji, bigEmoji]; +const invalidNamespacePrefixes = []; +const validDoctypes = ['']; +const invalidDoctypes = []; + +const codePoints = []; +for (let i = 0; i < 0x80; i++) { + codePoints.push(i); +} +codePoints.push(latin1CodePoint); + +// attributes and namespaces +for (const codePoint of codePoints) { + const str = String.fromCodePoint(codePoint); + if (codePoint == 0 || isAsciiWhitespace(codePoint) || codePoint == 0x2F || codePoint == 0x3E) { + invalidNamespacePrefixes.push(str); + invalidAttributeLocalNames.push(str); + } else if (codePoint == 0x3A) { + // colons are not valid namespace prefixes, but due to parsing they can + // never be considered as a namespace prefix, only as a separator between the + // prefix and the local name. + validAttributeLocalNames.push(str); + } else if (codePoint == 0x3D) { + validNamespacePrefixes.push(str); + invalidAttributeLocalNames.push(str); + } else { + validNamespacePrefixes.push(str); + validAttributeLocalNames.push(str); + } +} + +// valid element local names +for (const firstChar of codePoints) { + for (const secondChar of codePoints) { + const str = `${String.fromCodePoint(firstChar)}${String.fromCodePoint(secondChar)}`; + if (isAsciiAlpha(firstChar)) { + if (!secondChar || secondChar == 0x2F || secondChar == 0x3E || isAsciiWhitespace(secondChar)) { + invalidElementLocalNames.push(str); + } else { + validElementLocalNames.push(str); + } + } else { + if (firstChar == 0x3A || firstChar == 0x5F || firstChar >= 0x80) { + if (isAsciiAlpha(secondChar) || + isAsciiDigit(secondChar) || + secondChar == 0x2D || + secondChar == 0x2E || + secondChar == 0x3A || + secondChar == 0x5F || + secondChar >= 0x80) { + validElementLocalNames.push(str); + } else { + invalidElementLocalNames.push(str); + } + } else { + invalidElementLocalNames.push(str); + } + } + } +} + +// doctypes +for (const codePoint of codePoints) { + const str = String.fromCodePoint(codePoint); + if (codePoint == 0 || isAsciiWhitespace(codePoint) || codePoint == 0x3E) { + invalidDoctypes.push(str); + } else { + validDoctypes.push(str); + } +} + +test(() => { + // This regex is provided in the spec and is used here to double check our + // test input. + const validNameRegex = /^(?:[A-Za-z][^\0\t\n\f\r\u0020/>]*|[:_\u0080-\u{10FFFF}][A-Za-z0-9-.:_\u0080-\u{10FFFF}]*)$/u; + for (const validName of validElementLocalNames) { + assert_true( + validNameRegex.test(validName), + `Regex should match: ${debugString(validName)}`); + try { + document.createElement(validName); + } catch (error) { + assert_unreached( + `document.createElement should not have thrown an error for: ${debugString(validName)} ${error.toString()}`); + } + } + for (const invalidName of invalidElementLocalNames) { + assert_false( + validNameRegex.test(invalidName), + `Regex should not match: ${debugString(invalidName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.createElement(invalidName), + `document.createElement should throw an error for: ${debugString(invalidName)}`); + } +}, 'Valid and invalid characters in createElement.'); + +test(() => { + for (const validNamespace of validNamespacePrefixes) { + for (const validName of validElementLocalNamesShortened) { + try { + document.createElementNS('namespaceuri', `${validNamespace}:${validName}`); + } catch (error) { + assert_unreached( + `document.createElementNS should not have thrown an error for: ${debugString(validNamespace)} ${debugString(validName)} ${error.toString()}`); + } + try { + document.implementation.createDocument('namespaceuri', `${validNamespace}:${validName}`); + } catch (error) { + assert_unreached( + `createDocument should not have thrown an error for: ${debugString(validNamespace)} ${debugString(validName)} ${error.toString()}`); + } + } + for (const invalidName of invalidElementLocalNamesShortened) { + assert_throws_dom( + 'InvalidCharacterError', + () => document.createElementNS('namespaceuri', `${validNamespace}:${invalidName}`), + `document.createElementNS should throw an error for: ${debugString(validNamespace)} ${debugString(invalidName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.implementation.createDocument('namespaceuri', `${validNamespace}:${invalidName}`), + `createDocument should throw an error for: ${debugString(validNamespace)} ${debugString(invalidName)}`); + } + } + for (const invalidNamespace of invalidNamespacePrefixes) { + for (const localName of validElementLocalNamesShortened.concat(invalidElementLocalNamesShortened)) { + assert_throws_dom( + 'InvalidCharacterError', + () => document.createElementNS('namespaceuri', `${invalidNamespace}:${localName}`), + `document.createElementNS should throw an error for: ${debugString(invalidNamespace)} ${debugString(localName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.implementation.createDocument('namespaceuri', `${invalidNamespace}:${localName}`), + `createDocument should throw an error for: ${debugString(invalidNamespace)} ${debugString(localName)}`); + } + } +}, 'Valid and invalid characters in createElementNS and createDocument.'); + +test(() => { + for (const validAttributeName of validAttributeLocalNames) { + const element = document.createElement('div'); + try { + element.setAttribute(validAttributeName, 'value'); + } catch (error) { + assert_unreached( + `element.setAttribute should not have thrown an error for: ${debugString(validAttributeName)} ${error.toString()}`); + } + try { + element.toggleAttribute(validAttributeName); + } catch (error) { + assert_unreached( + `element.toggleAttribute should not have thrown an error for: ${debugString(validAttributeName)} ${error.toString()}`); + } + try { + element.toggleAttribute(validAttributeName, false); + } catch (error) { + assert_unreached( + `element.toggleAttribute with false should not have thrown an error for: ${debugString(validAttributeName)} ${error.toString()}`); + } + try { + document.createAttribute(validAttributeName); + } catch (error) { + assert_unreached( + `document.createAttribute should not have thrown an error for: ${debugString(validAttributeName)} ${error.toString()}`); + } + } + for (const invalidAttributeName of invalidAttributeLocalNames) { + const element = document.createElement('div'); + assert_throws_dom( + 'InvalidCharacterError', + () => element.setAttribute(invalidAttributeName, 'value'), + `element.setAttribute should throw an error for: ${debugString(invalidAttributeName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => element.toggleAttribute(invalidAttributeName), + `element.toggleAttribute should throw an error for: ${debugString(invalidAttributeName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => element.toggleAttribute(invalidAttributeName, false), + `element.toggleAttribute with false should throw an error for: ${debugString(invalidAttributeName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.createAttribute(invalidAttributeName), + `document.createAttribute should throw an error for: ${debugString(invalidAttributeName)}`); + } +}, 'Valid and invalid characters in setAttribute, toggleAttribute, and createAttribute.'); + +test(() => { + for (const validNamespace of validNamespacePrefixes) { + for (const validLocalName of validAttributeLocalNamesShortened) { + const element = document.createElement('div'); + try { + element.setAttributeNS('namespaceuri', `${validNamespace}:${validLocalName}`, 'value'); + } catch (error) { + assert_unreached(`element.setAttributeNS should not have thrown an error for: ${debugString(validNamespace)} ${debugString(validLocalName)} ${error.toString()}`); + } + try { + document.createAttributeNS('namespaceuri', `${validNamespace}:${validLocalName}`); + } catch (error) { + assert_unreached(`document.createAttributeNS should not have thrown an error for: ${debugString(validNamespace)} ${debugString(validLocalName)} ${error.toString()}`); + } + } + for (const invalidLocalName of invalidAttributeLocalNamesShortened) { + const element = document.createElement('div'); + assert_throws_dom( + 'InvalidCharacterError', + () => element.setAttributeNS('namespaceuri', `${validNamespace}:${invalidLocalName}`, 'value'), + `element.setAttributeNS should have thrown an error for: ${debugString(validNamespace)} ${debugString(invalidLocalName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.createAttributeNS('namespaceuri', `${validNamespace}:${invalidLocalName}`), + `document.createAttributeNS should have thrown an error for: ${debugString(validNamespace)} ${debugString(invalidLocalName)}`); + } + } + for (const invalidNamespace of invalidNamespacePrefixes) { + for (const localName of validAttributeLocalNamesShortened.concat(invalidAttributeLocalNamesShortened)) { + const element = document.createElement('div'); + assert_throws_dom( + 'InvalidCharacterError', + () => element.setAttributeNS('namespaceuri', `${invalidNamespace}:${localName}`, ''), + `element.setAttributeNS should have thrown an error for: ${debugString(invalidNamespace)} ${debugString(localName)}`); + assert_throws_dom( + 'InvalidCharacterError', + () => document.createAttributeNS('namespaceuri', `${invalidNamespace}:${localName}`), + `document.createAttributeNS should have thrown an error for: ${debugString(invalidNamespace)} ${debugString(localName)}`); + } + } +}, 'Valid and invalid characters in setAttributeNS and createAttributeNS.'); + +test(() => { + for (const validDoctype of validDoctypes) { + try { + document.implementation.createDocumentType(validDoctype, 'publicid', 'systemid'); + } catch (error) { + assert_unreached(`createDocumentType should not have thrown an error for ${debugString(validDoctype)} ${error.toString()}`); + } + } + for (const invalidDoctype of invalidDoctypes) { + assert_throws_dom( + 'InvalidCharacterError', + () => document.implementation.createDocumentType(invalidDoctype, 'publicid', 'systemid'), + `createDocumentType should have thrown an error for: ${debugString(invalidDoctype)}`); + } +}, 'Valid and invalid characters in createDocumentType.'); +</script> diff --git a/tests/wpt/tests/fedcm/fedcm-login-status/idp-login-with-failed-accounts-fetch.https.html b/tests/wpt/tests/fedcm/fedcm-login-status/idp-login-with-failed-accounts-fetch.https.html new file mode 100644 index 00000000000..75d2c589b1d --- /dev/null +++ b/tests/wpt/tests/fedcm/fedcm-login-status/idp-login-with-failed-accounts-fetch.https.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>FedCM IDP log-in status API tests</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<script type="module"> +import {request_options_with_mediation_required, + fedcm_test, + fedcm_get_dialog_type_promise, + select_manifest, + mark_signed_out} from '../support/fedcm-helper.sub.js'; + +fedcm_test(async t => { + await mark_signed_out(); + + let test_options = request_options_with_mediation_required("manifest_no_accounts_login_delay.json"); + await select_manifest(t, test_options); + + test_options.identity.mode = "active"; + let cred_promise = navigator.credentials.get(test_options); + + // We should get the login popup window, which will automatically set + // the login status and close itself. + // The promise should get rejected because the accounts list is empty. + + return promise_rejects_dom(t, 'NetworkError', cred_promise); +}, 'Tests the IDP login dialog and subsequent account chooser.'); +</script> diff --git a/tests/wpt/tests/fedcm/support/login_delay.html b/tests/wpt/tests/fedcm/support/login_delay.html new file mode 100644 index 00000000000..469a7ee5cbe --- /dev/null +++ b/tests/wpt/tests/fedcm/support/login_delay.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<script> +async function doLogin() { + navigator.login.setStatus("logged-in"); + // Delay the close call to allow the accounts fetch to complete beforehand. + setTimeout(() => { + IdentityProvider.close(); + }, 200); +} +window.onload = doLogin; +</script> diff --git a/tests/wpt/tests/fedcm/support/manifest_no_accounts_login_delay.json b/tests/wpt/tests/fedcm/support/manifest_no_accounts_login_delay.json new file mode 100644 index 00000000000..030e4a85bfa --- /dev/null +++ b/tests/wpt/tests/fedcm/support/manifest_no_accounts_login_delay.json @@ -0,0 +1,6 @@ +{ + "accounts_endpoint": "no_accounts.py", + "client_metadata_endpoint": "client_metadata.py", + "id_assertion_endpoint": "token_with_account_id.py", + "login_url": "login_delay.html" +} diff --git a/tests/wpt/tests/fetch/fetch-later/resources/fetch-later-helper.js b/tests/wpt/tests/fetch/fetch-later/resources/fetch-later-helper.js index ef1d7090a8f..32220ae39e3 100644 --- a/tests/wpt/tests/fetch/fetch-later/resources/fetch-later-helper.js +++ b/tests/wpt/tests/fetch/fetch-later/resources/fetch-later-helper.js @@ -415,7 +415,10 @@ class FetchLaterIframeExpectation { } if (e.data.type === FetchLaterIframeMessageType.ERROR) { const actual = e.data.error.name || e.data.error.type; - if (e.data.error.constructor.name === 'DOMException' && + if (this.expectedDomErrorName === 'QuotaExceededError') { + return actual == this.expectedDomErrorName; + } else if ( + e.data.error.constructor.name === 'DOMException' && actual == this.expectedDomErrorName) { return true; } diff --git a/tests/wpt/tests/fetch/fetch-later/resources/fetch-later.html b/tests/wpt/tests/fetch/fetch-later/resources/fetch-later.html index b295be116c7..955f815d940 100644 --- a/tests/wpt/tests/fetch/fetch-later/resources/fetch-later.html +++ b/tests/wpt/tests/fetch/fetch-later/resources/fetch-later.html @@ -30,6 +30,12 @@ fetchLater(TARGET_URL, REQUEST_INIT); postMessageBack({type: FetchLaterIframeMessageType.DONE}); } catch (e) { + if (e.name == "QuotaExceededError" && + e instanceof DOMException) { + // PostMessage is unable to serialize the QuotExceededError object. + // Therefore do basic checks here and pass error name if successful. + e = {name: e.name}; + } postMessageBack({type: FetchLaterIframeMessageType.ERROR, error: e}); } </script> diff --git a/tests/wpt/tests/fetch/local-network-access/fetch.tentative.https.html b/tests/wpt/tests/fetch/local-network-access/fetch.tentative.https.html index ac2c3cca28e..b783269207b 100644 --- a/tests/wpt/tests/fetch/local-network-access/fetch.tentative.https.html +++ b/tests/wpt/tests/fetch/local-network-access/fetch.tentative.https.html @@ -11,7 +11,7 @@ "use strict"; promise_test(t => { - const sourceUrl = resolveUrl("resources/fetch-private.html", + const sourceUrl = resolveUrl("resources/fetch-local.html", sourceResolveOptions({ server: Server.HTTPS_PUBLIC })); function checkResult(evt) { @@ -26,12 +26,12 @@ t.add_cleanup(() => popup.close()); return promise; - }, 'LNA Public to private with permission'); + }, 'LNA Public to local with permission'); promise_test(t => { // TODO(crbug.com/406991278): consider moving permission url param into // options - const sourceUrl = resolveUrl("resources/fetch-private.html?permission=denied", + const sourceUrl = resolveUrl("resources/fetch-local.html?permission=denied", sourceResolveOptions({ server: Server.HTTPS_PUBLIC })); function checkResult(evt) { @@ -46,10 +46,10 @@ t.add_cleanup(() => popup.close()); return promise; - }, 'LNA Public to private with permission denied'); + }, 'LNA Public to local with permission denied'); promise_test(t => { - const sourceUrl = resolveUrl("resources/fetch-private-http.html", + const sourceUrl = resolveUrl("resources/fetch-local-http.html", sourceResolveOptions({ server: Server.HTTPS_PUBLIC })); function checkResult(evt) { @@ -64,7 +64,7 @@ t.add_cleanup(() => popup.close()); return promise; - }, 'LNA Public to private http mixed content bypass'); + }, 'LNA Public to local http mixed content bypass'); promise_test(t => { const sourceUrl = resolveUrl("resources/fetch-public-http-wrong-address-space.html", diff --git a/tests/wpt/tests/fetch/local-network-access/resources/fetch-private-http.html b/tests/wpt/tests/fetch/local-network-access/resources/fetch-local-http.html index 517629b758e..dcad775bfec 100644 --- a/tests/wpt/tests/fetch/local-network-access/resources/fetch-private-http.html +++ b/tests/wpt/tests/fetch/local-network-access/resources/fetch-local-http.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Fetch HTTP private with targetAddressSpace private </title> +<title>Fetch HTTP local with targetAddressSpace local </title> <script src="/resources/testdriver.js"></script> <script src="/resources/testdriver-vendor.js"></script> @@ -8,17 +8,17 @@ <script> "use strict"; -// Fetch a private address over HTTP. Fetch is annotated with a -// targetAddressSpace of private to allow for mixed content check bypassing. +// Fetch a local address over HTTP. Fetch is annotated with a +// targetAddressSpace of local to allow for mixed content check bypassing. // -// TODO(crbug.com/406991278): consolidate with fetch-private.html adding +// TODO(crbug.com/406991278): consolidate with fetch-local.html adding // options to minimize # of resources needed. Promise.resolve().then(async () => { test_driver.set_test_context(opener); await test_driver.set_permission({ name: 'local-network-access' }, 'granted'); const target = { - server: Server.HTTP_PRIVATE, + server: Server.HTTP_LOCAL, behavior: { response: ResponseBehavior.allowCrossOrigin() }, }; const targetUrl = resolveTargetUrl(target); diff --git a/tests/wpt/tests/fetch/local-network-access/resources/fetch-private.html b/tests/wpt/tests/fetch/local-network-access/resources/fetch-local.html index b96a207ec33..bc12e2660bc 100644 --- a/tests/wpt/tests/fetch/local-network-access/resources/fetch-private.html +++ b/tests/wpt/tests/fetch/local-network-access/resources/fetch-local.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Fetch Private resource</title> +<title>Fetch Local resource</title> <script src="/resources/testdriver.js"></script> <script src="/resources/testdriver-vendor.js"></script> @@ -9,7 +9,7 @@ "use strict"; // Set the 'local-network-access' permission then attempt to fetch a resource -// in the private address space. +// in the local address space. // // By default, 'local-network-access' permission is set to 'granted'. This can // be changed by passing in a different value via the 'permission' URL parameter. @@ -30,7 +30,7 @@ Promise.resolve().then(async () => { await test_driver.set_permission({ name: 'local-network-access' }, permission_value); const target = { - server: Server.HTTPS_PRIVATE, + server: Server.HTTPS_LOCAL, behavior: { response: ResponseBehavior.allowCrossOrigin() }, }; const targetUrl = resolveTargetUrl(target); diff --git a/tests/wpt/tests/fetch/local-network-access/resources/fetch-public-http-wrong-address-space.html b/tests/wpt/tests/fetch/local-network-access/resources/fetch-public-http-wrong-address-space.html index c15a87ff7b9..fb306f99d3c 100644 --- a/tests/wpt/tests/fetch/local-network-access/resources/fetch-public-http-wrong-address-space.html +++ b/tests/wpt/tests/fetch/local-network-access/resources/fetch-public-http-wrong-address-space.html @@ -1,6 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> -<title>Fetch HTTP public targetAddress private resource</title> +<title>Fetch HTTP public targetAddress local resource</title> <script src="/resources/testdriver.js"></script> <script src="/resources/testdriver-vendor.js"></script> @@ -9,11 +9,11 @@ "use strict"; // Fetch a public address over HTTP. Fetch is annotated with a -// targetAddressSpace of private to try to bypass mixed content, but should +// targetAddressSpace of local to try to bypass mixed content, but should // fail because the address space of the resource does not match the target // address space. // -// TODO(crbug.com/406991278): consolidate with fetch-private.html adding +// TODO(crbug.com/406991278): consolidate with fetch-local.html adding // options to minimize # of resources needed. Promise.resolve().then(async () => { test_driver.set_test_context(opener); diff --git a/tests/wpt/tests/fetch/local-network-access/resources/support.sub.js b/tests/wpt/tests/fetch/local-network-access/resources/support.sub.js index 6b7813fa89d..09e234c5f24 100644 --- a/tests/wpt/tests/fetch/local-network-access/resources/support.sub.js +++ b/tests/wpt/tests/fetch/local-network-access/resources/support.sub.js @@ -4,28 +4,28 @@ // space names. const SERVER_PORTS = { "http": { - "local": {{ports[http][0]}}, - "private": {{ports[http-local][0]}}, + "loopback": {{ports[http][0]}}, + "local": {{ports[http-local][0]}}, "public": {{ports[http-public][0]}}, }, "https": { - "local": {{ports[https][0]}}, - "other-local": {{ports[https][1]}}, - "private": {{ports[https-local][0]}}, + "loopback": {{ports[https][0]}}, + "other-loopback": {{ports[https][1]}}, + "local": {{ports[https-local][0]}}, "public": {{ports[https-public][0]}}, }, "ws": { - "local": {{ports[ws][0]}}, + "loopback": {{ports[ws][0]}}, }, "wss": { - "local": {{ports[wss][0]}}, + "loopback": {{ports[wss][0]}}, }, }; // A `Server` is a web server accessible by tests. It has the following shape: // // { -// addressSpace: the IP address space of the server ("local", "private" or +// addressSpace: the IP address space of the server ("loopback", "local" or // "public"), // name: a human-readable name for the server, // port: the port on which the server listens for connections, @@ -56,15 +56,15 @@ class Server { }; } + static HTTP_LOOPBACK = Server.get("http", "loopback"); static HTTP_LOCAL = Server.get("http", "local"); - static HTTP_PRIVATE = Server.get("http", "private"); static HTTP_PUBLIC = Server.get("http", "public"); + static HTTPS_LOOPBACK = Server.get("https", "loopback"); + static OTHER_HTTPS_LOOPBACK = Server.get("https", "other-loopback"); static HTTPS_LOCAL = Server.get("https", "local"); - static OTHER_HTTPS_LOCAL = Server.get("https", "other-local"); - static HTTPS_PRIVATE = Server.get("https", "private"); static HTTPS_PUBLIC = Server.get("https", "public"); - static WS_LOCAL = Server.get("ws", "local"); - static WSS_LOCAL = Server.get("wss", "local"); + static WS_LOOPBACK = Server.get("ws", "loopback"); + static WSS_LOOPBACK = Server.get("wss", "loopback"); }; // Resolves a URL relative to the current location, returning an absolute URL. diff --git a/tests/wpt/tests/fullscreen/model/remove-first-sibling.html b/tests/wpt/tests/fullscreen/model/remove-first-sibling.html new file mode 100644 index 00000000000..be1f501afff --- /dev/null +++ b/tests/wpt/tests/fullscreen/model/remove-first-sibling.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<title>Remove the first of two sibling elements in the fullscreen stack</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="../trusted-click.js"></script> +<div id="log"></div> +<div id="a"></div> +<div id="b"></div> +<script> + promise_test(async (t) => { + t.add_cleanup(() => { + if (document.fullscreenElement) { + return document.exitFullscreen(); + } + }); + + const a = document.getElementById("a"); + const b = document.getElementById("b"); + await Promise.all([trusted_request(a), fullScreenChange()]); + + assert_equals(document.fullscreenElement, a, "fullscreen element after first request"); + assert_true(a.matches(":fullscreen"), "a matches :fullscreen after first request"); + + await Promise.all([trusted_request(b, a), fullScreenChange()]); + assert_equals(document.fullscreenElement, b, "fullscreen element after second request"); + assert_true(a.matches(":fullscreen"), "a matches :fullscreen after second request"); + assert_true(b.matches(":fullscreen"), "b matches :fullscreen after second request"); + + // Removing /a/ now shouldn't do anything except remove it from the top + // layer, which causes it to no longer match :fullscreen. + a.remove(); + assert_equals(document.fullscreenElement, b, "fullscreen element immediately after removal of a"); + assert_false(a.matches(":fullscreen"), "a should no longer match :fullscreen immediately after removal"); + assert_true(b.matches(":fullscreen"), "b matches :fullscreen immediately after removal of a"); + + // No fullscreenchange event should fire. If the removal triggered exiting + // fullscreen the event would be fired after an async section and an + // animation frame task, so wait until after that. + document.onfullscreenchange = t.unreached_func("fullscreenchange event"); + await new Promise((resolve) => { + requestAnimationFrame(resolve); + }); + }); +</script> diff --git a/tests/wpt/tests/fullscreen/model/remove-last-sibling.html b/tests/wpt/tests/fullscreen/model/remove-last-sibling.html new file mode 100644 index 00000000000..f893a3f9d5a --- /dev/null +++ b/tests/wpt/tests/fullscreen/model/remove-last-sibling.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<title>Remove the last of two sibling elements in the fullscreen stack</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="../trusted-click.js"></script> +<div id="log"></div> +<div id="a"></div> +<div id="b"></div> +<script> + promise_test(async (t) => { + t.add_cleanup(() => { + if (document.fullscreenElement) { + return document.exitFullscreen(); + } + }); + + const a = document.getElementById("a"); + const b = document.getElementById("b"); + await Promise.all([trusted_request(a), fullScreenChange()]); + + assert_equals(document.fullscreenElement, a, "fullscreen element after first request"); + assert_true(a.matches(":fullscreen"), "a matches :fullscreen after first request"); + + await Promise.all([trusted_request(b, a), fullScreenChange()]); + assert_equals(document.fullscreenElement, b, "fullscreen element after second request"); + assert_true(a.matches(":fullscreen"), "a matches :fullscreen after second request"); + assert_true(b.matches(":fullscreen"), "b matches :fullscreen after second request"); + + // Removing the fullscreen element (b) triggers exiting fullscreen. Some changes are + // visible synchronously and the others come when the event fires. + b.remove(); + assert_equals(document.fullscreenElement, a, "fullscreen element immediately after removal of b"); + assert_true(a.matches(":fullscreen"), "a matches :fullscreen immediately after removal of b"); + assert_false(b.matches(":fullscreen"), "b no longer matches :fullscreen immediately after removal"); + + // A fullscreenchange event should fire and all state should be cleared. + await fullScreenChange(); + assert_equals(document.fullscreenElement, null, "fullscreen element after event"); + assert_false(a.matches(":fullscreen"), "a no longer matches :fullscreen after event"); + assert_false(b.matches(":fullscreen"), "b no longer matches :fullscreen after event"); + }); +</script> diff --git a/tests/wpt/tests/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js b/tests/wpt/tests/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js index 6c88b49fd4a..0181394f32d 100644 --- a/tests/wpt/tests/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js +++ b/tests/wpt/tests/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js @@ -228,82 +228,6 @@ const DEFAULT_CONTEXT_CONFIG = new RemoteContextConfig(); /** - * This class represents a configuration for creating remote contexts. This is - * the entry-point - * for creating remote contexts, providing @see addWindow . - */ - class RemoteContextHelper { - /** - * @param {RemoteContextConfig|object} config The configuration - * for this remote context. - */ - constructor(config) { - this.config = RemoteContextConfig.ensure(config); - } - - /** - * Creates a new remote context and returns a `RemoteContextWrapper` giving - * access to it. - * @private - * @param {Object} options - * @param {(url: string) => Promise<undefined>} [options.executorCreator] A - * function that takes a URL and causes the browser to navigate some - * window to that URL, e.g. via an iframe or a new window. If this is - * not supplied, then the returned RemoteContextWrapper won't actually - * be communicating with something yet, and something will need to - * navigate to it using its `url` property, before communication can be - * established. - * @param {RemoteContextConfig|object} [options.extraConfig] If supplied, - * extra configuration for this remote context to be merged with - * `this`'s existing config. If it's not a `RemoteContextConfig`, it - * will be used to construct a new one. - * @returns {Promise<RemoteContextWrapper>} - */ - async createContext({ - executorCreator, - extraConfig, - isWorker = false, - }) { - const config = - this.config.merged(RemoteContextConfig.ensure(extraConfig)); - - // UUID is needed for executor. - const uuid = token(); - const url = await config.createExecutorUrl(uuid, isWorker); - - if (executorCreator) { - if (config.urlType == 'blank') { - await executorCreator(undefined, await fetchText(url)); - } else { - await executorCreator(url, undefined); - } - } - - return new RemoteContextWrapper(new RemoteContext(uuid), this, url); - } - - /** - * Creates a window with a remote context. @see createContext for - * @param {RemoteContextConfig|object} [extraConfig] Will be - * merged with `this`'s config. - * @param {Object} [options] - * @param {string} [options.target] Passed to `window.open` as the - * 2nd argument - * @param {string} [options.features] Passed to `window.open` as the - * 3rd argument - * @returns {Promise<RemoteContextWrapper>} - */ - addWindow(extraConfig, options) { - return this.createContext({ - executorCreator: windowExecutorCreator(options), - extraConfig, - }); - } - } - // Export this class. - self.RemoteContextHelper = RemoteContextHelper; - - /** * Attaches header to the URL. See * https://web-platform-tests.org/writing-tests/server-pipes.html#headers * @param {string} url the URL to which headers should be attached. @@ -736,4 +660,87 @@ } } } + + + /** + * This class represents a configuration for creating remote contexts. This is + * the entry-point + * for creating remote contexts, providing @see addWindow . + */ + class RemoteContextHelper { + /** + * The constructor to use when creating new remote context wrappers. + * Can be overridden by subclasses. + */ + static RemoteContextWrapper = RemoteContextWrapper; + + /** + * @param {RemoteContextConfig|object} config The configuration + * for this remote context. + */ + constructor(config) { + this.config = RemoteContextConfig.ensure(config); + } + + /** + * Creates a new remote context and returns a `RemoteContextWrapper` giving + * access to it. + * @private + * @param {Object} options + * @param {(url: string) => Promise<undefined>} [options.executorCreator] A + * function that takes a URL and causes the browser to navigate some + * window to that URL, e.g. via an iframe or a new window. If this is + * not supplied, then the returned RemoteContextWrapper won't actually + * be communicating with something yet, and something will need to + * navigate to it using its `url` property, before communication can be + * established. + * @param {RemoteContextConfig|object} [options.extraConfig] If supplied, + * extra configuration for this remote context to be merged with + * `this`'s existing config. If it's not a `RemoteContextConfig`, it + * will be used to construct a new one. + * @returns {Promise<RemoteContextWrapper>} + */ + async createContext({ + executorCreator, + extraConfig, + isWorker = false, + }) { + const config = + this.config.merged(RemoteContextConfig.ensure(extraConfig)); + + // UUID is needed for executor. + const uuid = token(); + const url = await config.createExecutorUrl(uuid, isWorker); + + if (executorCreator) { + if (config.urlType == 'blank') { + await executorCreator(undefined, await fetchText(url)); + } else { + await executorCreator(url, undefined); + } + } + + return new this.constructor.RemoteContextWrapper(new RemoteContext(uuid), this, url); + } + + /** + * Creates a window with a remote context. @see createContext for + * @param {RemoteContextConfig|object} [extraConfig] Will be + * merged with `this`'s config. + * @param {Object} [options] + * @param {string} [options.target] Passed to `window.open` as the + * 2nd argument + * @param {string} [options.features] Passed to `window.open` as the + * 3rd argument + * @returns {Promise<RemoteContextWrapper>} + */ + addWindow(extraConfig, options) { + return this.createContext({ + executorCreator: windowExecutorCreator(options), + extraConfig, + }); + } + } + // Export this class. + self.RemoteContextHelper = RemoteContextHelper; } diff --git a/tests/wpt/tests/html/canvas/element/manual/imagebitmap/common.sub.js b/tests/wpt/tests/html/canvas/element/manual/imagebitmap/common.sub.js index 525d28553aa..160a0cbf9ac 100644 --- a/tests/wpt/tests/html/canvas/element/manual/imagebitmap/common.sub.js +++ b/tests/wpt/tests/html/canvas/element/manual/imagebitmap/common.sub.js @@ -57,7 +57,10 @@ function makeVideo() { return makeMakeVideo("/images/pattern")(); } -var imageBitmapDataUrlVideoPromise = fetch(getVideoURI("/images/pattern")) +var imageBitmapDataUrlVideoPromise = self.GLOBAL && self.GLOBAL.isWorker() + // /common/media.js can't load in a Worker so we don't have getVideoURI + ? null + : fetch(getVideoURI("/images/pattern")) .then(response => Promise.all([response.headers.get("Content-Type"), response.arrayBuffer()])) .then(([type, data]) => { return new Promise(function(resolve, reject) { diff --git a/tests/wpt/tests/html/canvas/element/manual/imagebitmap/createImageBitmap-resolves-in-task.any.js b/tests/wpt/tests/html/canvas/element/manual/imagebitmap/createImageBitmap-resolves-in-task.any.js new file mode 100644 index 00000000000..0d2ddf5855e --- /dev/null +++ b/tests/wpt/tests/html/canvas/element/manual/imagebitmap/createImageBitmap-resolves-in-task.any.js @@ -0,0 +1,117 @@ +// META: title=createImageBitmap resolves in a task +// META: script=/common/media.js +// META: script=./common.sub.js +function makeWorkerImageBitmap() { + return makeOffscreenCanvas().then(canvas => { + return createImageBitmap(canvas); + }); +} +var imageSourceTypes = self.GLOBAL.isWorker() ? + [ + { name: 'an OffscreenCanvas', factory: makeOffscreenCanvas }, + { name: 'an ImageData', factory: makeImageData }, + { name: 'an ImageBitmap', factory: makeWorkerImageBitmap }, + { name: 'a Blob', factory: makeBlob('/images/pattern.png') }, + ] : + imageSourceTypes; + +var testFuncs = { + reject_sync: (promiseFunc, source, t) => { + return new Promise((resolve, reject) => { + let rejected = false; + promiseFunc(source).then(() => { + reject(new Error('Expected this call to reject')); + }, (err) => { + rejected = true; + }); + Promise.resolve().then(() => { + try { + assert_equals(rejected, true, 'The promise should be rejected synchronously') + resolve(t); + } catch (err) { + reject(err); + } + }) + }); + + }, + resolve_async: (promiseFunc, source, t) => { + return new Promise((resolve, reject) => { + let taskRan = false; + promiseFunc(source).then(() => { + try { + assert_equals(taskRan, true, 'The promise should be resolved asynchronously') + resolve(t); + } catch (err) { + reject(err) + } + }, t.unreached_func('Expected this call to resolve')) + Promise.resolve().then(() => { + taskRan = true; + }); + }); + }, + reject_async: (promiseFunc, source, t) => { + return new Promise((resolve, reject) => { + let taskRan = false; + Promise.resolve().then(() => { + promiseFunc(source).then( + t.unreached_func('Expected this call to reject'), + () => { + try { + assert_equals(taskRan, true, 'The promise should be rejected asynchronously') + resolve(t); + } catch (err) { + reject(err) + } + }, + ); + }); + Promise.resolve().then(() => { + taskRan = true; + }); + }); + }, +}; + +var testCases = [{ + description: 'createImageBitmap with <sourceType> source and ' + + 'invalid cropHeight', + promiseTestFunction: (source) => createImageBitmap(source, 0, 0, 0, 0), + resolution: 'reject_sync' + }, + { + description: 'createImageBitmap with <sourceType> source and ' + + 'invalid resizeHeight', + promiseTestFunction: (source) => createImageBitmap(source, { + resizeWidth: 0, + resizeHeight: 0 + }), + resolution: 'reject_sync' + }, + { + description: 'createImageBitmap with <sourceType> source', + promiseTestFunction: (source) => createImageBitmap(source), + resolution: 'resolve_async' + }, +]; + +imageSourceTypes.forEach(imageSourceType => { + testCases.forEach(testCase => { + let description = `${testCase.description.replace('<sourceType>', + imageSourceType.name)} should ${testCase.resolution.replace('_', ' ')}`; + + promise_test(t => { + return imageSourceType.factory().then(source => { + const tester = testFuncs[testCase.resolution]; + return tester(testCase.promiseTestFunction, source, t); + }) + }, description); + + }); +}); +promise_test(t => { + return makeBlob('data:,')().then(image => { + return testFuncs.reject_async((source) => createImageBitmap(source), image, t); + }); +}, 'Invalid Blob source should reject async');
\ No newline at end of file diff --git a/tests/wpt/tests/html/interaction/focus/processing-model/focus-fixup-rule-one-no-dialogs.html b/tests/wpt/tests/html/interaction/focus/processing-model/focus-fixup-rule-one-no-dialogs.html index 2413fe26673..5471e8e9ec1 100644 --- a/tests/wpt/tests/html/interaction/focus/processing-model/focus-fixup-rule-one-no-dialogs.html +++ b/tests/wpt/tests/html/interaction/focus/processing-model/focus-fixup-rule-one-no-dialogs.html @@ -15,95 +15,98 @@ <fieldset id="fieldset2" disabled><legend><button id="button5">Button 5</button></legend></fieldset> <div id="div" tabindex="0">Div</div> <div id="editable" contenteditable=true>editor</div> + <button id="button6">Button 6</button> </div> <script> "use strict"; -test(() => { - const button = document.querySelector("#button1"); - button.focus(); +function test_focus_fixup(selector, change, expectSync = false) { + promise_test(async function(t) { + // Make sure we're not running from a ResizeObserver / etc notification. + await new Promise(r => t.step_timeout(r, 0)); - assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); + const el = document.querySelector(selector); + el.focus(); - button.disabled = true; - - assert_not_equals(document.activeElement, button, "After disabling, the button must no longer be focused"); - assert_equals(document.activeElement, document.body, "After disabling, the body must be focused"); + assert_equals(document.activeElement, el, `Sanity check: ${selector} must start focused`); -}, "Disabling the active element (making it inert)"); + change(el); -test(() => { - const button = document.querySelector("#button2"); - button.focus(); + { + const fn = expectSync ? assert_not_equals : assert_equals; + fn(document.activeElement, el, `active element ${expectSync ? "is" : "isn't"} fixed-up sync`); + } - assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); + // We don't expect blur events in the sync case per spec yet, at least. + if (!expectSync) { + // Fixup should run after animation frame callbacks, right before the end of + // "update the rendering", so after resize observations. + let ranFirstRaf = false; + let ranRO = false; - button.hidden = true; + let resolveDone; + let done = new Promise(r => { resolveDone = r; }); - assert_not_equals(document.activeElement, button, "After hiding, the button must no longer be focused"); - assert_equals(document.activeElement, document.body, "After hiding, the body must be focused"); + requestAnimationFrame(t.step_func(() => { + ranFirstRaf = true; + assert_equals(document.activeElement, el, "activeElement shouldn't have changed yet (rAF)"); + requestAnimationFrame(t.step_func(() => { + assert_true(ranRO, "ResizeObserver should've ran on the previous frame"); + resolveDone(); + })); + })); -}, "Hiding the active element"); + let ro = new ResizeObserver(t.step_func(() => { + assert_true(ranFirstRaf, "requestAnimationFrame should run before ResizeObserver"); + ranRO = true; + assert_equals(document.activeElement, el, "activeElement shouldn't have changed yet (ResizeObserver)"); + })); -test(() => { - const button = document.querySelector("#button3"); - button.focus(); + // TODO: Test IntersectionObserver timing. It's a bit trickier because it + // uses its own task source and so on. + ro.observe(document.documentElement); - assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); + await done; - button.remove(); + ro.disconnect(); + } - assert_not_equals(document.activeElement, button, "After removing, the button must no longer be focused"); - assert_equals(document.activeElement, document.body, "After removing, the body must be focused"); + assert_not_equals(document.activeElement, el, "focus is fixed up"); + assert_equals(document.activeElement, document.body, "Body is focused"); + }, selector); +} -}, "Removing the active element from the DOM"); +test_focus_fixup("#button1", function(button) { + button.disabled = true; +}); -test(() => { - const fieldset = document.querySelector("#fieldset1"); - const button = document.querySelector("#button4"); - button.focus(); - assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); +test_focus_fixup("#button2", function(button) { + button.hidden = true; +}); - fieldset.disabled = true; +test_focus_fixup("#button3", function(button) { + button.remove(); +}, /* expectSync = */ true); - assert_not_equals(document.activeElement, button, "After disabling ancestor fieldset, the button must no longer be focused"); - assert_equals(document.activeElement, document.body, "After disabling ancestor fieldset, the body must be focused"); -}, "Disabling <fieldset> affects its descendants"); +test_focus_fixup("#button4", function(button) { + document.querySelector("#fieldset1").disabled = true; +}); -test(() => { +test_focus_fixup("#button5", function(button) { const fieldset = document.querySelector("#fieldset2"); - const button = document.querySelector("#button5"); - button.focus(); - assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); - fieldset.insertBefore(document.createElement("legend"), fieldset.firstChild); +}); - assert_not_equals(document.activeElement, button, "After changing a legend element, the button must no longer be focused"); - assert_equals(document.activeElement, document.body, "After changing a legend element, the body must be focused"); -}, "Changing the first legend element in disabled <fieldset>"); - -test(() => { - const div = document.querySelector("#div"); - div.focus(); - - assert_equals(document.activeElement, div, "Sanity check: the div must start focused"); - +test_focus_fixup("#div", function(div) { div.removeAttribute("tabindex"); +}); - assert_not_equals(document.activeElement, div, "After removing tabindex, the div must no longer be focused"); - assert_equals(document.activeElement, document.body, "After removing tabindex, the body must be focused"); - -}, "Removing the tabindex attribute from a div"); - -test(() => { - const div = document.querySelector("#editable"); - div.focus(); - assert_equals(document.activeElement, div, "Sanity check: the div must start focused"); - +test_focus_fixup("#editable", function(div) { div.contentEditable = false; +}); - assert_not_equals(document.activeElement, div, "After disabling contentEditable, the div must no longer be focused"); - assert_equals(document.activeElement, document.body, "After disabling contentEditable, the body must be focused"); -}, "Disabling contenteditable"); +test_focus_fixup("#button6", function(button) { + button.style.visibility = "hidden"; +}); </script> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex-ref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex-ref.html new file mode 100644 index 00000000000..04c000ad5ad --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex-ref.html @@ -0,0 +1,15 @@ +<!DOCTYPE HTML> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + font-size: 60px; +} + +</style> + +<select> + <option>Option</option> +</select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex.html new file mode 100644 index 00000000000..628c7ec51f4 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-height-in-flex.html @@ -0,0 +1,30 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-height-in-flex-ref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + font-size: 60px; +} + +</style> + +<div style="display:flex; flex-direction: column; align-items: flex-start; height: 100px;"> + <select> + <option>Option</option> + </select> + <div style="color: transparent"> + This div has a lot of text in it but it should not make the select become smaller. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + A lot of text. Really a lot of text. + </div> +</div> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-notref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-notref.html new file mode 100644 index 00000000000..422f187dc69 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-notref.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 25px; + height: calc(max(1lh, 24px) + 1px); +} + +</style> + +<select></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref.html new file mode 100644 index 00000000000..1c37e12b0bc --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-size-empty-001-ref2.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 24px; + height: max(1lh, 24px); +} + +</style> + +<select></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref2.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref2.html new file mode 100644 index 00000000000..69170af04b5 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001-ref2.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML> +<link rel="mismatch" href="min-size-empty-001-notref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 23px; + height: calc(max(1lh, 24px) - 1px); +} + +</style> + +<select></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001.html new file mode 100644 index 00000000000..fd5cc4a0d02 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-001.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-size-empty-001-ref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +</style> + +<select></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-notref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-notref.html new file mode 100644 index 00000000000..0500b54b758 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-notref.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 25px; + height: calc(max(1lh, 24px) + 1px); +} + +</style> + +<select><option></option></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref.html new file mode 100644 index 00000000000..c9e2d2333e7 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-size-empty-002-ref2.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 24px; + height: max(1lh, 24px); +} + +</style> + +<select><option></option></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref2.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref2.html new file mode 100644 index 00000000000..dfbbbcac533 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002-ref2.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML> +<link rel="mismatch" href="min-size-empty-002-notref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +select { + width: 23px; + height: calc(max(1lh, 24px) - 1px); +} + +</style> + +<select><option></option></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002.html new file mode 100644 index 00000000000..b6256c93b28 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-size-empty-002.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-size-empty-002-ref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} +select::picker-icon { + display: none; +} + +</style> + +<select><option></option></select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex-ref.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex-ref.html new file mode 100644 index 00000000000..33df77bd0f1 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex-ref.html @@ -0,0 +1,12 @@ +<!DOCTYPE HTML> +<style> + +select, select::picker(select) { + appearance: base-select; +} + +</style> + +<select> + <option>This is an option</option> +</select> diff --git a/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex.html b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex.html new file mode 100644 index 00000000000..f3510a29585 --- /dev/null +++ b/tests/wpt/tests/html/rendering/replaced-elements/the-select-element/customizable-select/min-width-in-flex.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML> +<link rel="match" href="min-width-in-flex-ref.html"> +<style> + +select, select::picker(select) { + appearance: base-select; +} + +select { + white-space: nowrap; +} + +</style> + +<div style="display:flex; flex-direction: row; width: 400px"> + <select style="align-self: flex-start"> + <option>This is an option</option> + </select> + <div style="color: transparent"> + This div has a lot of text in it but it should not make the select become smaller. + A lot of text. Really a lot of text. + </div> +</div> diff --git a/tests/wpt/tests/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-unavailable.tentative.html b/tests/wpt/tests/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.tentative.html index ae6fa0e4328..c10a942069c 100644 --- a/tests/wpt/tests/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-unavailable.tentative.html +++ b/tests/wpt/tests/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.tentative.html @@ -1,7 +1,7 @@ <!doctype html> <head> <meta charset="utf-8"> -<title>HTMLImageElement naturalWidth/naturalHeight behavior for SVG that lacks at least one natural dimension</title> +<title>HTMLImageElement attributes naturalWidth, naturalHeight, width, height</title> <!-- Note: this test asserts a different expectation from what the HTML spec requires, as of mid-2025 when this testcase is being written. The spec behavior doesn't appear to be web-compatible for some of the cases here, @@ -58,12 +58,50 @@ img { * The "title" attribute is a description of the scenario being tested, and it must be unique to satisfy the test harness requirements. --> -<!-- FIRST PART OF TEST: No viewBox. Just a missing (or edge-casey, i.e. - negative or percent-valued) values, for the width and height attrs on the +<!-- JPG images --> +<img src="resources/cat.jpg" + title="raster image" + data-natural-width="320" data-natural-height="240"> +<img src="resources/cat.jpg" width="10" height="10" + title="raster image with width/height attributes" + data-natural-width="320" data-natural-height="240" + data-width="10" data-height="10" + data-not-rendered-width="10" data-not-rendered-height="10"> +<!-- Use "size-comes-from-broken-image-icon" attribute to opt out of checking + img.width and img.height, because they come from the UA-dependent + size of the broken image icon: --> +<img src="non-existent.jpg" + title="non existent image, no natural dimensions" + data-natural-width="0" data-natural-height="0" + size-comes-from-broken-image-icon> +<img src="non-existent.jpg" width="10" height="10" + title="non existent image with width/height attributes, no natural dimensions" + data-natural-width="0" data-natural-height="0" + data-width="10" data-height="10" + data-not-rendered-width="10" data-not-rendered-height="10"> + +<!-- First group of SVG images: no viewBox, with a missing (or edge-casey, i.e. + negative or percent-valued) value for the width and/or height attr on the root svg element in a SVG image. --> <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>" title="SVG image, no natural dimensions" data-natural-width="300" data-natural-height="150"> +<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>" + width="40" height="10" + data-width="40" data-height="10" + data-not-rendered-width="40" data-not-rendered-height="10" + title="SVG image with width/height attrs, no natural dimensions" + data-natural-width="300" data-natural-height="150"> +<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>" + width="40" + data-width="40" data-not-rendered-width="40" + title="SVG image with width attr, no natural dimensions" + data-natural-width="300" data-natural-height="150"> +<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>" + height="10" + data-height="10" data-not-rendered-height="10" + title="SVG image with height attr, no natural dimensions" + data-natural-width="300" data-natural-height="150"> <!-- Note: percent values can't be resolved when determining natural dimensions, so the exact percentage shouldn't matter. --> <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='400%' height='10%'></svg>" @@ -95,7 +133,7 @@ img { title="SVG image, with natural height being negative" data-natural-width="300" data-natural-height="0"> -<!-- NEXT PART OF TEST: Same as above, but now with a viewBox that grants a +<!-- Second group of SVG images: Same as above, but now with a viewBox that grants a 3:1 aspect-ratio; whenever we know one natural dimension, that should combine with the aspect ratio to produce the other natural dimension. @@ -137,7 +175,7 @@ img { title="SVG image, with natural height being negative, and aspect ratio from viewBox" data-natural-width="0" data-natural-height="0"> -<!-- THIRD PART OF TEST: Check a degenerate 0-sized viewBox for some of the +<!-- Third group of SVG images: Check a degenerate 0-sized viewBox for some of the cases; it should have no impact. --> <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 0 0'></svg>" title="SVG image, no natural dimensions, viewBox with 0 width/height" @@ -167,12 +205,15 @@ img { title="SVG image, with natural height, viewBox with 0 height" data-natural-width="300" data-natural-height="60"> -<!~- FINAL PART OF TEST: we have width/height/viewBox all specified on the - svg element. The width and height attrs should determine the natural - dimensions, with no impact from viewBox. --> -<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 600 200'></svg>" +<!~- Final group of SVG images: we have pixel-valued width/height on the root + svg element, and possibly viewBox as well. The width and height attrs should + determine the natural dimensions, with no impact from viewBox. --> +<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='40'></svg>" + title="SVG image, with natural width and height" + data-natural-width="60" data-natural-height="40"> +<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='40' viewBox='0 0 600 200'></svg>" title="SVG image, with natural width and height, and aspect ratio from viewBox" - data-natural-width="60" data-natural-height="60"> + data-natural-width="60" data-natural-height="40"> <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='0' height='0' viewBox='0 0 600 200'></svg>" title="SVG image, with natural width and height of 0, and aspect ratio from viewBox" data-natural-width="0" data-natural-height="0"> @@ -191,33 +232,144 @@ img { the window onload event: --> <script> setup({explicit_done:true}); + +// Utility function to generate a clone of imgTemplates using "srcset" and a +// given density value, with expectations adjusted per the density: +function cloneTemplateWithDensity(density) { + if (typeof(density) !== "number" || density <= 0) { + // If we get here, there's a bug in the test itself; throw an exception: + throw new Error("test error: param should be a positive number"); + } + let clone = imgTemplates.content.cloneNode("true"); + + for (let img of clone.children) { + // Swap out "src" for "srcset": + // The srcset attribute uses a space-separated list of tokens, + // so we need to encode any spaces that are in the URI itself + // before we put it in srcset: + let srcVal = img.getAttribute("src").replaceAll(" ", "%20"); + img.removeAttribute("src"); + img.setAttribute("srcSet", `${srcVal} ${density}x`); + + // Mention the density in the 'title' to keep the title values unique: + img.setAttribute("title", + `${img.getAttribute("title")} (with srcset/${density}x)`); + + const isUsingConcreteObjectWidth = (img.dataset.naturalWidth == "300"); + const isUsingConcreteObjectHeight = (img.dataset.naturalHeight == "150"); + + // Scale our 'data-natural-{width,height}' expectations by the density. + // But also: + // * Preserve the original 'data-natural-{width,height}' as the + // 'data-{width,height}' expectation if it's just the concrete object size + // (which doesn't actually get scaled by the density in practice when + // the image actually renders). + // * Preserve the original 'data-natural-{width,height}' as the + // 'data-not-rendered-{width,height}' expectation (if we don't already have + // one) since browsers don't do density-correction on .width and .height when + // the image is not being rendered, as discussed in + // https://github.com/whatwg/html/issues/11287#issuecomment-2923467541 + for (let name in img.dataset) { + if (name.startsWith("natural")) { + let origExpectation = img.dataset[name]; + + // Scale our img.natural{Width,Height} expectation: + img.dataset[name] = origExpectation / density; + + let isWidthAxis = (name == "naturalWidth"); + let nameWithoutNatural = (isWidthAxis ? "width" : "height"); + + let isConcreteObjectSize = + (isWidthAxis ? isUsingConcreteObjectWidth : isUsingConcreteObjectHeight); + if (isConcreteObjectSize && !(nameWithoutNatural in img.dataset)) { + img.dataset[nameWithoutNatural] = origExpectation; + } + + // Construct a string for "data-not-rendered-{width,height}" for + // whichever axis we're currently handling, and stash the + // origExpectation in there if we don't already have some expectation + // set there: + let notRenderedName = name.replace("natural", "notRendered"); + if (!(notRenderedName in img.dataset)) { + img.dataset[notRenderedName] = origExpectation; + } + } + } + } + return clone; +} + // Clone and append a copy of the contents of imgTemplates, for testing: let clone = imgTemplates.content.cloneNode("true"); containingBlock.appendChild(clone); +// Append additional clones, modified to use srcset with specified density. +// Note: +// * '1' is the trivial case; we're just testing that for completeness, +// to be sure there aren't any unexpected differences between +// <img src="..."> and <img srcset="... 1x">). +// * It's best for whatever density we test here to be something that evenly +// divides all of the image sizes in this test (so 1 and 2 are easy choices). +containingBlock.appendChild(cloneTemplateWithDensity(1)); +containingBlock.appendChild(cloneTemplateWithDensity(2)); + // After all the img elements have loaded (indicated by the window load event), // we run the various tests: onload = function() { Array.from(document.images).forEach(img => { + const expectedNaturalWidth = parseFloat(img.dataset.naturalWidth); + const expectedNaturalHeight = parseFloat(img.dataset.naturalHeight); + test(function() { // We expect naturalWidth to match the provided data-natural-width // (and similar for 'height'). - const expectedNaturalWidth = parseFloat(img.dataset.naturalWidth); - const expectedNaturalHeight = parseFloat(img.dataset.naturalHeight); assert_equals(img.naturalWidth, expectedNaturalWidth, 'naturalWidth'); assert_equals(img.naturalHeight, expectedNaturalHeight, 'naturalHeight'); - // If 'data-width' is provided, then we expect img.width to match it. - // Otherwise we expect img.width to match the 'data-natural-width'. - // (And similar for 'height'.) - const expectedWidth = 'width' in img.dataset ? - parseFloat(img.dataset.width) : expectedNaturalWidth; - const expectedHeight = 'height' in img.dataset ? - parseFloat(img.dataset.height) : expectedNaturalHeight; - assert_equals(img.width, expectedWidth, 'width'); - assert_equals(img.height, expectedHeight, 'height'); + let shouldCheckWidthAndHeight = + !img.hasAttribute("size-comes-from-broken-image-icon"); + if (shouldCheckWidthAndHeight) { + // If 'data-width' is provided, then we expect img.width to match it. + // Otherwise we expect img.width to match the 'data-natural-width'. + // (And similar for 'height'.) + const expectedWidth = 'width' in img.dataset ? + parseFloat(img.dataset.width) : expectedNaturalWidth; + const expectedHeight = 'height' in img.dataset ? + parseFloat(img.dataset.height) : expectedNaturalHeight; + assert_equals(img.width, expectedWidth, 'width'); + assert_equals(img.height, expectedHeight, 'height'); + } }, `${img.title}`); + + test(function() { + // Now test what we get when the img is not rendered. + // * naturalWidth and naturalHeight shouldn't change. + // * width and height should generally match naturalWidth and + // naturalHeight. (Exceptions are indicated via the + // 'data-not-rendered-{width/height} attributes). + this.add_cleanup(function() { + img.style.display = ""; + }); + + img.style.display = "none"; + img.getBoundingClientRect(); // Flush layout. + + assert_equals(img.naturalWidth, expectedNaturalWidth, + 'naturalWidth when not rendered'); + assert_equals(img.naturalHeight, expectedNaturalHeight, + 'naturalHeight when not rendered'); + + const expectedNotRenderedWidth = 'notRenderedWidth' in img.dataset ? + parseFloat(img.dataset.notRenderedWidth) : expectedNaturalWidth; + const expectedNotRenderedHeight = 'notRenderedHeight' in img.dataset ? + parseFloat(img.dataset.notRenderedHeight) : expectedNaturalHeight; + + assert_equals(img.width, expectedNotRenderedWidth, + 'width when not rendered'); + assert_equals(img.height, expectedNotRenderedHeight, + 'height when not rendered'); + }, `${img.title} (when not rendered)`); }); done(); }; diff --git a/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors-ref.html b/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors-ref.html new file mode 100644 index 00000000000..8e75a4e21e8 --- /dev/null +++ b/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors-ref.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html class=reftest-wait> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/resources/testdriver-actions.js"></script> + +<style> +option:not(:checked) { + background-color: green; + color: blue; +} +</style> + +<select multiple size=4 autofocus> + <option>option</option> + <option id=target>focused and checked</option> +</select> + +<script> +const target = document.getElementById('target'); +(async () => { + await (new test_driver.Actions() + .pointerMove(0, 0, {origin: target}) + .pointerDown() + .pointerUp()) + .send(); + document.documentElement.classList.remove('reftest-wait'); +})(); +</script> diff --git a/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors.html b/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors.html new file mode 100644 index 00000000000..c05d595c30c --- /dev/null +++ b/tests/wpt/tests/html/semantics/forms/the-select-element/list-box-important-colors.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html class=reftest-wait> +<link rel=author href="mailto:jarhar@chromium.org"> +<link rel=help href="https://issues.chromium.org/issues/415953695"> +<link rel=match href="list-box-important-colors-ref.html"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/resources/testdriver-actions.js"></script> + +<style> +option { + background-color: green; + color: blue; +} +</style> + +<select multiple size=4 autofocus> + <option>option</option> + <option id=target>focused and checked</option> +</select> + +<script> +const target = document.getElementById('target'); +(async () => { + await (new test_driver.Actions() + .pointerMove(0, 0, {origin: target}) + .pointerDown() + .pointerUp()) + .send(); + document.documentElement.classList.remove('reftest-wait'); +})(); +</script> diff --git a/tests/wpt/tests/html/semantics/interactive-elements/the-details-element/details-toggle-source.tentative.html b/tests/wpt/tests/html/semantics/interactive-elements/the-details-element/details-toggle-source.html index 1a571f54414..1a571f54414 100644 --- a/tests/wpt/tests/html/semantics/interactive-elements/the-details-element/details-toggle-source.tentative.html +++ b/tests/wpt/tests/html/semantics/interactive-elements/the-details-element/details-toggle-source.html diff --git a/tests/wpt/tests/html/semantics/interactive-elements/the-dialog-element/dialog-toggle-source.tentative.html b/tests/wpt/tests/html/semantics/interactive-elements/the-dialog-element/dialog-toggle-source.html index 7e6fe25dabf..130d76451da 100644 --- a/tests/wpt/tests/html/semantics/interactive-elements/the-dialog-element/dialog-toggle-source.tentative.html +++ b/tests/wpt/tests/html/semantics/interactive-elements/the-dialog-element/dialog-toggle-source.html @@ -9,14 +9,18 @@ <script src="../../popovers/resources/toggle-event-source-test.js"></script> <button id=showmodalbutton commandfor=dialog command=show-modal>show modal</button> -<dialog id=dialog> +<button id=lightdismiss>light dismiss</button> +<dialog id=dialog closedby=any> dialog <button id=closebutton commandfor=dialog command=close>close</button> + <button id=requestclosebutton commandfor=dialog command=request-close>request close</button> </dialog> <script> const showmodalbutton = document.getElementById('showmodalbutton'); const dialog = document.getElementById('dialog'); +const requestclosebutton = document.getElementById('requestclosebutton'); +const lightdismiss = document.getElementById('lightdismiss'); createToggleEventSourceTest({ description: 'ToggleEvent.source on <dialog> elements: dialog.showModal().', @@ -53,4 +57,34 @@ createToggleEventSourceTest({ openSource: showmodalbutton, closeSource: null }); + +createToggleEventSourceTest({ + description: 'ToggleEvent.source on <dialog> elements: open with showModal, close with request-close button.', + target: dialog, + openFunc: async () => dialog.showModal(), + closeFunc: async () => requestclosebutton.click(), + openSource: null, + closeSource: requestclosebutton +}); + +createToggleEventSourceTest({ + description: 'ToggleEvent.source on <dialog> elements: open with button, close with light dismiss.', + target: dialog, + openFunc: async () => { + await test_driver.click(showmodalbutton); + }, + closeFunc: async () => { + dialog.addEventListener('cancel', event => event.preventDefault(), {once: true}); + requestclosebutton.click(); + assert_true(dialog.matches(':open'), + 'cancel preventDefault should have prevented dialog from closing.'); + await (new test_driver.Actions() + .pointerMove(0, 0, {origin: lightdismiss}) + .pointerDown() + .pointerUp()) + .send(); + }, + openSource: showmodalbutton, + closeSource: null +}); </script> diff --git a/tests/wpt/tests/html/semantics/permission-element/bounded-css-properties.tentative.html b/tests/wpt/tests/html/semantics/permission-element/bounded-css-properties.tentative.html index 9678286179a..1455ba98bb3 100644 --- a/tests/wpt/tests/html/semantics/permission-element/bounded-css-properties.tentative.html +++ b/tests/wpt/tests/html/semantics/permission-element/bounded-css-properties.tentative.html @@ -17,11 +17,13 @@ word-spacing: 1em; font-size: 100px; letter-spacing: 21px; + box-shadow: 5px 5px inset; } #id-under-bounds { word-spacing: -1px; font-size: 100px; letter-spacing: -6px; + box-shadow: rgb(255, 0, 0) 5px 4px 3px 2px, 5px 5px inset; } #id-within-bounds { font-weight: 300; @@ -29,6 +31,7 @@ word-spacing: 0.4em; font-size: 100px; letter-spacing: 15px; + box-shadow: rgb(255, 0, 0) 5px 4px 3px 2px; } </style> @@ -44,10 +47,12 @@ assert_equals(getComputedStyle(el).fontStyle, "normal", "font-style"); assert_equals(getComputedStyle(el).wordSpacing, "50px", "word-spacing"); assert_equals(getComputedStyle(el).letterSpacing, "20px", "letter-spacing"); + assert_equals(getComputedStyle(el).boxShadow, "none", "box-shadow"); el = document.getElementById("id-under-bounds"); assert_equals(getComputedStyle(el).wordSpacing, "0px", "word-spacing, negative"); assert_equals(getComputedStyle(el).letterSpacing, "-5px", "letter-spacing, negative"); + assert_equals(getComputedStyle(el).boxShadow, "none", "box-shadow, multiple"); }, "Properties with out-of-bounds values should be corrected"); test(function(){ @@ -56,6 +61,7 @@ assert_equals(getComputedStyle(el).fontStyle, "italic", "font-style"); assert_equals(getComputedStyle(el).wordSpacing, "40px", "word-spacing"); assert_equals(getComputedStyle(el).letterSpacing, "15px", "letter-spacing"); + assert_equals(getComputedStyle(el).boxShadow, "rgb(255, 0, 0) 5px 4px 3px 2px", "box-shadow"); el.style.letterSpacing = "-4px"; assert_equals(getComputedStyle(el).letterSpacing, "-4px", "letter-spacing, negative"); diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-fill-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-fill-reftest.html new file mode 100644 index 00000000000..130849e79ba --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-fill-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the fill color is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + fill: red; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-height-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-height-reftest.html new file mode 100644 index 00000000000..9f52fd75479 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-height-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the height is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + height: 20px; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-margin-inline-end-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-margin-inline-end-reftest.html new file mode 100644 index 00000000000..b4edffbf00b --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-margin-inline-end-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the margin-inline-end is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + margin-inline-end: 50px; + } +</style> +<permission id="geolocation" type="geolocation"/> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest-ref.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest-ref.html new file mode 100644 index 00000000000..abda1adc1d8 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest-ref.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title> + A standard permission element of type location, without 50px height. +</title> + +<style> + ::permission-icon { + height: 50px; + } +</style> + +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest.html new file mode 100644 index 00000000000..45abc0ffd47 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-max-height-reftest.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>The icon of the element should be restricted to 50px due to the max-height property.</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="match" href="icon-css-property-max-height-reftest-ref.html"> +<style> + ::permission-icon { + height: 60px; + max-height: 50px; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-min-height-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-min-height-reftest.html new file mode 100644 index 00000000000..d1fe8d0724c --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-min-height-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the min-height is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + min-height: 50px; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-reftest.html new file mode 100644 index 00000000000..9d0ff75c3d8 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the stroke is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + stroke: red; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest-ref.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest-ref.html new file mode 100644 index 00000000000..5ed8af57313 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest-ref.html @@ -0,0 +1,12 @@ +<!doctype html> +<title> + A standard permission element of type location, with a red stroke with the + default stroke-width of 1px. +</title> + +<style> + ::permission-icon { + stroke: red; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest.html new file mode 100644 index 00000000000..a268e3c5fba --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-css-property-stroke-width-reftest.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>The icon of the element should change if the stroke-width is changed</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="icon-css-property-stroke-width-reftest-ref.html"> +<style> + ::permission-icon { + stroke-width: 2px; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-different-for-precise-location-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-different-for-precise-location-reftest.html new file mode 100644 index 00000000000..bf58fdf93e5 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-different-for-precise-location-reftest.html @@ -0,0 +1,6 @@ +<!doctype html> +<title>The precise and non-precise location icons should be different.</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="mismatch" href="standard-location-permission-element-ref.html"> +<permission id="geolocation" type="geolocation" preciselocation></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-hidden-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-hidden-reftest.html index 79055da1bad..a5b5bb61d2b 100644 --- a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-hidden-reftest.html +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-hidden-reftest.html @@ -8,4 +8,4 @@ display: none; } </style> -<permission id="geolocation" type="geolocation"/> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-restricted-css-no-effect-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-restricted-css-no-effect-reftest.html new file mode 100644 index 00000000000..5c0ea13fde7 --- /dev/null +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-restricted-css-no-effect-reftest.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>The icon of the permission element should not change when any of the restricted CSS properties are changed.</title> +<!-- TODO: Update the link to the permission icon spec --> +<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> +<link rel="match" href="standard-location-permission-element-ref.html"> +<style> + ::permission-icon { + margin-inline-start: 100px; + float: inline-end; + padding: 50px; + opacity: 0.5; + stroke-opacity: 0.5; + fill-rule: evenodd; + } +</style> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-unique-per-type-reftest.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-unique-per-type-reftest.html index d51b1c4d398..162a785852c 100644 --- a/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-unique-per-type-reftest.html +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/icon-unique-per-type-reftest.html @@ -3,4 +3,4 @@ <!-- TODO: Update the link to the permission icon spec --> <link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md"> <link rel="mismatch" href="standard-location-permission-element-ref.html"> -<permission id="camera" type="camera"/> +<permission id="camera" type="camera"></permission> diff --git a/tests/wpt/tests/html/semantics/permission-element/permission-icon/standard-location-permission-element-ref.html b/tests/wpt/tests/html/semantics/permission-element/permission-icon/standard-location-permission-element-ref.html index 15ffe751c51..d9f55b345f7 100644 --- a/tests/wpt/tests/html/semantics/permission-element/permission-icon/standard-location-permission-element-ref.html +++ b/tests/wpt/tests/html/semantics/permission-element/permission-icon/standard-location-permission-element-ref.html @@ -1,4 +1,4 @@ <!DOCTYPE html> <meta charset="utf-8"> <title>A standard permission element of type location, without any non-default styling</title> -<permission id="geolocation" type="geolocation"/> +<permission id="geolocation" type="geolocation"></permission> diff --git a/tests/wpt/tests/html/semantics/popovers/popover-toggle-source.tentative.html b/tests/wpt/tests/html/semantics/popovers/popover-toggle-source.html index 00ced8f7070..00ced8f7070 100644 --- a/tests/wpt/tests/html/semantics/popovers/popover-toggle-source.tentative.html +++ b/tests/wpt/tests/html/semantics/popovers/popover-toggle-source.html diff --git a/tests/wpt/tests/html/semantics/the-button-element/interest-target/interesttarget-invoker-descendants.tentative.html b/tests/wpt/tests/html/semantics/the-button-element/interest-target/interesttarget-invoker-descendants.tentative.html new file mode 100644 index 00000000000..d976c0eb011 --- /dev/null +++ b/tests/wpt/tests/html/semantics/the-button-element/interest-target/interesttarget-invoker-descendants.tentative.html @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<link rel="author" href="mailto:masonf@chromium.org"> +<link rel="help" href="https://open-ui.org/components/interest-invokers.explainer/" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="resources/invoker-utils.js"></script> + +<button id=invoker interesttarget=target> + Button content + <span id=inner tabindex=0>Inner content</span> +</button> +<div id=target>Target</div> +<button id=otherbutton>Other button</button> +<style> + [interesttarget] { interest-target-delay: 0s; } +</style> + +<script> +const invoker = document.getElementById('invoker'); +const innerSpan = document.getElementById('inner'); +const target = document.getElementById('target'); +const otherbutton = document.getElementById('otherbutton'); + +promise_test(async function (t) { + t.add_cleanup(() => otherbutton.focus()); + const signal = t.get_signal(); + let interestCount = 0; + let loseInterestCount = 0; + target.addEventListener('interest',() => (++interestCount),{signal}); + target.addEventListener('loseinterest',() => (++loseInterestCount),{signal}); + await focusOn(invoker); + assert_true(invoker.matches(':has-interest'),'focusing invoker should show interest'); + assert_equals(interestCount,1,'One interest event'); + interestCount = 0; + assert_equals(loseInterestCount,0,'No loseinterest events'); + await focusOn(innerSpan); + assert_true(invoker.matches(':has-interest'),'focusing inner span should keep interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,0,'No loseinterest events'); + await focusOn(invoker); + assert_true(invoker.matches(':has-interest'),'focusing back to outer button should keep interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,0,'No loseinterest events'); + await focusOn(otherbutton); + assert_false(invoker.matches(':has-interest'),'focusing outside should lose interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,1,'Finally got loseinterest event'); +},'Moving focus within invoker works correctly'); + +promise_test(async function (t) { + t.add_cleanup(() => otherbutton.focus()); + const signal = t.get_signal(); + let interestCount = 0; + let loseInterestCount = 0; + target.addEventListener('interest',() => (++interestCount),{signal}); + target.addEventListener('loseinterest',() => (++loseInterestCount),{signal}); + await hoverOver(invoker); + assert_true(invoker.matches(':has-interest'),'hovering invoker should show interest'); + assert_equals(interestCount,1,'One interest event'); + interestCount = 0; + assert_equals(loseInterestCount,0,'No loseinterest events'); + await hoverOver(innerSpan); + assert_true(invoker.matches(':has-interest'),'hovering inner span should keep interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,0,'No loseinterest events'); + await hoverOver(invoker); + assert_true(invoker.matches(':has-interest'),'hovering back to outer button should keep interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,0,'No loseinterest events'); + await hoverOver(otherbutton); + assert_false(invoker.matches(':has-interest'),'hovering outside should lose interest'); + assert_equals(interestCount,0,'No extra interest events'); + assert_equals(loseInterestCount,1,'Finally got loseinterest event'); +},'Moving hover within invoker works correctly'); +</script> diff --git a/tests/wpt/tests/images/pattern.webm b/tests/wpt/tests/images/pattern.webm Binary files differindex 7cd3d311557..8b7ff388b88 100644 --- a/tests/wpt/tests/images/pattern.webm +++ b/tests/wpt/tests/images/pattern.webm diff --git a/tests/wpt/tests/interfaces/crash-reporting.idl b/tests/wpt/tests/interfaces/crash-reporting.idl index 6eaee138a82..ba21afcf397 100644 --- a/tests/wpt/tests/interfaces/crash-reporting.idl +++ b/tests/wpt/tests/interfaces/crash-reporting.idl @@ -8,6 +8,6 @@ interface CrashReportBody : ReportBody { [Default] object toJSON(); readonly attribute DOMString? reason; readonly attribute DOMString? stack; - readonly attribute DOMString? is_top_level; + readonly attribute boolean? is_top_level; readonly attribute DocumentVisibilityState? page_visibility; }; diff --git a/tests/wpt/tests/interfaces/cssom-view.idl b/tests/wpt/tests/interfaces/cssom-view.idl index 88abb078485..160c27ca050 100644 --- a/tests/wpt/tests/interfaces/cssom-view.idl +++ b/tests/wpt/tests/interfaces/cssom-view.idl @@ -141,6 +141,7 @@ partial interface Element { }; partial interface HTMLElement { + readonly attribute Element? scrollParent; readonly attribute Element? offsetParent; readonly attribute long offsetTop; readonly attribute long offsetLeft; diff --git a/tests/wpt/tests/interfaces/element-timing.idl b/tests/wpt/tests/interfaces/element-timing.idl index ef73ca6c0f6..4f42823704a 100644 --- a/tests/wpt/tests/interfaces/element-timing.idl +++ b/tests/wpt/tests/interfaces/element-timing.idl @@ -13,7 +13,7 @@ interface PerformanceElementTiming : PerformanceEntry { readonly attribute unsigned long naturalHeight; readonly attribute DOMString id; readonly attribute Element? element; - readonly attribute DOMString url; + readonly attribute USVString url; [Default] object toJSON(); }; diff --git a/tests/wpt/tests/interfaces/html.idl b/tests/wpt/tests/interfaces/html.idl index 9c84e6a67ef..3a7dce9693e 100644 --- a/tests/wpt/tests/interfaces/html.idl +++ b/tests/wpt/tests/interfaces/html.idl @@ -1235,18 +1235,19 @@ interface HTMLDialogElement : HTMLElement { interface HTMLScriptElement : HTMLElement { [HTMLConstructor] constructor(); - [CEReactions] attribute USVString src; [CEReactions] attribute DOMString type; + [CEReactions] attribute USVString src; [CEReactions] attribute boolean noModule; [CEReactions] attribute boolean async; [CEReactions] attribute boolean defer; + [SameObject, PutForwards=value] readonly attribute DOMTokenList blocking; [CEReactions] attribute DOMString? crossOrigin; - [CEReactions] attribute DOMString text; - [CEReactions] attribute DOMString integrity; [CEReactions] attribute DOMString referrerPolicy; - [SameObject, PutForwards=value] readonly attribute DOMTokenList blocking; + [CEReactions] attribute DOMString integrity; [CEReactions] attribute DOMString fetchPriority; + [CEReactions] attribute DOMString text; + static boolean supports(DOMString type); // also has obsolete members @@ -1694,6 +1695,7 @@ interface ToggleEvent : Event { constructor(DOMString type, optional ToggleEventInit eventInitDict = {}); readonly attribute DOMString oldState; readonly attribute DOMString newState; + readonly attribute Element source; }; dictionary ToggleEventInit : EventInit { diff --git a/tests/wpt/tests/interfaces/privacy-preserving-attribution.idl b/tests/wpt/tests/interfaces/privacy-preserving-attribution.idl index 0ab5d0fc21e..02a35798204 100644 --- a/tests/wpt/tests/interfaces/privacy-preserving-attribution.idl +++ b/tests/wpt/tests/interfaces/privacy-preserving-attribution.idl @@ -30,9 +30,12 @@ dictionary PrivateAttributionImpressionOptions { unsigned long lifetimeDays = 30; }; +dictionary PrivateAttributionImpressionResult { +}; + [SecureContext, Exposed=Window] partial interface PrivateAttribution { - undefined saveImpression(PrivateAttributionImpressionOptions options); + Promise<PrivateAttributionImpressionResult> saveImpression(PrivateAttributionImpressionOptions options); }; dictionary PrivateAttributionConversionOptions { diff --git a/tests/wpt/tests/interfaces/resource-timing.idl b/tests/wpt/tests/interfaces/resource-timing.idl index 66f2841d744..499d27b6ee6 100644 --- a/tests/wpt/tests/interfaces/resource-timing.idl +++ b/tests/wpt/tests/interfaces/resource-timing.idl @@ -28,6 +28,7 @@ interface PerformanceResourceTiming : PerformanceEntry { readonly attribute unsigned short responseStatus; readonly attribute RenderBlockingStatusType renderBlockingStatus; readonly attribute DOMString contentType; + readonly attribute DOMString contentEncoding; [Default] object toJSON(); }; diff --git a/tests/wpt/tests/interfaces/scoped-custom-elements-registry.idl b/tests/wpt/tests/interfaces/scoped-custom-elements-registry.idl deleted file mode 100644 index 46ca2d6b9c4..00000000000 --- a/tests/wpt/tests/interfaces/scoped-custom-elements-registry.idl +++ /dev/null @@ -1,38 +0,0 @@ -[Exposed=Window] -partial interface CustomElementRegistry { - constructor(); - undefined initialize(Node root); -}; - -[Exposed=Window] -partial interface HTMLTemplateElement { - [CEReactions] attribute DOMString shadowRootCustomElementRegistry; -}; - -[Exposed=Window] -partial interface Document { - readonly attribute CustomElementRegistry? customElementRegistry; -}; - -[Exposed=Window] -partial interface Element { - readonly attribute CustomElementRegistry? customElementRegistry; -}; - -[Exposed=Window] -partial interface ShadowRoot { - readonly attribute CustomElementRegistry? customElementRegistry; -}; - -dictionary ImportNodeOptions { - CustomElementRegistry customElementRegistry; - boolean selfOnly = false; -}; - -partial dictionary ShadowRootInit { - CustomElementRegistry customElementRegistry; -}; - -partial dictionary ElementCreationOptions { - CustomElementRegistry customElementRegistry; -}; diff --git a/tests/wpt/tests/interfaces/screen-capture.idl b/tests/wpt/tests/interfaces/screen-capture.idl index db9282ce0a5..eb5685eee41 100644 --- a/tests/wpt/tests/interfaces/screen-capture.idl +++ b/tests/wpt/tests/interfaces/screen-capture.idl @@ -29,6 +29,12 @@ enum SystemAudioPreferenceEnum { "exclude" }; +enum WindowAudioPreferenceEnum { + "system", + "window", + "exclude" +}; + enum SurfaceSwitchingPreferenceEnum { "include", "exclude" @@ -45,6 +51,7 @@ dictionary DisplayMediaStreamOptions { CaptureController controller; SelfCapturePreferenceEnum selfBrowserSurface; SystemAudioPreferenceEnum systemAudio; + WindowAudioPreferenceEnum windowAudio; SurfaceSwitchingPreferenceEnum surfaceSwitching; MonitorTypeSurfacesEnum monitorTypeSurfaces; }; diff --git a/tests/wpt/tests/interfaces/secure-payment-confirmation.idl b/tests/wpt/tests/interfaces/secure-payment-confirmation.idl index 5b67ca62678..0a2207684ec 100644 --- a/tests/wpt/tests/interfaces/secure-payment-confirmation.idl +++ b/tests/wpt/tests/interfaces/secure-payment-confirmation.idl @@ -11,6 +11,7 @@ dictionary SecurePaymentConfirmationRequest { unsigned long timeout; USVString payeeName; USVString payeeOrigin; + sequence<PaymentEntityLogo> paymentEntitiesLogos; AuthenticationExtensionsClientInputs extensions; sequence<USVString> locale; boolean showOptOut; @@ -40,6 +41,7 @@ dictionary AuthenticationExtensionsPaymentInputs { USVString topOrigin; USVString payeeName; USVString payeeOrigin; + sequence<PaymentEntityLogo> paymentEntitiesLogos; PaymentCurrencyAmount total; PaymentCredentialInstrument instrument; }; @@ -53,6 +55,7 @@ dictionary CollectedClientAdditionalPaymentData { required USVString topOrigin; USVString payeeName; USVString payeeOrigin; + sequence<PaymentEntityLogo> paymentEntitiesLogos; required PaymentCurrencyAmount total; required PaymentCredentialInstrument instrument; }; @@ -62,3 +65,8 @@ dictionary PaymentCredentialInstrument { required USVString icon; boolean iconMustBeShown = true; }; + +dictionary PaymentEntityLogo { + required USVString url; + required USVString label; +}; diff --git a/tests/wpt/tests/interfaces/speech-api.idl b/tests/wpt/tests/interfaces/speech-api.idl index 94a416f262b..9620e60dc50 100644 --- a/tests/wpt/tests/interfaces/speech-api.idl +++ b/tests/wpt/tests/interfaces/speech-api.idl @@ -12,7 +12,7 @@ interface SpeechRecognition : EventTarget { attribute boolean continuous; attribute boolean interimResults; attribute unsigned long maxAlternatives; - attribute SpeechRecognitionMode mode; + attribute boolean processLocally; attribute SpeechRecognitionPhraseList phrases; // methods to drive the speech interaction @@ -20,8 +20,8 @@ interface SpeechRecognition : EventTarget { undefined start(MediaStreamTrack audioTrack); undefined stop(); undefined abort(); - static Promise<AvailabilityStatus> availableOnDevice(DOMString lang); - static Promise<boolean> installOnDevice(DOMString lang); + static Promise<AvailabilityStatus> available(SpeechRecognitionOptions options); + static Promise<boolean> install(SpeechRecognitionOptions options); // event methods attribute EventHandler onaudiostart; @@ -37,6 +37,11 @@ interface SpeechRecognition : EventTarget { attribute EventHandler onend; }; +dictionary SpeechRecognitionOptions { + required sequence<DOMString> langs; + boolean processLocally = false; +}; + enum SpeechRecognitionErrorCode { "no-speech", "aborted", @@ -48,12 +53,6 @@ enum SpeechRecognitionErrorCode { "phrases-not-supported" }; -enum SpeechRecognitionMode { - "ondevice-preferred", // On-device speech recognition if available, otherwise use Cloud speech recognition as a fallback. - "ondevice-only", // On-device speech recognition only. Returns an error if on-device speech recognition is not available. - "cloud-only", // Cloud speech recognition only. -}; - enum AvailabilityStatus { "unavailable", "downloadable", diff --git a/tests/wpt/tests/interfaces/wai-aria.idl b/tests/wpt/tests/interfaces/wai-aria.idl index deebc5626e2..3364bc9a769 100644 --- a/tests/wpt/tests/interfaces/wai-aria.idl +++ b/tests/wpt/tests/interfaces/wai-aria.idl @@ -57,4 +57,4 @@ interface mixin ARIAMixin { [CEReactions] attribute DOMString? ariaValueNow; [CEReactions] attribute DOMString? ariaValueText; }; -Element includes ARIAMixin; + Element includes ARIAMixin; diff --git a/tests/wpt/tests/interfaces/web-animations-2.idl b/tests/wpt/tests/interfaces/web-animations-2.idl index c4a0c2532d9..f18cdd4f458 100644 --- a/tests/wpt/tests/interfaces/web-animations-2.idl +++ b/tests/wpt/tests/interfaces/web-animations-2.idl @@ -118,7 +118,7 @@ dictionary AnimationPlaybackEventInit : EventInit { interface AnimationTrigger { constructor(optional AnimationTriggerOptions options = {}); attribute AnimationTimeline timeline; - attribute AnimationTriggerType type; + attribute AnimationTriggerBehavior behavior; attribute any rangeStart; attribute any rangeEnd; attribute any exitRangeStart; @@ -127,11 +127,11 @@ interface AnimationTrigger { dictionary AnimationTriggerOptions { AnimationTimeline? timeline; - AnimationTriggerType? type = "once"; + AnimationTriggerBehavior? behavior = "once"; (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) rangeStart = "normal"; (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) rangeEnd = "normal"; (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) exitRangeStart = "auto"; (TimelineRangeOffset or CSSNumericValue or CSSKeywordValue or DOMString) exitRangeEnd = "auto"; }; -enum AnimationTriggerType { "once", "repeat", "alternate", "state" }; +enum AnimationTriggerBehavior { "once", "repeat", "alternate", "state" }; diff --git a/tests/wpt/tests/interfaces/webgpu.idl b/tests/wpt/tests/interfaces/webgpu.idl index 4fec46a2557..1fc896c6b16 100644 --- a/tests/wpt/tests/interfaces/webgpu.idl +++ b/tests/wpt/tests/interfaces/webgpu.idl @@ -127,6 +127,7 @@ enum GPUFeatureName { "clip-distances", "dual-source-blending", "subgroups", + "texture-formats-tier1", }; [Exposed=(Window, Worker), SecureContext] @@ -295,6 +296,8 @@ enum GPUTextureFormat { "r8sint", // 16-bit formats + "r16unorm", + "r16snorm", "r16uint", "r16sint", "r16float", @@ -307,6 +310,8 @@ enum GPUTextureFormat { "r32uint", "r32sint", "r32float", + "rg16unorm", + "rg16snorm", "rg16uint", "rg16sint", "rg16float", @@ -327,6 +332,8 @@ enum GPUTextureFormat { "rg32uint", "rg32sint", "rg32float", + "rgba16unorm", + "rgba16snorm", "rgba16uint", "rgba16sint", "rgba16float", @@ -556,7 +563,11 @@ dictionary GPUBindGroupDescriptor required sequence<GPUBindGroupEntry> entries; }; -typedef (GPUSampler or GPUTextureView or GPUBufferBinding or GPUExternalTexture) GPUBindingResource; +typedef (GPUSampler or + GPUTextureView or + GPUBuffer or + GPUBufferBinding or + GPUExternalTexture) GPUBindingResource; dictionary GPUBindGroupEntry { required GPUIndex32 binding; @@ -990,7 +1001,7 @@ interface mixin GPUBindingCommandsMixin { optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []); undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup, - Uint32Array dynamicOffsetsData, + [AllowShared] Uint32Array dynamicOffsetsData, GPUSize64 dynamicOffsetsDataStart, GPUSize32 dynamicOffsetsDataLength); }; diff --git a/tests/wpt/tests/interfaces/writing-assistance-apis.idl b/tests/wpt/tests/interfaces/writing-assistance-apis.idl index 916daee754e..82acfdb48e2 100644 --- a/tests/wpt/tests/interfaces/writing-assistance-apis.idl +++ b/tests/wpt/tests/interfaces/writing-assistance-apis.idl @@ -56,7 +56,7 @@ dictionary SummarizerSummarizeOptions { DOMString context; }; -enum SummarizerType { "tl;dr", "teaser", "key-points", "headline" }; +enum SummarizerType { "tldr", "teaser", "key-points", "headline" }; enum SummarizerFormat { "plain-text", "markdown" }; enum SummarizerLength { "short", "medium", "long" }; diff --git a/tests/wpt/tests/lint.ignore b/tests/wpt/tests/lint.ignore index 60b0f65a6f4..cf83e458213 100644 --- a/tests/wpt/tests/lint.ignore +++ b/tests/wpt/tests/lint.ignore @@ -173,6 +173,7 @@ SET TIMEOUT: encrypted-media/polyfill/clearkey-polyfill.js SET TIMEOUT: encrypted-media/scripts/playback-temporary-events.js SET TIMEOUT: fedcm/support/fedcm-iframe.html SET TIMEOUT: fedcm/support/fedcm/disconnect-iframe.html +SET TIMEOUT: fedcm/support/login_delay.html SET TIMEOUT: fetch/fetch-later/resources/fetch-later-helper.js SET TIMEOUT: fetch/metadata/resources/helper.sub.js SET TIMEOUT: fetch/metadata/resources/message-opener.html @@ -423,6 +424,7 @@ SET TIMEOUT: speculation-rules/prerender/resources/media-play.html SET TIMEOUT: html/browsers/browsing-the-web/back-forward-cache/timers.html SET TIMEOUT: dom/abort/crashtests/timeout-close.html SET TIMEOUT: storage-access-api/storage-access-beyond-cookies.locks.sub.https.window.js +SET TIMEOUT: pointerevents/crashtests/longpress-crash.html # setTimeout use in reftests SET TIMEOUT: acid/acid3/test.html @@ -818,6 +820,7 @@ TESTDRIVER-IN-UNSUPPORTED-TYPE: payment-handler/change-shipping-address-manual.h TESTDRIVER-IN-UNSUPPORTED-TYPE: payment-handler/change-shipping-option-manual.https.html TESTDRIVER-IN-UNSUPPORTED-TYPE: payment-handler/payment-request-event-manual.https.html TESTDRIVER-IN-UNSUPPORTED-TYPE: payment-handler/supports-shipping-contact-delegation-manual.https.html +TESTDRIVER-IN-UNSUPPORTED-TYPE: speech-api/SpeechRecognition-phrases-manual.https.html # Tests automatically imported from the WebAssembly/spec repository that should be removed after getting fixed upstream. SET TIMEOUT: wasm/core/js/harness/testharness.js diff --git a/tests/wpt/tests/paint-timing/idlharness.window.js b/tests/wpt/tests/paint-timing/idlharness.window.js index 049f0f18f1b..9843a604b80 100644 --- a/tests/wpt/tests/paint-timing/idlharness.window.js +++ b/tests/wpt/tests/paint-timing/idlharness.window.js @@ -7,7 +7,7 @@ idl_test( ['paint-timing'], - ['performance-timeline'], + ['performance-timeline', 'hr-time'], (idl_array, t) => { idl_array.add_objects({ PerformancePaintTiming: ['paintTiming'], diff --git a/tests/wpt/tests/pointerevents/crashtests/longpress-crash.html b/tests/wpt/tests/pointerevents/crashtests/longpress-crash.html new file mode 100644 index 00000000000..0ace661d5a9 --- /dev/null +++ b/tests/wpt/tests/pointerevents/crashtests/longpress-crash.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<link rel="author" href="mailto:masonf@chromium.org"> +<link rel="help" href="https://crbug.com/421119389"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<html class=test-wait> + +<button>Button</button> + +<script> +async function longPress(element) { + const actions = new test_driver.Actions(); + await actions.addPointer("touchPointer", "touch") + .pointerMove(0, 0, {sourceName: "touchPointer",origin: element}) + .pointerDown({sourceName: "touchPointer",origin: element}) + .send(); + // This needs to be long enough to trigger long-press: + await new Promise(resolve => setTimeout(resolve,1000)); + await actions.pointerUp({sourceName: "touchPointer"}) + .send(); +} + +async function test() { + const el = document.querySelector('button'); + await longPress(el); + await longPress(el); + document.documentElement.classList.remove('test-wait'); +} +// This test should pass if nothing crashes. +test(); + +</script> diff --git a/tests/wpt/tests/pointerevents/pointerevent_click_during_parent_capture.html b/tests/wpt/tests/pointerevents/pointerevent_click_during_parent_capture.html index f25e61aade3..fd6de4d0899 100644 --- a/tests/wpt/tests/pointerevents/pointerevent_click_during_parent_capture.html +++ b/tests/wpt/tests/pointerevents/pointerevent_click_during_parent_capture.html @@ -240,6 +240,7 @@ addEventListener( .pointerMove(0, 0, { origin: target }) .pointerDown() .pointerUp() + .pause(100) // XXX Required for preventing intermittent failure of Firefox .send(); test(() => { diff --git a/tests/wpt/tests/resources/test/conftest.py b/tests/wpt/tests/resources/test/conftest.py index 1301e7a9f77..0b67ca76761 100644 --- a/tests/wpt/tests/resources/test/conftest.py +++ b/tests/wpt/tests/resources/test/conftest.py @@ -55,6 +55,7 @@ def pytest_configure(config): config.driver = webdriver.Session("localhost", 4444, capabilities=capabilities) + config.driver.start() config.add_cleanup(config.driver.end) # Although the name of the `_create_unverified_context` method suggests diff --git a/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-addAnimation.tentative.html b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-addAnimation.tentative.html new file mode 100644 index 00000000000..71fedebbcea --- /dev/null +++ b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-addAnimation.tentative.html @@ -0,0 +1,148 @@ + +<!DOCTYPE html> +<html> + <head> + <link rel="help" src="https://drafts.csswg.org/css-animations-2/#animation-trigger"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/web-animations/testcommon.js"></script> + <script src="/dom/events/scrolling/scroll_support.js"></script> + <script src="support/support.js"></script> + </head> + <body> + <style> + .subject, .target { + height: 50px; + width: 50px; + background-color: red; + } + .scroller { + overflow-y: scroll; + height: 500px; + width: 500px; + border: solid 1px; + position: relative; + } + #space { + width: 50px; + height: 600px; + } + </style> + <div id="wrapper"> + <div id="scroller" class="scroller"> + <div id="space"></div> + <div id="subject" class="subject"></div> + <div id="space"></div> + </div> + <div id="target" class="target"></div> + </div> + <script> + // The trigger and exit ranges are the same for this test. + const TRIGGER_START_PX = 150; + const TRIGGER_END_PX = 200; + const scroller = document.getElementById("scroller"); + const target = document.getElementById("target"); + const COVER_START_OFFSET = 100; + const rangeBoundaries = getRangeBoundariesForTest( + COVER_START_OFFSET + TRIGGER_START_PX, + COVER_START_OFFSET + TRIGGER_END_PX, + COVER_START_OFFSET + TRIGGER_START_PX, + COVER_START_OFFSET + TRIGGER_END_PX, + scroller); + const ANIMATION_DURATION_MS = 1; + const view_timeline = new ViewTimeline({ subject: subject }); + function setupAnimation() { + const animation = new Animation( + new KeyframeEffect( + target, + [ + { transform: "scaleX(1)", backgroundColor: "pink", left: "0px" }, + { transform: "scaleX(5)", backgroundColor: "pink", left: "10px" } + ], + { duration: ANIMATION_DURATION_MS, fill: "both" } + )); + return animation; + } + function setupAnimationTrigger(use_default_trigger=false) { + const trigger = use_default_trigger ? new AnimationTrigger() + : new AnimationTrigger({ + type: "alternate", + timeline: view_timeline, + rangeStart: `${TRIGGER_START_PX}px`, + rangeEnd: `${TRIGGER_END_PX}px` + }); + return trigger; + } + + promise_test(async (test) => { + const animation = setupAnimation(); + const trigger = setupAnimationTrigger(/*use_default_trigger=*/true); + + // As the default trigger is always in the tripped state, the animation + // should be played right away. + trigger.addAnimation(animation); + await animation.finished; + + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + "animation finish reflected in currentTime"); + assert_equals(animation.playState, "finished", + "animation finish reflected in playeState"); + }, "Animation attached to tripped (default) trigger plays."); + + promise_test(async (test) => { + const animation = setupAnimation(); + const trigger = setupAnimationTrigger(); + + assert_equals(animation.playState, "idle", "animation is idle"); + assert_equals(animation.currentTime, null, "currentTime is null"); + + assert_equals(scroller.scrollTop, 0, "scroller is not scrolled, i.e. " + + "not within the trigger range"); + + trigger.addAnimation(animation); + + await waitForAnimationFrames(2); + + assert_equals(animation.playState, "paused", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, 0, "currentTime is 0"); + + // Entering the trigger range should play the animation. + rangeBoundaries.enterTriggerRange(); + await animation.finished; + + assert_equals(animation.playState, "finished", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + "currentTime is 0"); + }, "Animation attached to untripped trigger is paused at the beginning."); + + promise_test(async (test) => { + await waitForScrollReset(test, scroller); + + assert_equals(scroller.scrollTop, 0, "scroller is not scrolled, i.e. " + + "not within the trigger range"); + + const animation = setupAnimation(); + const trigger = setupAnimationTrigger(); + + assert_equals(animation.playState, "idle", "animation is idle"); + assert_equals(animation.currentTime, null, "currentTime is null"); + + rangeBoundaries.enterTriggerRange(); + await waitForAnimationFrames(2); + + assert_equals(animation.playState, "idle", "animation is still idle"); + assert_equals(animation.currentTime, null, "currentTime is still null"); + + trigger.addAnimation(animation); + await animation.finished; + + assert_equals(animation.playState, "finished", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + `currentTime is ${ANIMATION_DURATION_MS}`); + }, "Animation attached to tripped trigger is played immediately."); + </script> + </body> +</html> diff --git a/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-animations.tentative.html b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-animations.tentative.html new file mode 100644 index 00000000000..6914cb09b89 --- /dev/null +++ b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-animations.tentative.html @@ -0,0 +1,132 @@ +<!DOCTYPE html> +<html> + <head> + <link rel="help" src="https://drafts.csswg.org/css-animations-2/#animation-trigger"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/web-animations/testcommon.js"></script> + <script src="/dom/events/scrolling/scroll_support.js"></script> + <script src="support/support.js"></script> + </head> + <body> + <style> + .subject, .target { + height: 50px; + width: 50px; + background-color: red; + } + .scroller { + overflow-y: scroll; + height: 500px; + width: 500px; + border: solid 1px; + position: relative; + } + #space { + width: 50px; + height: 600px; + } + </style> + <div id="wrapper"> + <div id="scroller" class="scroller"> + <div id="space"></div> + <div id="subject" class="subject"></div> + <div id="space"></div> + </div> + <div id="target1" class="target"></div> + <div id="target2" class="target"></div> + </div> + <script> + // The trigger and exit ranges are the same for this test. + const TRIGGER_START_PX = 150; + const TRIGGER_END_PX = 200; + const scroller = document.getElementById("scroller"); + const subject = document.getElementById("subject"); + const target = document.getElementById("target"); + + const ANIMATION_DURATION_MS = 1; + + const COVER_START_OFFSET = 100; + const rangeBoundaries = getRangeBoundariesForTest( + COVER_START_OFFSET + TRIGGER_START_PX, + COVER_START_OFFSET + TRIGGER_END_PX, + COVER_START_OFFSET + TRIGGER_START_PX, + COVER_START_OFFSET + TRIGGER_END_PX, + scroller); + + function setupAnimation(target) { + const animation = new Animation( + new KeyframeEffect( + target, + [ + { transform: "scaleX(1)", backgroundColor: "pink", left: "0px" }, + { transform: "scaleX(5)", backgroundColor: "pink", left: "10px" } + ], + { duration: ANIMATION_DURATION_MS, fill: "both" } + )); + return animation; + } + + const view_timeline = new ViewTimeline({ subject: subject }); + function setupAnimationTrigger() { + const trigger = new AnimationTrigger({ + type: "alternate", + timeline: view_timeline, + rangeStart: `${TRIGGER_START_PX}px`, + rangeEnd: `${TRIGGER_END_PX}px` + }); + return trigger; + } + + promise_test(async (test) => { + const animation1 = setupAnimation(target1); + const animation2 = setupAnimation(target2); + const trigger = setupAnimationTrigger(); + + assert_equals(animation1.playState, "idle", "animation1 is idle"); + assert_equals(animation1.currentTime, null, + "animation1's currentTime is null"); + assert_equals(animation2.playState, "idle", "animation is idle"); + assert_equals(animation2.currentTime, null, + "animations2's currentTime is null"); + assert_equals(scroller.scrollTop, 0, + "scroller is not scrolled, i.e. not within the trigger range"); + + trigger.addAnimation(animation1); + + assert_equals(animation1.playState, "paused", + "animation1 is paused, awaiting trigger event"); + assert_times_equal(animation1.currentTime, 0, + "animation1's currentTime is 0"); + assert_equals(animation2.playState, "idle", "animation2 is idle"); + assert_equals(animation2.currentTime, null, + "animations2's currentTime is null"); + + trigger.addAnimation(animation2); + + assert_equals(animation1.playState, "paused", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation1.currentTime, 0, + "animation1's currentTime is 0"); + assert_equals(animation2.playState, "paused", + "animation2 is paused, awaiting trigger event"); + assert_times_equal(animation2.currentTime, 0, + "animation2's currentTime is 0"); + + rangeBoundaries.enterTriggerRange(); + + await animation1.finished; + await animation2.finished; + + assert_equals(animation1.playState, "finished", + "animation1 is paused, awaiting trigger event"); + assert_times_equal(animation1.currentTime, ANIMATION_DURATION_MS, + `animation1's currentTime is ${ANIMATION_DURATION_MS}`); + assert_equals(animation2.playState, "finished", + "animation2 is paused, awaiting trigger event"); + assert_times_equal(animation2.currentTime, ANIMATION_DURATION_MS, + `animation2's currentTime is ${ANIMATION_DURATION_MS}`); + }, "Single trigger controls multiple animations"); + </script> + </body> +</html>
\ No newline at end of file diff --git a/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-triggers.tentative.html b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-triggers.tentative.html new file mode 100644 index 00000000000..5fccdf27550 --- /dev/null +++ b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger-multiple-triggers.tentative.html @@ -0,0 +1,175 @@ + +<!DOCTYPE html> +<html> + <head> + <link rel="help" src="https://drafts.csswg.org/css-animations-2/#animation-trigger"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/web-animations/testcommon.js"></script> + <script src="/dom/events/scrolling/scroll_support.js"></script> + <script src="support/support.js"></script> + </head> + <body> + <style> + .subject, .target { + height: 50px; + width: 50px; + background-color: red; + } + .scroller { + overflow-y: scroll; + height: 500px; + width: 500px; + border: solid 1px; + position: relative; + } + #space { + width: 50px; + height: 600px; + } + </style> + <div id="wrapper"> + <div id="scroller" class="scroller"> + <div id="space"></div> + <div id="subject1" class="subject"></div> + <div id="space"></div> + <div id="subject2" class="subject"></div> + <div id="space"></div> + </div> + <div id="target" class="target"></div> + </div> + <script> + // The trigger and exit ranges are the same for this test. + const TRIGGER_START_PX = 150; + const TRIGGER_END_PX = 200; + const scroller = document.getElementById("scroller"); + const subject1 = document.getElementById("subject1"); + const subject2 = document.getElementById("subject2"); + const target = document.getElementById("target"); + + function getRangeBoundariesForSubject(subject, scroller) { + const cover_start_offset = subject.offsetTop - scroller.clientHeight; + return getRangeBoundariesForTest( + cover_start_offset + TRIGGER_START_PX, + cover_start_offset + TRIGGER_END_PX, + cover_start_offset + TRIGGER_START_PX, + cover_start_offset + TRIGGER_END_PX, + scroller); + } + const rangeBoundaries1 = getRangeBoundariesForSubject(subject1, + scroller); + const rangeBoundaries2 = getRangeBoundariesForSubject(subject2, + scroller); + + const ANIMATION_DURATION_MS = 1; + const view_timeline1 = new ViewTimeline({ subject: subject1 }); + const view_timeline2 = new ViewTimeline({ subject: subject2 }); + function setupAnimation() { + const animation = new Animation( + new KeyframeEffect( + target, + [ + { transform: "scaleX(1)", backgroundColor: "pink" }, + { transform: "scaleX(5)", backgroundColor: "pink" } + ], + { duration: ANIMATION_DURATION_MS, fill: "both" } + )); + return animation; + } + function setupAnimationTrigger(view_timeline) { + const trigger = new AnimationTrigger({ + type: "repeat", + timeline: view_timeline, + rangeStart: `${TRIGGER_START_PX}px`, + rangeEnd: `${TRIGGER_END_PX}px` + }); + return trigger; + } + + promise_test(async (test) => { + const animation = setupAnimation(); + const trigger1 = setupAnimationTrigger(view_timeline1); + const trigger2 = setupAnimationTrigger(view_timeline2); + + // Test preconditions. + assert_equals(animation.playState, "idle", "animation is idle"); + assert_equals(animation.currentTime, null, "currentTime is null"); + assert_equals(scroller.scrollTop, 0, "scroller is not scrolled, i.e. " + + "not within the trigger range"); + + trigger1.addAnimation(animation); + trigger2.addAnimation(animation); + + // Test preconditions. + assert_equals(animation.playState, "paused", "animation is idle"); + assert_equals(animation.currentTime, 0, "currentTime is null"); + + await rangeBoundaries1.enterTriggerRange(); + await animation.finished; + assert_equals(animation.playState, "finished", + "animation is played by trigger1"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + `currentTime is ${ANIMATION_DURATION_MS}`); + + await rangeBoundaries1.exitExitRangeBelow(); + await waitForNextFrame(); + assert_equals(animation.playState, "paused", + "animation should be reset by trigger1"); + assert_times_equal(animation.currentTime, 0, "currentTime is 0"); + + // animation should be played by trigger2. + rangeBoundaries2.enterTriggerRange(); + await animation.finished; + assert_equals(animation.playState, "finished", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + `currentTime is ${ANIMATION_DURATION_MS}`); + + // animation should be reversed by trigger2. + rangeBoundaries2.exitExitRangeBelow(); + await waitForNextFrame(); + assert_equals(animation.playState, "paused", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, 0, `currentTime is 0`); + }, "Triggers on same animation; no conflict."); + + promise_test(async (test) => { + await waitForScrollReset(test, scroller); + const animation = setupAnimation(); + const trigger1 = setupAnimationTrigger(view_timeline1); + const trigger2 = setupAnimationTrigger(view_timeline2); + + // Test preconditions. + assert_equals(animation.playState, "idle", "animation is idle"); + assert_equals(animation.currentTime, null, "currentTime is null"); + assert_equals(scroller.scrollTop, 0, "scroller is not scrolled, i.e. " + + "not within the trigger range"); + + trigger1.addAnimation(animation); + trigger2.addAnimation(animation); + + // Test preconditions. + assert_equals(animation.playState, "paused", "animation is paused"); + assert_equals(animation.currentTime, 0, "currentTime is null"); + + await rangeBoundaries1.enterTriggerRange(); + await animation.finished; + assert_equals(animation.playState, "finished", + "animation is played by trigger1"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + `currentTime is ${ANIMATION_DURATION_MS}`); + + // Entering trigger2's trigger range exits trigger1's exit range. + // So trigger1 wants to do a reset and trigger2 wants to play the + // animation. As trigger2 was the most recently created, it wins and the + // animation is played. + rangeBoundaries2.enterTriggerRange(); + await animation.finished; + assert_equals(animation.playState, "finished", + "animation is paused, awaiting trigger event"); + assert_times_equal(animation.currentTime, ANIMATION_DURATION_MS, + `currentTime is ${ANIMATION_DURATION_MS}`); + }, "Triggers on same animation; conflict."); + </script> + </body> +</html> diff --git a/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger.html b/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger.html deleted file mode 100644 index 7506fb05829..00000000000 --- a/tests/wpt/tests/scroll-animations/animation-trigger/animation-trigger.html +++ /dev/null @@ -1,169 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <link rel="help" src="https://drafts.csswg.org/css-animations-2/#animation-trigger"> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <script src="/web-animations/testcommon.js"></script> - <script src="/css/css-typed-om/resources/testhelper.js"></script> - </head> - <body> - <style> - @keyframes myAnim { - from { transform: scaleX(1); } - to { transform: scaleX(5); } - } - .subject, .target { - height: 50px; - width: 50px; - background-color: red; - } - .subject { - view-timeline: --viewtimeline; - } - .target { - animation: myAnim linear 0.5s forwards; - } - #scroll_target { - animation-trigger: repeat scroll(inline) 150px 200px 100px 250px; - } - #view_target { - animation-trigger: state view(x) contain 10% contain 90% cover 10% cover 90%; - } - #deferred_target { - animation-trigger: alternate --viewtimeline contain 5% contain 80% cover 5% cover 80%; - } - .scroller { - overflow-y: scroll; - height: 500px; - width: 500px; - border: solid 1px; - position: relative; - } - #wrapper { - timeline-scope: --viewtimeline; - } - #space { - width: 50px; - height: 600px; - } - </style> - <div id="wrapper"> - <div id="default_target" class="target"></div> - <div id="scroller" class="scroller"> - <div id="space"></div> - <div id="scroll_target" class="target"></div> - <div id="space"></div> - <div id="view_target" class="target"></div> - <div id="space"></div> - <div id="deferred_subject" class="subject"></div> - <div id="space"></div> - </div> - <div id="deferred_target" class="target"></div> - </div> - <script> - function assert_timeline_offset(actual, expected, errorMessage) { - assert_equals(actual.rangeName, expected.rangeName, errorMessage); - assert_style_value_equals(actual.offset, expected.offset); - } - - function testTrigger(trigger, expectation) { - assert_equals(trigger.type, expectation.type, "trigger type matches"); - assert_timeline_offset(trigger.rangeStart, expectation.rangeStart, - "trigger rangeStart matches"); - assert_timeline_offset(trigger.rangeEnd, expectation.rangeEnd, - "trigger rangeEnd matches"); - assert_timeline_offset(trigger.exitRangeStart, expectation.exitRangeStart, - "trigger exitRangeStart matches"); - assert_timeline_offset(trigger.exitRangeEnd, expectation.exitRangeEnd, - "trigger exitRangeEnd matches"); - if (expectation.timeline === document.timeline) { - assert_equals(trigger.timeline, document.timeline, "timeline matches"); - } else { - assert_equals(trigger.timeline.source, expectation.timelineSource, - "trigger timeline source matches"); - assert_equals(trigger.timeline.axis, expectation.timelineAxis, - "trigger timeline axis matches"); - assert_equals(trigger.timeline.subject, expectation.timelineSubject, - "trigger timeline subject matches"); - } - } - - promise_test(async() => { - await waitForNextFrame(); - const animation = default_target.getAnimations()[0]; - const trigger = animation.trigger; - - const expectation = { - type: "once", - rangeStart: "normal", - rangeEnd: "normal", - exitRangeStart: "normal", - exitRangeEnd: "normal", - timeline: document.timeline - }; - - testTrigger(trigger, expectation); - }, "Default AnimationTrigger for CSS Animation"); - - promise_test(async() => { - await waitForNextFrame(); - const animation = scroll_target.getAnimations()[0]; - const trigger = animation.trigger; - await waitForNextFrame(); - - const expectation = { - type: "repeat", - rangeStart: { rangeName: "none", offset: CSS.px(150) }, - rangeEnd: { rangeName: "none", offset: CSS.px(200) }, - exitRangeStart: { rangeName: "none", offset: CSS.px(100) }, - exitRangeEnd: { rangeName: "none", offset: CSS.px(250) }, - timelineSource: scroller, - timelineAxis: "inline" - }; - - testTrigger(trigger, expectation); - }, "AnimationTrigger for CSS Animation with scroll() timeline"); - - promise_test(async() => { - await waitForNextFrame(); - const animation = view_target.getAnimations()[0]; - const trigger = animation.trigger; - await waitForNextFrame(); - - const expectation = { - type: "state", - rangeStart: { rangeName: 'contain', offset: CSS.percent(10) }, - rangeEnd: { rangeName: 'contain', offset: CSS.percent(90) }, - exitRangeStart: { rangeName: 'cover', offset: CSS.percent(10) }, - exitRangeEnd: { rangeName: 'cover', offset: CSS.percent(90) }, - timelineSource: scroller, - timelineAxis: "x", - timelineSubject: view_target - }; - - testTrigger(trigger, expectation); - }, "AnimationTrigger for CSS Animation with view() timeline"); - - promise_test(async() => { - await waitForNextFrame(); - const animation = deferred_target.getAnimations()[0]; - const trigger = animation.trigger; - await waitForNextFrame(); - - const expectation = { - type: "alternate", - rangeStart: { rangeName: 'contain', offset: CSS.percent(5) }, - rangeEnd: { rangeName: 'contain', offset: CSS.percent(80) }, - exitRangeStart: { rangeName: 'cover', offset: CSS.percent(5) }, - exitRangeEnd: { rangeName: 'cover', offset: CSS.percent(80) }, - timelineSource: scroller, - timelineAxis: "block", - timelineSubject: deferred_subject - }; - - testTrigger(trigger, expectation); - }, "AnimationTrigger for CSS Animation with deferred timeline"); - </script> - </body> -</html>
\ No newline at end of file diff --git a/tests/wpt/tests/service-workers/service-worker/add-routes.https.html b/tests/wpt/tests/service-workers/service-worker/add-routes.https.html new file mode 100644 index 00000000000..fbab7cdedfa --- /dev/null +++ b/tests/wpt/tests/service-workers/service-worker/add-routes.https.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Service Worker: addRoutes() executes in installing</title> +<script src="/common/get-host-info.sub.js"></script> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script src="resources/static-router-helpers.sub.js"></script> +<script> + +promise_test(async t => { + const script = 'resources/add-routes.js'; + const scope = 'resources/blank.html'; + const reg = await service_worker_unregister_and_register(t, script, scope); + t.add_cleanup(() => reg.unregister()); + await wait_for_state(t, reg.installing, 'activated'); + const sw = reg.active; + const addRoutesError = await get_info_from_worker(sw); + + assert_equals(addRoutesError.install, null, + 'addRoutes() should execute successfully in installing'); + assert_true(addRoutesError.activate instanceof Error, + 'addRoutes() should throw outside of installing'); + +}, 'addRoutes() will not be executed outside of installing'); + +</script>
\ No newline at end of file diff --git a/tests/wpt/tests/service-workers/service-worker/resources/add-routes.js b/tests/wpt/tests/service-workers/service-worker/resources/add-routes.js new file mode 100644 index 00000000000..796acd19c12 --- /dev/null +++ b/tests/wpt/tests/service-workers/service-worker/resources/add-routes.js @@ -0,0 +1,37 @@ +let globalAddRoutes; +let addRoutesError = {}; + +self.addEventListener('install', event => { + globalAddRoutes = event.addRoutes.bind(event); + globalAddRoutes([ + { + condition: { urlPattern: '/', runningStatus: 'not-running' }, + source: 'network', + }, + ]) + .then(() => { + addRoutesError.install = null; + }) + .catch(error => { + addRoutesError.install = error; + }); +}); + +self.addEventListener('activate', event => { + globalAddRoutes([ + { + condition: { urlPattern: '/', runningStatus: 'not-running' }, + source: 'network', + }, + ]) + .then(() => { + addRoutesError.activate = null; + }) + .catch(error => { + addRoutesError.activate = error; + }); +}); + +self.addEventListener('message', event => { + event.ports[0].postMessage(addRoutesError); +});
\ No newline at end of file diff --git a/tests/wpt/tests/soft-navigation-heuristics/detection/tentative/racing-soft-navigations.html b/tests/wpt/tests/soft-navigation-heuristics/detection/tentative/racing-soft-navigations.html index d485f908134..b513ff4f99b 100644 --- a/tests/wpt/tests/soft-navigation-heuristics/detection/tentative/racing-soft-navigations.html +++ b/tests/wpt/tests/soft-navigation-heuristics/detection/tentative/racing-soft-navigations.html @@ -10,68 +10,240 @@ <script></script> </head> <body> - <div id="slow-soft-navigation">Click here!</div> - <div id="fast-soft-navigation">Click here!</div> + <div id="first_interaction">Click here!</div> + <div id="second_interaction">Click here!</div> <script> - // This soft navigation is slow - it will wait 1s before processing. - function slowSoftNavigation(t) { - t.step_timeout(() => { + const FIRST_URL = "first-url"; + const SECOND_URL = "second-url"; + + const button1 = document.getElementById("first_interaction"); + const button2 = document.getElementById("second_interaction"); + + async function updateUI() { const greeting = document.createElement("div"); greeting.textContent = "Hello, World."; document.body.appendChild(greeting); - history.pushState({}, "", "/slow-soft-navigation"); - }, 1000); } - // This soft navigation is fast - it will process immediately. - function fastSoftNavigation() { - const greeting = document.createElement("div"); - greeting.textContent = "Hello, World."; - document.body.appendChild(greeting); - history.pushState({}, "", "/fast-soft-navigation"); + function updateUrl(t, url) { + t.state.numPushStateCalls++; + const actual_url = t.state.urlPrefix + url; + history.pushState({}, "", actual_url); + } + + async function waitForSoftNavEntry(t, count = 1) { + return t.step_wait(() => t.state.softNavEntries.length >= count); } - promise_test(async (t) => { - document.getElementById("slow-soft-navigation").addEventListener("click", () => { - slowSoftNavigation(t); - }); - document - .getElementById("fast-soft-navigation") - .addEventListener("click", fastSoftNavigation); - - // Wait for both soft navigations to complete. - const promise = new Promise((resolve) => { - let entries = []; - new PerformanceObserver((list, observer) => { - entries.push(...list.getEntries()); - if (entries.length >= 2) { - observer.disconnect(); - resolve(entries); + async function create_test(urlPrefix, callback) { + return promise_test(async (t) => { + const currentUrl = location.pathname.replace(/.*\//, ""); + assert_equals(currentUrl, "racing-soft-navigations.html"); + + t.state = {}; + t.state.urlPrefix = urlPrefix; + t.state.numPushStateCalls = 0; + t.state.softNavEntries = []; + const observer = new PerformanceObserver((list, observer) => { + // If we get two soft-navs in one observer callback... + // that is a sign that we emitted multiple for a single effect + const entries = list.getEntries(); + assert_equals(entries.length, 1, "Expecting a single soft navigation"); + t.state.softNavEntries.push(entries[0]); + }); + observer.observe({ type: 'soft-navigation' }); + + // We have multiple test cases with side effects, so add some cleanup. + t.add_cleanup(async () => { + observer.disconnect(); + + // Go back to the original URL + for (let i = 0; i < t.state.numPushStateCalls; i++) { + history.back(); + await new Promise(resolve => { + addEventListener('popstate', resolve, {once: true}); + }); } - }).observe({ type: "soft-navigation" }); - }); + }); + + return callback(t); + }, "Racing multiple overlapping interactions and soft navs: " + urlPrefix); + } + + async function expectationsMultipleInteractionTest(t, expected = [FIRST_URL, SECOND_URL]) { + const count = expected.length; + await t.step_wait(() => t.state.softNavEntries.length >= count, `Wait for ${count} soft navigation entries`); + + // Although we await at least `count` (above), we also assert exactly `count` (here) + assert_equals(t.state.softNavEntries.length, count, `Expected ${count} soft navigation entries`); + + for (let i = 0; i < count; i++) { + const entry = t.state.softNavEntries[i]; + const actual_expected_url = t.state.urlPrefix + expected[i]; + assert_equals( + entry.name.replace(/.*\//, ""), + actual_expected_url, + "Expect to observe the first URL change.", + ); + } + } + + // The following tests will trigger two interaction back to back, and each + // interaction will do a sequence of the following: + // - Triggers event listener, which schedules async work + // - updates URL + // - updates UI + // - yield, or timeout of some kind + // - Emit a soft nav entry + // + // Because there are two interactions per test, we manipulate the + // sequence of operations in various ways. + + // Baseline, non overlapping interactions. + create_test("click1,url1,ui1,sn1,yield,click2,url2,ui2,sn2", async (t) => { + button1.addEventListener('click', async () => { + updateUrl(t, FIRST_URL); + updateUI(); + }, { once: true }); + + button2.addEventListener('click', async () => { + updateUrl(t, SECOND_URL); + updateUI(); + }, { once: true }); + + if (test_driver) { + test_driver.click(button1); + } + + await waitForSoftNavEntry(t); + + if(test_driver) { + test_driver.click(button2); + } + + await expectationsMultipleInteractionTest(t); + }); + + // Both interactions start and yield (simulate network), then finish all + // required effects and emit soft nav without overlap. First interaction + // wins the "network" race. + create_test("click1,yield,click2,yield,url1,ui1,sn1,yield,url2,ui2,sn2", async (t) => { + button1.addEventListener('click', async () => { + t.step_timeout(() => { + updateUrl(t, FIRST_URL); + updateUI(); + }, 0); + }, { once: true }); + + button2.addEventListener('click', async () => { + await waitForSoftNavEntry(t); + + updateUrl(t, SECOND_URL); + updateUI(); + }, { once: true }); + + // Start both soft navigations in rapid succession. + if (test_driver) { + test_driver.click(button1); + test_driver.click(button2); + } + + await expectationsMultipleInteractionTest(t); + + }); + + // Both interactions start and yield (simulate network), then finish all + // required effects and emit soft nav without overlap. Second interaction + // wins the "network" race. + create_test("click1,yield,click2,yield,url2,ui2,sn2,yield,url1,ui1,sn1", async (t) => { + button1.addEventListener('click', async () => { + await waitForSoftNavEntry(t); + // In this test, the first interaction sets the second URL + updateUrl(t, FIRST_URL); + updateUI(); + }, { once: true }); + + button2.addEventListener('click', async () => { + t.step_timeout(() => { + updateUrl(t, SECOND_URL); + updateUI(); + }, 0); + }, { once: true }); + // Start both soft navigations in rapid succession. if (test_driver) { - test_driver.click(document.getElementById("slow-soft-navigation")); - test_driver.click(document.getElementById("fast-soft-navigation")); + test_driver.click(button1); + test_driver.click(button2); } - // Notice that both navigations are detected, with the fast one - // arriving first. - const entries = await promise; - assert_equals(entries.length, 2, "Expected two soft navigation entries"); - assert_equals( - entries[0].name.replace(/.*\//, ""), - "fast-soft-navigation", - "First entry should be the fast soft navigation.", - ); - assert_equals( - entries[1].name.replace(/.*\//, ""), - "slow-soft-navigation", - "Second entry should be the slow soft navigation.", - ); - }, "Two soft navigations that race each other should be detected correctly."); + await expectationsMultipleInteractionTest(t, [SECOND_URL, FIRST_URL]); + }); + + // Both interactions start, immediately update URL and yield (simulate + // navigate interception), then finish all required effects later. + // Only the second URL update emits a soft nav entry. + create_test("click1,url1,yield,click2,url2,ui1,yield,ui2,sn2", async (t) => { + let first_interaction_did_finish_paint = false; + let second_interaction_did_run = false; + + button1.addEventListener('click', async () => { + updateUrl(t, FIRST_URL); + + await t.step_wait(() => second_interaction_did_run); + + updateUI(); + + await new Promise(r => requestAnimationFrame(r)); + await new Promise(r => t.step_timeout(r, 0)); + first_interaction_did_finish_paint = true; + }, { once: true }); + + button2.addEventListener('click', async () => { + updateUrl(t, SECOND_URL); + second_interaction_did_run = true; + + await t.step_wait(() => first_interaction_did_finish_paint); + + updateUI(); + }, { once: true }); + + // Start both soft navigations in rapid succession. + if (test_driver) { + test_driver.click(button1); + test_driver.click(button2); + } + + await expectationsMultipleInteractionTest(t,[SECOND_URL]); + }); + + // Both interactions start, immediately update URL and yield (simulate + // navigate interception), then finish all required effects later. + // Only the second URL update emits a soft nav entry. + create_test("click1,url1,yield,click2,url2,yield,ui2,sn2,yield,ui1", async (t) => { + button1.addEventListener('click', async () => { + updateUrl(t, FIRST_URL); + await waitForSoftNavEntry(t); + updateUI(); + }, { once: true }); + + button2.addEventListener('click', async () => { + updateUrl(t, SECOND_URL); + + t.step_timeout(async () => { + updateUI(); + }, 100); + }, { once: true }); + + // Start both soft navigations in rapid succession. + if (test_driver) { + test_driver.click(button1); + test_driver.click(button2); + } + + await expectationsMultipleInteractionTest(t,[SECOND_URL]); + }); + </script> </body> </html> diff --git a/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/distant-leaf.window.js b/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/distant-leaf.window.js new file mode 100644 index 00000000000..c599985a2a2 --- /dev/null +++ b/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/distant-leaf.window.js @@ -0,0 +1,47 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=../../resources/soft-navigation-test-helper.js + +// This test is intended to verify that when a distant leaf of a +// deeply nested div element is attached to the DOM, its painting can +// trigger a soft navigation. +// +// To show this, we create a button that, when clicked, creates a deeply +// nested div element and attaches it to the DOM - only the leaf, a text +// node saying "Hello, World.", 10 levels below the attachment point actually +// gets painted. + +function clickHandler() { + let div = document.createElement('div'); + div.textContent = 'Hello, World.'; // The leaf node that gets painted. + for (let i = 0; i < 10; i++) { + const tmp = document.createElement('div'); + tmp.appendChild(div); + div = tmp; + } + document.body.appendChild(div); + history.pushState({}, '', '/greeting'); +} + +const button = document.createElement('div'); +button.textContent = 'Click here!'; +button.onclick = clickHandler; +document.body.appendChild(button); + +promise_test(async (t) => { + if (test_driver) { + test_driver.click(button); + } + const helper = new SoftNavigationTestHelper(t); + const entries = await helper.getBufferedPerformanceEntriesWithTimeout( + /*type=*/ 'soft-navigation', + /*includeSoftNavigationObservations=*/ false, + /*minNumEntries=*/ 1, + ); + assert_equals(entries.length, 1, 'Expected exactly one soft navigation.'); + assert_equals( + entries[0].name.replace(/.*\//, ''), + 'greeting', + 'URL ends with \'greeting\'.', + ); +}, 'DOM: Distant leaf satisfies Soft Navigation paint criterion.'); diff --git a/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/insert-image-div-before.window.js b/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/insert-image-div-before.window.js new file mode 100644 index 00000000000..19e8a397c34 --- /dev/null +++ b/tests/wpt/tests/soft-navigation-heuristics/dom/tentative/insert-image-div-before.window.js @@ -0,0 +1,47 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=../../resources/soft-navigation-test-helper.js + +// This test shows a relatively simple case where a div with an image inside +// is inserted before another element, and the image is painted, and yet +// we don't detect a soft navigation. +// https://g-issues.chromium.org/issues/419822831#comment5 + +function clickHandler() { + const div = document.createElement("div"); + const img = new Image(); + img.src = "/images/lcp-256x256.png" + // Uncomment the following line => test passes (image should work too though). + // div.textContent = "Hello, World."; + div.appendChild(img); + document.body.insertBefore(div, document.getElementById("insert-before")); + history.pushState({}, '', '/test'); +} + +const div = document.createElement('div'); +div.id = 'insert-before'; +document.body.appendChild(div); + +const button = document.createElement('div'); +button.textContent = 'Click here!'; +button.onclick = clickHandler; +document.body.appendChild(button); + +promise_test(async (t) => { + if (test_driver) { + test_driver.click(button); + } + const helper = new SoftNavigationTestHelper(t); + const entries = await helper.getBufferedPerformanceEntriesWithTimeout( + /*type=*/ 'soft-navigation', + /*includeSoftNavigationObservations=*/ false, + /*minNumEntries=*/ 1, + /*timeout=*/ 3000, + ); + assert_equals(entries.length, 1, 'Expected exactly one soft navigation.'); + assert_equals( + entries[0].name.replace(/.*\//, ''), + 'test', + 'URL ends with \'test\'.', + ); +}, 'DOM: Insert image div satisfies Soft Navigation paint criterion.'); diff --git a/tests/wpt/tests/soft-navigation-heuristics/history/tentative/navigation-api-prevent-default.window.js b/tests/wpt/tests/soft-navigation-heuristics/history/tentative/navigation-api-prevent-default.window.js new file mode 100644 index 00000000000..3df2192f560 --- /dev/null +++ b/tests/wpt/tests/soft-navigation-heuristics/history/tentative/navigation-api-prevent-default.window.js @@ -0,0 +1,48 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +// This test shows that preventDefault() on the navigate event can +// prevent a soft navigation, because it ensures that neither the a.href +// (foobar.html in our example) is visited, nor the handler specified in the +// intercept on the navigate event is called. + +const link = document.createElement('a'); +link.href = 'foobar.html'; +link.textContent = 'Click me!'; +document.body.appendChild(link); + +promise_test(async (t) => { + let navigateProcessed = false; + + navigation.addEventListener('navigate', (e) => { + e.intercept({ + async handler() { + assert_unreached('preventDefault() should prevent the navigation'); + }, + }); + e.preventDefault(); + navigateProcessed = true; + }); + + if (test_driver) { + test_driver.click(link); + } + + await t.step_wait( + () => navigateProcessed, '\'navigate\' event not processed'); + + const observer = new PerformanceObserver(() => { + assert_unreached('Soft navigation should not be triggered'); + }); + observer.observe({type: 'soft-navigation', buffered: true}); + + await new Promise((resolve) => { + t.step_timeout(resolve, 3000); + }).then(() => { + observer.disconnect(); + }); + if (document.softNavigations) { + assert_equals(document.softNavigations, 0, 'Soft Navigation not detected'); + } + assert_false(location.href.includes('foobar.html'), 'foobar.html not visited'); +}, 'Navigation API: Aborted navigate event is not a soft navigation'); diff --git a/tests/wpt/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html b/tests/wpt/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html deleted file mode 100644 index b7b2a24c942..00000000000 --- a/tests/wpt/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>Don't detect a navigate event which got aborted as a soft navigation. -</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="/resources/testdriver.js"></script> -<script src="/resources/testdriver-vendor.js"></script> -<script src="resources/soft-navigation-helper.js"></script> -</head> -<body> - <main id=main> - <a href="foobar.html" id=link>Click me!</a> - </main> - <script> - const link = document.getElementById("link"); - testSoftNavigationNotDetected({ - testName: "Aborted navigate event is not a soft navigation", - eventHandler: e => { - e.intercept({handler: async () => { - await addImageToMain(); - main.appendChild(img); - }}); - e.preventDefault(); - timestamps[counter]["eventEnd"] = performance.now(); - }, - eventTarget: navigation, - eventName: "navigate", - link: link}); - </script> -</body> -</html> - diff --git a/tests/wpt/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html b/tests/wpt/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html index fd87f5f03e7..a460b922eb7 100644 --- a/tests/wpt/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html +++ b/tests/wpt/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html @@ -1,64 +1,77 @@ -<!DOCTYPE HTML> +<!DOCTYPE html> <html> -<head> -<meta charset="utf-8"> -<title>Soft navigation with multiple popstate calls.</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="/resources/testdriver.js"></script> -<script src="/resources/testdriver-vendor.js"></script> -<script src="resources/soft-navigation-helper.js"></script> -</head> -<body> - <main id=main> - <div> - <a id=link>Click me!</a> - </div> - </main> - <script> - // Push state 4 times, as history.back() calls will trigger popstate - // events. - history.pushState({}, "", "foobar.html"); - history.pushState({}, "", "another_one.html"); - history.pushState({}, "", "and_another.html"); - history.pushState({}, "", "and_yet_another.html"); + <head> + <meta charset="utf-8" /> + <title>Soft navigation with multiple popstate calls.</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-vendor.js"></script> + <script src="resources/soft-navigation-helper.js"></script> + </head> + <body> + <main id="main"> + <div> + <a id="link">Click me!</a> + </div> + </main> + <script> + // Push state 4 times, as history.back() calls will trigger popstate + // events. + history.pushState({}, "", "three.html"); + history.pushState({}, "", "two.html"); + history.pushState({}, "", "one.html"); + history.pushState({}, "", "zero.html"); - // This function runs at the start of the popstate event. - const eventPrepWork = t => { - // If this is an event due to the first click, go back() twice more. - if (!t.popped) { - step_timeout(()=>history.back(), 0); - step_timeout(()=>history.back(), 0); - t.popped = 0; - } - ++t.popped; - // return true for the second time the event fires, which is the first - // back() triggered by the popstate event. The means that the first one - // of those back() navigations would trigger a soft navigation, but not - // the last one. - return t.popped == 2; - } - const link = document.getElementById("link"); - link.addEventListener("click", () => { - history.back(); - timestamps[counter]["eventEnd"] = performance.now(); - }); - testSoftNavigation({ - addContent: () => { - // Add the content to the main element - const main = document.getElementById("main"); - main.removeChild(document.getElementsByTagName("div")[0]); - const div = document.createElement("div"); - const text = document.createTextNode("Lorem ipsum"); - div.appendChild(text); - div.style="font-size: 3em"; - main.appendChild(div); - }, - link: link, - eventPrepWork: eventPrepWork, - testName: "A soft navigation that started from a back() call inside a " - + "popstate event is recognized by SoftNavigationHeuristics", - eventType: "popstate"}); - </script> -</body> + // When the link is clicked by the driver, this click handler will call + // history.back(), which will (of course) also trigger a popstate event. + // The history.back() destination is one.html, the first URL visited by + // this interaction. + const link = document.getElementById("link"); + link.addEventListener("click", async () => { + history.back(); + timestamps[counter]["eventEnd"] = performance.now(); + await waitForUrlToEndWith("one.html"); + }); + + let shouldPrepWorkFail = false; + testSoftNavigation({ + link: link, + // The popstate event handler triggers two additional history.back() + // events, which don't cascade further (see shouldPrepWorkFail). + // After the pushState method runs, the contents get added, and the + // soft navigation is detected. + eventType: "popstate", + eventPrepWork: () => { + return !shouldPrepWorkFail; + }, + pushState: async () => { + shouldPrepWorkFail = true; + history.back(); + await waitForUrlToEndWith("two.html"); // Second URL visited by interaction. + history.back(); + await waitForUrlToEndWith("three.html"); // Third and final URL visited by interaction. + }, + // This is the URL we expect to see in the 'name' field of the soft navigation entry. + pushUrl: "one.html", + addContent: async () => { + assert_true( + location.href.endsWith("three.html"), + "addContent should see the effect of all history.back() calls", + ); + // Add the content to the main element + const main = document.getElementById("main"); + main.removeChild(document.getElementsByTagName("div")[0]); + const div = document.createElement("div"); + const text = document.createTextNode("Lorem ipsum"); + div.appendChild(text); + div.style = "font-size: 3em"; + main.appendChild(div); + }, + testName: + "A soft navigation that started from a back() call inside a " + + "popstate event is recognized by SoftNavigationHeuristics", + }); + </script> + </body> </html> diff --git a/tests/wpt/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js b/tests/wpt/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js index 5860738225b..4bc16b44e00 100644 --- a/tests/wpt/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js +++ b/tests/wpt/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js @@ -24,7 +24,7 @@ const withTimeoutMessage = // Helper method for use with history.back(), when we want to be // sure that its asynchronous effect has completed. const waitForUrlToEndWith = async (url) => { - return new Promise((resolve) => { + return new Promise((resolve, reject) => { window.addEventListener('popstate', () => { if (location.href.endsWith(url)) { resolve(); @@ -44,7 +44,7 @@ const testSoftNavigation = options => { const clicks = readValue(options.clicks, 1); const extraValidations = readValue(options.extraValidations, () => {}); const testName = options.testName; - const pushUrl = readValue(options.pushUrl, true); + const pushUrl = readValue(options.pushUrl, URL); const eventType = readValue(options.eventType, 'click'); const interactionFunc = options.interactionFunc; const eventPrepWork = options.eventPrepWork; @@ -67,7 +67,7 @@ const testSoftNavigation = options => { interact(link, interactionFunc); const navigation_id = await withTimeoutMessage( - t, soft_nav_promise, 'Timed out waiting for soft navigation'); + t, soft_nav_promise, 'Timed out waiting for soft navigation', 3000); if (!first_navigation_id) { first_navigation_id = navigation_id; } @@ -113,28 +113,6 @@ const testNavigationApi = (testName, navigateEventHandler, link) => { }, testName); }; -const testSoftNavigationNotDetected = options => { - promise_test(async t => { - const preClickLcp = await getLcpEntries(); - options.eventTarget.addEventListener( - options.eventName, options.eventHandler); - interact(options.link); - await new Promise((resolve, reject) => { - new PerformanceObserver(() => { - reject('Soft navigation should not be triggered'); - }).observe({type: 'soft-navigation', buffered: true}); - t.step_timeout(resolve, 1000); - }); - if (document.softNavigations) { - assert_equals( - document.softNavigations, 0, 'Soft Navigation not detected'); - } - const postClickLcp = await getLcpEntries(); - assert_equals( - preClickLcp.length, postClickLcp.length, 'No LCP entries accumulated'); - }, options.testName); -}; - const runEntryValidations = async ( preClickLcp, first_navigation_id, entries_expected_number = 2, validate = null) => { @@ -233,7 +211,7 @@ const validateSoftNavigationEntry = for (let i = 0; i < entries.length; ++i) { const entry = entries[i]; assert_true( - entry.name.includes(pushUrl ? URL : document.location.href), + entry.name.includes(pushUrl ? pushUrl : document.location.href), 'The soft navigation name is properly set'); const entryTimestamp = entry.startTime; assert_less_than_equal( diff --git a/tests/wpt/tests/soft-navigation-heuristics/smoke/tentative/supported-entry-types.window.js b/tests/wpt/tests/soft-navigation-heuristics/smoke/tentative/supported-entry-types.window.js new file mode 100644 index 00000000000..50e22df0f3e --- /dev/null +++ b/tests/wpt/tests/soft-navigation-heuristics/smoke/tentative/supported-entry-types.window.js @@ -0,0 +1,7 @@ +// PerformanceObserver.supportedEntryTypes is a good way to detect whether +// soft navigations are supported. See also: +// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/supportedEntryTypes_static + +test(() => { + assert_in_array('soft-navigation', PerformanceObserver.supportedEntryTypes); +}, 'Soft navigations are a supported entry type for PerformanceObserver'); diff --git a/tests/wpt/tests/soft-navigation-heuristics/supported-entry-types.tentative.html b/tests/wpt/tests/soft-navigation-heuristics/supported-entry-types.tentative.html deleted file mode 100644 index 4ab408e10b1..00000000000 --- a/tests/wpt/tests/soft-navigation-heuristics/supported-entry-types.tentative.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>Soft navigations are a supported entry type</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> - promise_test(async () => { - assert_true(PerformanceObserver.supportedEntryTypes.includes( - "soft-navigation")); - }, "Soft navigations are a supported entry type"); -</script> - - diff --git a/tests/wpt/tests/speculation-rules/invalid-rules.https.html b/tests/wpt/tests/speculation-rules/invalid-rules.https.html new file mode 100644 index 00000000000..d887c6cafc8 --- /dev/null +++ b/tests/wpt/tests/speculation-rules/invalid-rules.https.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/utils.js"></script> +<script src="/common/dispatcher/dispatcher.js"></script> +<script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> +<script src="resources/utils.js"></script> + +<meta name="variant" content="?prefetch"> +<meta name="variant" content="?prerender"> + +<script> +setup(() => assertSpeculationRulesIsSupported()); + +const preloadingType = location.search.substring(1); + +promise_test(async t => { + const rcHelper = new PreloadingRemoteContextHelper(); + const referrerRC = await rcHelper.addWindow(); + + const destinationRC = await referrerRC.addPreload(preloadingType, { + extrasInSpeculationRule: { invalid_key: "value" } + }); + + await referrerRC.navigateTo(destinationRC.url); + + const headers = await destinationRC.getRequestHeaders(); + assert_false(headers.has("Sec-Purpose")); +}, `an unrecognized key in a ${preloadingType} rule should prevent it from being preloaded`); +</script> diff --git a/tests/wpt/tests/speculation-rules/prefetch/clear-prefetch-cache-after-clear-site-data-cache.tentative.https.html b/tests/wpt/tests/speculation-rules/prefetch/clear-prefetch-cache-after-clear-site-data-cache.https.html index 48f6264e852..79078d30ab6 100644 --- a/tests/wpt/tests/speculation-rules/prefetch/clear-prefetch-cache-after-clear-site-data-cache.tentative.https.html +++ b/tests/wpt/tests/speculation-rules/prefetch/clear-prefetch-cache-after-clear-site-data-cache.https.html @@ -1,9 +1,4 @@ <!DOCTYPE html> -<!-- -This file is marked as "tentative" until: -* The feature flag ClearSiteDataPrefetchPrerenderCache is enabled and - https://github.com/WICG/nav-speculation/issues/357 is added to the specification. ---> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/common/dispatcher/dispatcher.js"></script> diff --git a/tests/wpt/tests/speculation-rules/prefetch/invalid-rules.https.html b/tests/wpt/tests/speculation-rules/prefetch/invalid-rules.https.html deleted file mode 100644 index 0fdfacde643..00000000000 --- a/tests/wpt/tests/speculation-rules/prefetch/invalid-rules.https.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="/common/dispatcher/dispatcher.js"></script> -<script src="/common/utils.js"></script> -<script src="../resources/utils.js"></script> -<script src="resources/utils.sub.js"></script> -<script> - setup(() => assertSpeculationRulesIsSupported()); - - promise_test(async t => { - let agent = await spawnWindow(t); - let nextUrl = agent.getExecutorURL({ page: 2 }); - await agent.forceSinglePrefetch(nextUrl, { invalid_key: "value" }); - await agent.navigate(nextUrl); - - assert_not_prefetched(await agent.getRequestHeaders()); - }, "an unrecognized key in a prefetch rule should prevent it from being fetched"); -</script> diff --git a/tests/wpt/tests/speculation-rules/prerender/activation-start.https.html b/tests/wpt/tests/speculation-rules/prerender/activation-start.https.html index 7aee20c3465..a26af011614 100644 --- a/tests/wpt/tests/speculation-rules/prerender/activation-start.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/activation-start.https.html @@ -16,9 +16,9 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { const ACTIVATION_DELAY = 10; - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const iframeRC = await prerenderedRC.addIframe(); assert_equals( @@ -36,7 +36,7 @@ promise_test(async t => { // Wait ACTIVATION_DELAY ms before activation. await new Promise(resolve => t.step_timeout(resolve, ACTIVATION_DELAY)); - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); assert_greater_than_equal( await getActivationStart(prerenderedRC), diff --git a/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-different-origins.tentative.https.html b/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-different-origins.https.html index db52e758750..c18df9e0cd9 100644 --- a/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-different-origins.tentative.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-different-origins.https.html @@ -1,32 +1,26 @@ <!DOCTYPE html> -<!-- -This file is marked as "tentative" until: -* The feature flag ClearSiteDataPrefetchPrerenderCache is enabled and - https://github.com/WICG/nav-speculation/issues/357 is added to the specification. ---> <title>clear-site-data-cache cancels prerenders</title> <meta name="timeout" content="long"> -<body> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<script src="/speculation-rules/resources/utils.js"></script> -<script src="/speculation-rules/prerender/resources/utils.js"></script> <script src="/common/utils.js"></script> <script src="/common/get-host-info.sub.js"></script> <script src="/common/dispatcher/dispatcher.js"></script> <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> +<script src="../resources/utils.js"></script> +<script src="resources/utils.js"></script> <script> setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow({ origin: 'HTTPS_ORIGIN' }, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC, { + const prerenderedRC = await referrerRC.addPrerender({ origin: 'HTTPS_REMOTE_ORIGIN', headers: [ ['Supports-Loading-Mode', 'credentialed-prerender'] @@ -52,8 +46,6 @@ promise_test(async t => { // the initiator origin, the existing prerender is not expected to be // canceled. // And the prerender is expected to be activated. - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); }); </script> -</body> -</html> diff --git a/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-same-origin.tentative.https.html b/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-same-origin.https.html index 23d862c5130..a2668fc3bca 100644 --- a/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-same-origin.tentative.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/cancel-prerendering-after-clear-site-data-cache-same-origin.https.html @@ -1,33 +1,26 @@ <!DOCTYPE html> -<!-- -This file is marked as "tentative" until: -* The feature flag ClearSiteDataPrefetchPrerenderCache is enabled and - https://github.com/WICG/nav-speculation/issues/357 is added to the specification. ---> <title>clear-site-data-cache cancels prerenders</title> <meta name="timeout" content="long"> -<body> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<script src="/speculation-rules/resources/utils.js"></script> -<script src="/speculation-rules/prerender/resources/utils.js"></script> <script src="/common/utils.js"></script> <script src="/common/get-host-info.sub.js"></script> <script src="/common/dispatcher/dispatcher.js"></script> <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> +<script src="../resources/utils.js"></script> +<script src="resources/utils.js"></script> <script> setup(() => assertSpeculationRulesIsSupported()); -// Test that Clear-Site-Data header value "prerenderCache" clears prerender cache promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow({ origin: 'HTTPS_ORIGIN' }, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC, { + const prerenderedRC = await referrerRC.addPrerender({ origin: 'HTTPS_ORIGIN' }); @@ -48,20 +41,18 @@ promise_test(async t => { // Because Clear-Site-Data response header is sent, the existing prerender // is expected to be canceled. // And the navigation is expected to create another page instead of activation. - referrerRC.navigateTo(prerenderedRC.url); - assert_equals(await getActivationStart(prerenderedRC), 0); + await referrerRC.navigateExpectingNoPrerenderingActivation(prerenderedRC); }, "clear-site-data prerenderCache headers should prevent it from being activated"); -// Test that Clear-Site-Data header value "cache" clears prerender cache promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow({ origin: 'HTTPS_ORIGIN' }, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC, { + const prerenderedRC = await referrerRC.addPrerender({ origin: 'HTTPS_ORIGIN' }); @@ -83,9 +74,6 @@ promise_test(async t => { // Because Clear-Site-Data response header is sent, the existing prerender // is expected to be canceled. // And the navigation is expected to create another page instead of activation. - referrerRC.navigateTo(prerenderedRC.url); - assert_equals(await getActivationStart(prerenderedRC), 0); + await referrerRC.navigateExpectingNoPrerenderingActivation(prerenderedRC); }, "clear-site-data cache headers should prevent it from being activated"); </script> -</body> -</html> diff --git a/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-not-opt-in.https.html b/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-not-opt-in.https.html index 697382a6dc8..a02a2860990 100644 --- a/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-not-opt-in.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-not-opt-in.https.html @@ -15,13 +15,12 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow({origin: 'HTTPS_ORIGIN'}, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC, {origin: 'HTTPS_REMOTE_ORIGIN'}); + const prerenderedRC = await referrerRC.addPrerender({origin: 'HTTPS_REMOTE_ORIGIN'}); // Because the prerender doesn't use opt-in header, it is expected to be canceled. // And the navigation is expected to create another page instead of activation. - referrerRC.navigateTo(prerenderedRC.url); - assert_equals(await getActivationStart(prerenderedRC), 0); + await referrerRC.navigateExpectingNoPrerenderingActivation(prerenderedRC); }); </script> diff --git a/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-opt-in.https.html b/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-opt-in.https.html index 91626bafce6..c309abd2c6d 100644 --- a/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-opt-in.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/credentialed-prerender-opt-in.https.html @@ -15,10 +15,10 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow({origin: 'HTTPS_ORIGIN'}, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC, {origin: 'HTTPS_REMOTE_ORIGIN', headers: [['Supports-Loading-Mode', 'credentialed-prerender']] }); + const prerenderedRC = await referrerRC.addPrerender({origin: 'HTTPS_REMOTE_ORIGIN', headers: [['Supports-Loading-Mode', 'credentialed-prerender']] }); - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); }); </script> diff --git a/tests/wpt/tests/speculation-rules/prerender/headers.https.html b/tests/wpt/tests/speculation-rules/prerender/headers.https.html index 2ef6b5ce072..e05f72434e4 100644 --- a/tests/wpt/tests/speculation-rules/prerender/headers.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/headers.https.html @@ -15,9 +15,9 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async () => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const prerenderedHeaders = await prerenderedRC.getRequestHeaders(); assertHeaders(prerenderedHeaders, true, true, 'prerendered page'); @@ -53,14 +53,14 @@ promise_test(async () => { }, 'Headers before activation, including prerendered page navigation'); promise_test(async () => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); // Add the iframe now, but only check its headers after activation. const crossOriginIframeBeforeActivationRC = await prerenderedRC.addIframe({ origin: 'HTTPS_REMOTE_ORIGIN' }); - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); const crossOriginIframeBeforeActivationHeaders = await crossOriginIframeBeforeActivationRC.getRequestHeaders(); assertHeaders(crossOriginIframeBeforeActivationHeaders, true, false, 'cross-origin iframe before activation'); diff --git a/tests/wpt/tests/speculation-rules/prerender/navigation-api-location-replace.https.html b/tests/wpt/tests/speculation-rules/prerender/navigation-api-location-replace.https.html index e3ecf1b72b6..3b4fb4195ca 100644 --- a/tests/wpt/tests/speculation-rules/prerender/navigation-api-location-replace.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/navigation-api-location-replace.https.html @@ -13,12 +13,12 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); assert_equals(await referrerRC.executeScript(() => navigation.entries().length), 1); let referrerRCCurrentId = await referrerRC.executeScript(() => navigation.currentEntry.id); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); let activationStateBeforeActivation = await prerenderedRC.executeScript(() => { return { entries: navigation.entries().map(e => ({ id: e.id, })), @@ -35,7 +35,7 @@ promise_test(async t => { // Save the current entry before activation. await prerenderedRC.executeScript(() => window.currentEntryBeforeActivation = navigation.currentEntry); - await activatePrerenderRC(referrerRC, prerenderedRC, url => { + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC, url => { location.replace(url); }); diff --git a/tests/wpt/tests/speculation-rules/prerender/navigation-api-multiple-entries.https.html b/tests/wpt/tests/speculation-rules/prerender/navigation-api-multiple-entries.https.html index e8e0f874597..060091e171e 100644 --- a/tests/wpt/tests/speculation-rules/prerender/navigation-api-multiple-entries.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/navigation-api-multiple-entries.https.html @@ -13,7 +13,7 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC1 = await rcHelper.addWindow(undefined, { features: 'noopener' }); const referrerRC2 = await referrerRC1.navigateToNew(); @@ -22,7 +22,7 @@ promise_test(async t => { let referrerRC3CurrentId = await referrerRC3.executeScript(() => navigation.currentEntry.id); - const prerenderedRC = await addPrerenderRC(referrerRC3); + const prerenderedRC = await referrerRC3.addPrerender(); let activationStateBeforeActivation = await prerenderedRC.executeScript(() => { return { entries: navigation.entries().map(e => ({ id: e.id, })), @@ -36,7 +36,7 @@ promise_test(async t => { assert_equals(activationStateBeforeActivation.activationEntryId, activationStateBeforeActivation.entries[0].id); assert_equals(activationStateBeforeActivation.activationNavigationType, "push"); - await activatePrerenderRC(referrerRC3, prerenderedRC); + await referrerRC3.navigateExpectingPrerenderingActivation(prerenderedRC); let activationStateAfterActivation = await prerenderedRC.executeScript(() => { return { diff --git a/tests/wpt/tests/speculation-rules/prerender/navigation-api.https.html b/tests/wpt/tests/speculation-rules/prerender/navigation-api.https.html index fd25e94b5b3..c6ee9742716 100644 --- a/tests/wpt/tests/speculation-rules/prerender/navigation-api.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/navigation-api.https.html @@ -13,12 +13,12 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); assert_equals(await referrerRC.executeScript(() => navigation.entries().length), 1); let referrerRCCurrentId = await referrerRC.executeScript(() => navigation.currentEntry.id); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); let activationStateBeforeActivation = await prerenderedRC.executeScript(() => { return { entries: navigation.entries().map(e => ({ id: e.id, })), @@ -35,7 +35,7 @@ promise_test(async t => { // Save the current entry before activation. await prerenderedRC.executeScript(() => window.currentEntryBeforeActivation = navigation.currentEntry); - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); let activationStateAfterActivation = await prerenderedRC.executeScript(() => { return { diff --git a/tests/wpt/tests/speculation-rules/prerender/referrer-policy-mismatch.https.html b/tests/wpt/tests/speculation-rules/prerender/referrer-policy-mismatch.https.html index fa2d424660a..09cd98eb243 100644 --- a/tests/wpt/tests/speculation-rules/prerender/referrer-policy-mismatch.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/referrer-policy-mismatch.https.html @@ -15,17 +15,17 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: "noopener" }); await setReferrerPolicy(referrerRC, "strict-origin-when-cross-origin"); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const referrerURL = await referrerRC.executeScript(() => location.href); assert_equals(await prerenderedRC.executeScript(() => document.prerendering), true); assert_equals(await prerenderedRC.executeScript(() => document.referrer), referrerURL); - await activatePrerenderRC(referrerRC, prerenderedRC, url => { + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC, url => { const a = document.createElement("a"); a.href = url; a.referrerPolicy = "no-referrer"; @@ -37,17 +37,17 @@ promise_test(async t => { }, 'prerendered with "strict-origin-when-cross-origin", activated with "no-referrer"'); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: "noopener" }); await setReferrerPolicy(referrerRC, "strict-origin-when-cross-origin"); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const referrerURL = await referrerRC.executeScript(() => location.href); assert_equals(await prerenderedRC.executeScript(() => document.prerendering), true); assert_equals(await prerenderedRC.executeScript(() => document.referrer), referrerURL); - await activatePrerenderRC(referrerRC, prerenderedRC, url => { + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC, url => { const a = document.createElement("a"); a.href = url; a.referrerPolicy = "strict-origin"; @@ -59,10 +59,10 @@ promise_test(async t => { }, 'prerendered with "strict-origin-when-cross-origin", activated with "strict-origin"'); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: "noopener" }); await setReferrerPolicy(referrerRC, "strict-origin"); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const referrerURL = await referrerRC.executeScript(() => location.href); const referrerOrigin = (new URL(referrerURL)).origin + "/"; @@ -70,7 +70,7 @@ promise_test(async t => { assert_equals(await prerenderedRC.executeScript(() => document.prerendering), true); assert_equals(await prerenderedRC.executeScript(() => document.referrer), referrerOrigin); - await activatePrerenderRC(referrerRC, prerenderedRC, url => { + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC, url => { const a = document.createElement("a"); a.href = url; a.referrerPolicy = "unsafe-url"; diff --git a/tests/wpt/tests/speculation-rules/prerender/resources/background-sync.https.html b/tests/wpt/tests/speculation-rules/prerender/resources/background-sync.https.html index dd452aa3451..6589b69b22f 100644 --- a/tests/wpt/tests/speculation-rules/prerender/resources/background-sync.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/resources/background-sync.https.html @@ -5,7 +5,7 @@ <script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script> <script> -// The main test page (restriction-background-sync.tentative.https.html) +// The main test page (restriction-background-sync.https.html) // loads the initiator page, then the initiator page will prerender itself // with the `prerendering` parameter. const params = new URLSearchParams(location.search); diff --git a/tests/wpt/tests/speculation-rules/prerender/resources/utils.js b/tests/wpt/tests/speculation-rules/prerender/resources/utils.js index 259f71f6a70..e8397042e7f 100644 --- a/tests/wpt/tests/speculation-rules/prerender/resources/utils.js +++ b/tests/wpt/tests/speculation-rules/prerender/resources/utils.js @@ -375,98 +375,108 @@ function test_prerender_defer(fn, label) { }, label); } -/** - * Starts prerendering a page from the given referrer `RemoteContextWrapper`, - * using `<script type="speculationrules">`. - * - * See - * /html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js - * for more details on the `RemoteContextWrapper` framework, and supported fields for extraConfig. - * - * The returned `RemoteContextWrapper` for the prerendered remote - * context will have an extra `url` property, which is used by - * @see activatePrerenderRC. (Most `RemoteContextWrapper` uses should not care - * about the URL, but prerendering is unique in that you need to navigate to - * a prerendered page after creating it.) - * - * @param {RemoteContextWrapper} referrerRemoteContext - * @param {RemoteContextConfig|object} extraConfig - * @returns {Promise<RemoteContextWrapper>} - */ -function addPrerenderRC(referrerRemoteContext, extraConfig) { - return referrerRemoteContext.helper.createContext({ - executorCreator(url) { - return referrerRemoteContext.executeScript(url => { - const script = document.createElement("script"); - script.type = "speculationrules"; - script.textContent = JSON.stringify({ - prerender: [ - { - source: "list", - urls: [url] - } - ] +// If you want access to these, be sure to include +// /html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js +// and /speculation-rules/resources/utils.js. So as to avoid requiring everyone +// to do that, we only conditionally define this infrastructure. +if (globalThis.PreloadingRemoteContextHelper) { + class PrerenderingRemoteContextWrapper extends PreloadingRemoteContextHelper.RemoteContextWrapper { + /** + * Activates a prerendered page represented by `destinationRC` by navigating + * the page currently displayed in this `PrerenderingRemoteContextWrapper` to + * it. If the navigation does not result in a prerender activation, the + * returned promise will be rejected with a testharness.js AssertionError. + * + * @param {PrerenderingRemoteContextWrapper} destinationRC - The + * `PrerenderingRemoteContextWrapper` pointing to the prerendered + * content. This is monitored to ensure the navigation results in a + * prerendering activation. + * @param {(string) => Promise<undefined>} [navigateFn] - An optional + * function to customize the navigation. It will be passed the URL of the + * prerendered content, and will run as a script in this (see + * `RemoteContextWrapper.prototype.executeScript`). If not given, + * navigation will be done via the `location.href` setter (see + * `RemoteContextWrapper.prototype.navigateTo`). + * @returns {Promise<undefined>} + */ + async navigateExpectingPrerenderingActivation(destinationRC, navigateFn) { + // Store a promise that will fulfill when the `prerenderingchange` event + // fires. + await destinationRC.executeScript(() => { + window.activatedPromise = new Promise(resolve => { + document.addEventListener("prerenderingchange", () => resolve("activated"), { once: true }); }); - document.head.append(script); - }, [url]); - }, extraConfig - }); -} + }); -/** - * Activates a prerendered RemoteContextWrapper `prerenderedRC` by navigating - * the referrer RemoteContextWrapper `referrerRC` to it. If the navigation does - * not result in a prerender activation, the returned - * promise will be rejected with a testharness.js AssertionError. - * - * See - * /html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js - * for more on the RemoteContext helper framework. - * - * @param {RemoteContextWrapper} referrerRC - The referrer - * `RemoteContextWrapper` in which the prerendering was triggered, - * probably via `addPrerenderRC()`. - * @param {RemoteContextWrapper} prerenderedRC - The `RemoteContextWrapper` - * pointing to the prerendered content. This is monitored to ensure the - * navigation results in a prerendering activation. - * @param {(string) => Promise<undefined>} [navigateFn] - An optional function - * to customize the navigation. It will be passed the URL of the prerendered - * content, and will run as a script in `referrerRC` (see - * `RemoteContextWrapper.prototype.executeScript`). If not given, navigation - * will be done via the `location.href` setter (see - * `RemoteContextWrapper.prototype.navigateTo`). - * @returns {Promise<undefined>} - */ -async function activatePrerenderRC(referrerRC, prerenderedRC, navigateFn) { - // Store a promise that will fulfill when the prerenderingchange event fires. - await prerenderedRC.executeScript(() => { - window.activatedPromise = new Promise(resolve => { - document.addEventListener("prerenderingchange", () => resolve("activated")); - }); - }); + if (navigateFn === undefined) { + await this.navigateTo(destinationRC.url); + } else { + await this.navigate(navigateFn, [destinationRC.url]); + } - if (navigateFn === undefined) { - referrerRC.navigateTo(prerenderedRC.url); - } else { - referrerRC.navigate(navigateFn, [prerenderedRC.url]); - } + // Wait until that event fires. If the activation fails and a normal + // navigation happens instead, then `destinationRC` will start pointing to + // that other page, where `window.activatedPromise` is undefined. In that + // case this assert will fail since `undefined !== "activated"`. + assert_equals( + await destinationRC.executeScript(() => window.activatedPromise), + "activated", + "The prerendered page must be activated; instead a normal navigation happened." + ); + } - // Wait until that event fires. If the activation fails and a normal - // navigation happens instead, then prerenderedRC will start pointing to that - // other page, where window.activatedPromise is undefined. In that case this - // assert will fail since undefined !== "activated". - assert_equals( - await prerenderedRC.executeScript(() => window.activatedPromise), - "activated", - "The prerendered page must be activated; instead a normal navigation happened." - ); -} + /** + * Navigates to the URL identified by `destinationRC`, but expects that the + * navigation does not cause a prerendering activation. (E.g., because the + * prerender was canceled by something in the test code.) If the navigation + * results in a prerendering activation, the returned promise will be + * rejected with a testharness.js AssertionError. + * @param {RemoteContextWrapper} destinationRC - The `RemoteContextWrapper` + * pointing to the destination URL. Usually this is obtained by + * prerendering (e.g., via `addPrerender()`), even though we are testing + * that the prerendering does not activate. + * @param {(string) => Promise<undefined>} [navigateFn] - An optional + * function to customize the navigation. It will be passed the URL of the + * prerendered content, and will run as a script in this (see + * `RemoteContextWrapper.prototype.executeScript`). If not given, + * navigation will be done via the `location.href` setter (see + * `RemoteContextWrapper.prototype.navigateTo`). + * @returns {Promise<undefined>} + */ + async navigateExpectingNoPrerenderingActivation(destinationRC, navigateFn) { + if (navigateFn === undefined) { + await this.navigateTo(destinationRC.url); + } else { + await this.navigate(navigateFn, [destinationRC.url]); + } + + assert_equals( + await destinationRC.executeScript(() => { + return performance.getEntriesByType("navigation")[0].activationStart; + }), + 0, + "The prerendered page must not be activated." + ); + } -async function getActivationStart(prerenderedRC) { - return await prerenderedRC.executeScript(() => { - const entry = performance.getEntriesByType("navigation")[0]; - return entry.activationStart; - });; + /** + * Starts prerendering a page with this `PreloadingRemoteContextWrapper` as the + * referrer, using `<script type="speculationrules">`. + * + * @param {object} [extrasInSpeculationRule] - Additional properties to add + * to the speculation rule JSON. + * @param {RemoteContextConfig|object} [extraConfig] - Additional remote + * context configuration for the preloaded context. + * @returns {Promise<PreloadingRemoteContextWrapper>} + */ + addPrerender(options) { + return this.addPreload("prerender", options); + } + } + + globalThis.PrerenderingRemoteContextHelper = class extends PreloadingRemoteContextHelper { + static RemoteContextWrapper = PrerenderingRemoteContextWrapper; + }; } // Used by the opened window, to tell the main test runner to terminate a diff --git a/tests/wpt/tests/speculation-rules/prerender/restriction-background-sync.tentative.https.html b/tests/wpt/tests/speculation-rules/prerender/restriction-background-sync.https.html index 53dbb56d99f..53dbb56d99f 100644 --- a/tests/wpt/tests/speculation-rules/prerender/restriction-background-sync.tentative.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/restriction-background-sync.https.html diff --git a/tests/wpt/tests/speculation-rules/prerender/visibility-state.https.html b/tests/wpt/tests/speculation-rules/prerender/visibility-state.https.html index e9e8548c4f6..8ab18113fda 100644 --- a/tests/wpt/tests/speculation-rules/prerender/visibility-state.https.html +++ b/tests/wpt/tests/speculation-rules/prerender/visibility-state.https.html @@ -14,13 +14,13 @@ setup(() => assertSpeculationRulesIsSupported()); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); assert_equals(await prerenderedRC.executeScript(() => document.visibilityState), "hidden"); - await activatePrerenderRC(referrerRC, prerenderedRC); + await referrerRC.navigateExpectingPrerenderingActivation(prerenderedRC); assert_equals(await prerenderedRC.executeScript(() => document.visibilityState), "visible"); }); diff --git a/tests/wpt/tests/speculation-rules/resources/utils.js b/tests/wpt/tests/speculation-rules/resources/utils.js index cb72f446813..f2fc2169113 100644 --- a/tests/wpt/tests/speculation-rules/resources/utils.js +++ b/tests/wpt/tests/speculation-rules/resources/utils.js @@ -1,4 +1,4 @@ -window.assertSpeculationRulesIsSupported = () => { +globalThis.assertSpeculationRulesIsSupported = () => { assert_implements( 'supports' in HTMLScriptElement, 'HTMLScriptElement.supports must be supported'); @@ -6,3 +6,49 @@ window.assertSpeculationRulesIsSupported = () => { HTMLScriptElement.supports('speculationrules'), '<script type="speculationrules"> must be supported'); }; + +// If you want access to these, be sure to include +// /html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js. +// So as to avoid requiring everyone to do that, we only conditionally define this infrastructure. +if (globalThis.RemoteContextHelper) { + class PreloadingRemoteContextWrapper extends RemoteContextHelper.RemoteContextWrapper { + /** + * Starts preloading a page with this `PreloadingRemoteContextWrapper` as the + * referrer, using `<script type="speculationrules">`. + * + * @param {"prefetch"|"prerender"} preloadType - The preload type to use. + * @param {object} [extrasInSpeculationRule] - Additional properties to add + * to the speculation rule JSON. + * @param {RemoteContextConfig|object} [extraConfig] - Additional remote + * context configuration for the preloaded context. + * @returns {Promise<PreloadingRemoteContextWrapper>} + */ + addPreload(preloadType, { extrasInSpeculationRule = {}, ...extraConfig } = {}) { + const referrerRemoteContext = this; + + return this.helper.createContext({ + executorCreator(url) { + return referrerRemoteContext.executeScript((url, preloadType, extrasInSpeculationRule) => { + const script = document.createElement("script"); + script.type = "speculationrules"; + script.textContent = JSON.stringify({ + [preloadType]: [ + { + source: "list", + urls: [url], + ...extrasInSpeculationRule + } + ] + }); + document.head.append(script); + }, [url, preloadType, extrasInSpeculationRule]); + }, + extraConfig + }); + } + } + + globalThis.PreloadingRemoteContextHelper = class extends RemoteContextHelper { + static RemoteContextWrapper = PreloadingRemoteContextWrapper; + }; +} diff --git a/tests/wpt/tests/speculation-rules/prerender/script-supports-speculationrules.https.html b/tests/wpt/tests/speculation-rules/script-supports.https.html index 2dc856fce5d..7446f2b6b5f 100644 --- a/tests/wpt/tests/speculation-rules/prerender/script-supports-speculationrules.https.html +++ b/tests/wpt/tests/speculation-rules/script-supports.https.html @@ -1,15 +1,14 @@ <!DOCTYPE html> -<html> <title>HTMLScriptElement.supports speculationrules</title> -<meta name="timeout" content="long"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> + <script> -test(function() { +test(() => { assert_true(HTMLScriptElement.supports('speculationrules')); }, 'HTMLScriptElement.supports returns true for \'speculationrules\''); -test(function() { +test(() => { assert_false(HTMLScriptElement.supports(' speculationrules')); assert_false(HTMLScriptElement.supports('speculationrules ')); assert_false(HTMLScriptElement.supports('Speculationrules')); @@ -17,5 +16,4 @@ test(function() { assert_false(HTMLScriptElement.supports('speculationRules')); assert_false(HTMLScriptElement.supports('speculation-rules')); }, 'HTMLScriptElement.supports returns false for unsupported types'); - </script> diff --git a/tests/wpt/tests/speculation-rules/speculation-tags/no-tags.https.html b/tests/wpt/tests/speculation-rules/speculation-tags/no-tags.https.html index 176b3d20bb2..088f0ba66b5 100644 --- a/tests/wpt/tests/speculation-rules/speculation-tags/no-tags.https.html +++ b/tests/wpt/tests/speculation-rules/speculation-tags/no-tags.https.html @@ -6,9 +6,9 @@ <script src="/common/dispatcher/dispatcher.js"></script> <script src="/common/utils.js"></script> <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script> -<script src="/speculation-rules/prerender/resources/utils.js"></script> <script src="/speculation-rules/resources/utils.js"></script> <script src="/speculation-rules/prefetch/resources/utils.sub.js"></script> +<script src="/speculation-rules/prerender/resources/utils.js"></script> <script src="resources/speculation-tags-utils.js"></script> <script> "use strict"; @@ -30,10 +30,10 @@ promise_test(async t => { }, "Sec-Speculation-Tags: no tags (prefetch)"); promise_test(async t => { - const rcHelper = new RemoteContextHelper(); + const rcHelper = new PrerenderingRemoteContextHelper(); const referrerRC = await rcHelper.addWindow(undefined, { features: 'noopener' }); - const prerenderedRC = await addPrerenderRC(referrerRC); + const prerenderedRC = await referrerRC.addPrerender(); const headers = await prerenderedRC.getRequestHeaders(); assert_equals(headers.get("sec-purpose"), "prefetch;prerender"); assert_equals(headers.get("sec-speculation-tags"), "null"); diff --git a/tests/wpt/tests/speech-api/SpeechRecognition-availableOnDevice.https.html b/tests/wpt/tests/speech-api/SpeechRecognition-availableOnDevice.https.html index ace8edd9164..fb4273f7392 100644 --- a/tests/wpt/tests/speech-api/SpeechRecognition-availableOnDevice.https.html +++ b/tests/wpt/tests/speech-api/SpeechRecognition-availableOnDevice.https.html @@ -1,34 +1,34 @@ <!DOCTYPE html> -<title>SpeechRecognition availableOnDevice</title> +<title>SpeechRecognition available</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script> promise_test(async (t) => { - const lang = "en-US"; + const options = { langs: ["en-US", "fr-FR"], processLocally: true }; window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; // Test that it returns a promise. - const resultPromise = SpeechRecognition.availableOnDevice(lang); + const resultPromise = SpeechRecognition.available(options); assert_true( resultPromise instanceof Promise, - "availableOnDevice should return a Promise." + "available should return a Promise." ); // Verify the resolved value is a string. const result = await resultPromise; assert_true( typeof result === "string", - "The resolved value of the availableOnDevice promise should be a string." + "The resolved value of the available promise should be a string." ); assert_true( result === "unavailable" || result === "downloadable" || result === "downloading" || result === "available", - "The resolved value of the availableOnDevice promise should be a " + + "The resolved value of the available promise should be a " + "valid value." ); -}, "SpeechRecognition.availableOnDevice resolves with a string value."); +}, "SpeechRecognition.available resolves with a string value for on-device."); promise_test(async (t) => { const iframe = document.createElement("iframe"); @@ -38,14 +38,15 @@ promise_test(async (t) => { const frameSpeechRecognition = frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition; + const options = { langs: ["en-US"], processLocally: true }; iframe.remove(); await promise_rejects_dom( t, "InvalidStateError", frameDOMException, - frameSpeechRecognition.availableOnDevice("en-US"), + frameSpeechRecognition.available(options), ); -}, "SpeechRecognition.availableOnDevice rejects in a detached context."); +}, "SpeechRecognition.available rejects in a detached context for on-device."); promise_test(async (t) => { const iframe = document.createElement("iframe"); @@ -70,17 +71,18 @@ promise_test(async (t) => { assert_true(!!frameSpeechRecognition, "SpeechRecognition should exist in iframe."); - assert_true(!!frameSpeechRecognition.availableOnDevice, - "availableOnDevice method should exist on SpeechRecognition in iframe."); + assert_true(!!frameSpeechRecognition.available, + "available method should exist on SpeechRecognition in iframe."); - // Call availableOnDevice and expect it to resolve to "unavailable". + const options = { langs: ["en-US"], processLocally: true }; + // Call available and expect it to resolve to "unavailable". const availabilityStatus = - await frameSpeechRecognition.availableOnDevice("en-US"); + await frameSpeechRecognition.available(options); assert_equals(availabilityStatus, "unavailable", - "availableOnDevice should resolve to 'unavailable' if " + + "available should resolve to 'unavailable' if " + "'on-device-speech-recognition' Permission Policy is 'none'." ); -}, "SpeechRecognition.availableOnDevice resolves to 'unavailable' if " + +}, "SpeechRecognition.available resolves to 'unavailable' for on-device if " + "'on-device-speech-recognition' Permission Policy is 'none'."); promise_test(async (t) => { @@ -89,24 +91,25 @@ promise_test(async (t) => { <script> window.addEventListener('message', async (event) => { // Ensure we only process the message intended to trigger the test. - if (event.data !== "runTestCallAvailableOnDevice") return; + if (event.data !== "runTestCallAvailable") return; try { const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; - if (!SpeechRecognition || !SpeechRecognition.availableOnDevice) { + if (!SpeechRecognition || !SpeechRecognition.available) { parent.postMessage({ type: "error", // Use "error" for API not found or other issues. name: "NotSupportedError", - message: "SpeechRecognition.availableOnDevice API not " + + message: "SpeechRecognition.available API not " + "available in iframe" }, "*"); return; } - // Call availableOnDevice and post its resolution. + const options = { langs: ["en-US"], processLocally: true }; + // Call available and post its resolution. const availabilityStatus = - await SpeechRecognition.availableOnDevice("en-US"); + await SpeechRecognition.available(options); parent.postMessage( { type: "resolution", result: availabilityStatus }, "*" @@ -155,7 +158,7 @@ promise_test(async (t) => { })); // Send a distinct message to the iframe to trigger its test logic. - iframe.contentWindow.postMessage("runTestCallAvailableOnDevice", "*"); + iframe.contentWindow.postMessage("runTestCallAvailable", "*"); }); // Check if the iframe's script reported an error (e.g., API not found). @@ -175,9 +178,9 @@ promise_test(async (t) => { assert_equals( testResult.result, // Expecting the string "unavailable". "unavailable", - "availableOnDevice should resolve to 'unavailable' in a cross-origin " + + "available should resolve to 'unavailable' for on-device in a cross-origin " + "iframe." ); -}, "SpeechRecognition.availableOnDevice should resolve to 'unavailable' " + +}, "SpeechRecognition.available should resolve to 'unavailable' for on-device " + "in a cross-origin iframe."); </script> diff --git a/tests/wpt/tests/speech-api/SpeechRecognition-basics.https.html b/tests/wpt/tests/speech-api/SpeechRecognition-basics.https.html index 91cf8e6d3e5..0fbc4aa8426 100644 --- a/tests/wpt/tests/speech-api/SpeechRecognition-basics.https.html +++ b/tests/wpt/tests/speech-api/SpeechRecognition-basics.https.html @@ -11,7 +11,7 @@ test(function() { assert_false(reco.continuous, 'SpeechRecognition.continuous'); assert_false(reco.interimResults, 'SpeechRecognition.interimResults'); assert_equals(reco.maxAlternatives, 1, 'SpeechRecognition.maxAlternatives'); - assert_equals(reco.mode, 'ondevice-preferred', 'SpeechRecognition.mode'); + assert_false(reco.processLocally, 'SpeechRecognition.processLocally'); assert_equals(reco.phrases.length, 0, 'SpeechRecognition.phrases.length'); }); </script> diff --git a/tests/wpt/tests/speech-api/SpeechRecognition-installOnDevice.https.html b/tests/wpt/tests/speech-api/SpeechRecognition-installOnDevice.https.html index 5f78fc8c9c1..52281f61b6c 100644 --- a/tests/wpt/tests/speech-api/SpeechRecognition-installOnDevice.https.html +++ b/tests/wpt/tests/speech-api/SpeechRecognition-installOnDevice.https.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<title>SpeechRecognition installOnDevice</title> +<title>SpeechRecognition install</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/resources/testdriver.js"></script> @@ -11,148 +11,155 @@ promise_test(async (t) => { const invalidLang = "invalid language code"; window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; + const validOptions = { langs: [validLang], processLocally: true }; + const validAlternateOptions = { langs: [validLangAlternateLocale], processLocally: true }; + const invalidOptions = { langs: [invalidLang], processLocally: true }; // Check the availablility of the on-device language pack. const initialAvailabilityPromise = - SpeechRecognition.availableOnDevice(validLang); + SpeechRecognition.available(validOptions); assert_true( initialAvailabilityPromise instanceof Promise, - "availableOnDevice should return a Promise." + "available should return a Promise." ); const initialAvailabilityResult = await initialAvailabilityPromise; assert_true( typeof initialAvailabilityResult === "string", - "The resolved value of the availableOnDevice promise should be a string." + "The resolved value of the available promise should be a string." ); if (initialAvailabilityResult === "downloadable") { - // Attempt to call installOnDevice directly, without a user gesture with a + // Attempt to call install directly, without a user gesture with a // language that is downloadable but not installed. const installWithoutUserGesturePromise = - SpeechRecognition.installOnDevice(validLang); + SpeechRecognition.install(validOptions); // Assert that the promise rejects with NotAllowedError. await promise_rejects_dom( t, "NotAllowedError", window.DOMException, - installWithoutUserGesturePromise, "SpeechRecognition.installOnDevice() " + - "must reject with NotAllowedError if called without a user gesture." + installWithoutUserGesturePromise, "SpeechRecognition.install() " + + "must reject with NotAllowedError if called without a user gesture for on-device." ); // Test that it returns a promise when called with a valid language. const validResultPromise = test_driver.bless( - "Call SpeechRecognition.installOnDevice with a valid language", - () => SpeechRecognition.installOnDevice(validLang) + "Call SpeechRecognition.install with a valid language", + () => SpeechRecognition.install(validOptions) + ); + const validInstallPromise = test_driver.bless( + "Call SpeechRecognition.install with valid options for on-device", + () => SpeechRecognition.install(validOptions) ); assert_true( - validResultPromise instanceof Promise, - "installOnDevice (with gesture) should return a Promise." + validInstallPromise instanceof Promise, + "install (with gesture, for on-device) should return a Promise." ); // Verify the resolved value is a boolean. - const validResult = await validResultPromise; + const validInstallResult = await validInstallPromise; assert_true( - typeof validResult === "boolean", - "The resolved value of the installOnDevice promise should be a boolean." + typeof validInstallResult === "boolean", + "The resolved value of the install promise (on-device) should be a boolean." ); // Verify that the method returns true when called with a supported language. assert_equals( - validResult, + validInstallResult, true, - "installOnDevice should resolve with `true` when called with a " + - "supported language code." + "install should resolve with `true` when called with " + + "supported options for on-device." ); // Verify that the newly installed language pack is available. const availableOnDeviceResultPromise = - SpeechRecognition.availableOnDevice(validLang); + SpeechRecognition.available(validOptions); assert_true( availableOnDeviceResultPromise instanceof Promise, - "availableOnDevice should return a Promise." + "available should return a Promise." ); const availableOnDeviceResult = await availableOnDeviceResultPromise; assert_true( typeof availableOnDeviceResult === "string", - "The resolved value of the availableOnDevice promise should be a string." + "The resolved value of the available promise should be a string." ); assert_true( availableOnDeviceResult === "available", - "The resolved value of the availableOnDevice promise should be " + + "The resolved value of the available promise (on-device) should be " + "'available'." ); // Verify that the newly installed language pack is available for an alternate locale. const alternateLocaleResultPromise = - SpeechRecognition.availableOnDevice(validLangAlternateLocale); + SpeechRecognition.available(validAlternateOptions); assert_true( alternateLocaleResultPromise instanceof Promise, - "availableOnDevice should return a Promise." + "available should return a Promise." ); const alternateLocaleResult = await alternateLocaleResultPromise; assert_true( typeof alternateLocaleResult === "string", - "The resolved value of the availableOnDevice promise should be a string." + "The resolved value of the available promise should be a string." ); assert_true( alternateLocaleResult === "available", - "The resolved value of the availableOnDevice promise should be " + + "The resolved value of the available promise (on-device, alternate locale) should be " + "'available'." ); // Verify that installing an already installed language resolves to true. - const secondResultPromise = test_driver.bless( - "Call SpeechRecognition.installOnDevice for an already installed language", - () => SpeechRecognition.installOnDevice(validLang) + const secondInstallPromise = test_driver.bless( + "Call SpeechRecognition.install for an already installed on-device language", + () => SpeechRecognition.install(validOptions) ); assert_true( - secondResultPromise instanceof Promise, - "installOnDevice (with gesture, for already installed language) should " + + secondInstallPromise instanceof Promise, + "install (with gesture, for already installed on-device language) should " + "return a Promise." ); - const secondResult = await secondResultPromise; + const secondInstallResult = await secondInstallPromise; assert_true( - typeof secondResult === "boolean", - "The resolved value of the second installOnDevice promise should be a " + + typeof secondInstallResult === "boolean", + "The resolved value of the second install promise (on-device) should be a " + "boolean." ); assert_equals( - secondResult, + secondInstallResult, true, - "installOnDevice should resolve with `true` if the language is already " + + "install should resolve with `true` if the on-device language is already " + "installed." ); } // Test that it returns a promise and resolves to false for unsupported lang. - const invalidResultPromise = test_driver.bless( - "Call SpeechRecognition.installOnDevice with an unsupported language code", - () => SpeechRecognition.installOnDevice(invalidLang) + const invalidInstallPromise = test_driver.bless( + "Call SpeechRecognition.install with unsupported on-device options", + () => SpeechRecognition.install(invalidOptions) ); assert_true( - invalidResultPromise instanceof Promise, - "installOnDevice (with gesture, for unsupported language) should return " + + invalidInstallPromise instanceof Promise, + "install (with gesture, for unsupported on-device options) should return " + "a Promise." ); - const invalidResult = await invalidResultPromise; + const invalidInstallResult = await invalidInstallPromise; assert_true( - typeof invalidResult === "boolean", - "The resolved value of the installOnDevice promise (unsupported language) " + + typeof invalidInstallResult === "boolean", + "The resolved value of the install promise (unsupported on-device options) " + "should be a boolean." ); assert_equals( - invalidResult, + invalidInstallResult, false, - "installOnDevice should resolve with `false` when called with an " + - "unsupported language code." + "install should resolve with `false` when called with " + + "unsupported on-device options." ); -}, "SpeechRecognition.installOnDevice resolves with a boolean value " + +}, "SpeechRecognition.install resolves with a boolean value for on-device " + "(with user gesture)."); promise_test(async (t) => { @@ -162,6 +169,7 @@ promise_test(async (t) => { const frameDOMException = frameWindow.DOMException; const frameSpeechRecognition = frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition; + const options = { langs: ["en-US"], processLocally: true }; iframe.remove(); await promise_rejects_dom( @@ -169,13 +177,13 @@ promise_test(async (t) => { "InvalidStateError", frameDOMException, test_driver.bless( - "Call SpeechRecognition.installOnDevice in a detached frame context", + "Call SpeechRecognition.install in a detached frame context for on-device", () => { - return frameSpeechRecognition.installOnDevice("en-US"); + return frameSpeechRecognition.install(options); } ) ); -}, "SpeechRecognition.installOnDevice rejects in a detached context."); +}, "SpeechRecognition.install rejects in a detached context for on-device."); promise_test(async (t) => { const iframe = document.createElement("iframe"); @@ -200,19 +208,20 @@ promise_test(async (t) => { assert_true(!!frameSpeechRecognition, "SpeechRecognition should exist in iframe."); - assert_true(!!frameSpeechRecognition.installOnDevice, - "installOnDevice method should exist on SpeechRecognition in iframe."); + assert_true(!!frameSpeechRecognition.install, + "install method should exist on SpeechRecognition in iframe."); + const options = { langs: ["en-US"], processLocally: true }; await promise_rejects_dom( t, "NotAllowedError", frameDOMException, - frameSpeechRecognition.installOnDevice("en-US"), - "installOnDevice should reject with NotAllowedError if " + + frameSpeechRecognition.install(options), + "install should reject with NotAllowedError if " + "'install-on-device-speech-recognition' Permission Policy is " + "disabled." ); -}, "SpeechRecognition.installOnDevice rejects if " + +}, "SpeechRecognition.install rejects for on-device if " + "'install-on-device-speech-recognition' Permission Policy is disabled."); promise_test(async (t) => { @@ -223,7 +232,7 @@ promise_test(async (t) => { try { const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; - if (!SpeechRecognition || !SpeechRecognition.installOnDevice) { + if (!SpeechRecognition || !SpeechRecognition.install) { parent.postMessage({ type: "rejection", name: "NotSupportedError", @@ -232,7 +241,8 @@ promise_test(async (t) => { return; } - await SpeechRecognition.installOnDevice("en-US"); + const options = { langs: ["en-US"], processLocally: true }; + await SpeechRecognition.install(options); parent.postMessage({ type: "resolution", result: "success" }, "*"); } catch (err) { parent.postMessage({ @@ -286,5 +296,5 @@ promise_test(async (t) => { testResult.message.includes("cross-site subframe"), `Error message should reference cross-origin. Got: "${testResult.message}"` ); -}, "SpeechRecognition.installOnDevice should reject in a cross-origin iframe."); +}, "SpeechRecognition.install should reject for on-device in a cross-origin iframe."); </script> diff --git a/tests/wpt/tests/speech-api/SpeechRecognition-phrases-manual.https.html b/tests/wpt/tests/speech-api/SpeechRecognition-phrases-manual.https.html index 2d0b19ab46c..0f596a88015 100644 --- a/tests/wpt/tests/speech-api/SpeechRecognition-phrases-manual.https.html +++ b/tests/wpt/tests/speech-api/SpeechRecognition-phrases-manual.https.html @@ -1,7 +1,10 @@ <!DOCTYPE html> <html lang="en"> +<meta name="timeout" content="long"> <title>SpeechRecognition Phrases</title> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> @@ -22,6 +25,24 @@ async function getAudioTrackFromFile(filePath) { } promise_test(async (t) => { + window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; + + // Install en-US for on-device speech recognition. + const installOptions = { langs: ["en-US"], processLocally: true }; + const installPromise = test_driver.bless( + "Install on-device en-US speech recognition", + () => SpeechRecognition.install(installOptions) + ); + assert_true( + installPromise instanceof Promise, + "SpeechRecognition.install() should return a Promise." + ); + const installResult = await installPromise; + assert_true( + installResult, + "SpeechRecognition.install() for en-US should resolve with true." + ); + // Verify the audio track for recognition context exists. const audioTrack = await getAudioTrackFromFile("/media/recognition_context.mp3"); assert_true( @@ -31,9 +52,8 @@ promise_test(async (t) => { // Create the first speech recognition with a mode that does not support contextual biasing. // Note that this may vary between browsers in the future. - window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; const recognition1 = new SpeechRecognition(); - recognition1.mode = "cloud-only"; + recognition1.processLocally = false; recognition1.lang = "en-US"; recognition1.onerror = function(event) { @@ -50,7 +70,7 @@ promise_test(async (t) => { // Create the second speech recognition with a mode that supports contextual biasing. const recognition2 = new SpeechRecognition(); - recognition2.mode = "ondevice-only"; + recognition2.processLocally = true; recognition2.lang = "en-US"; recognition2.onerror = function(event) { @@ -67,7 +87,11 @@ promise_test(async (t) => { const recognitionPromise = new Promise((resolve) => { recognition2.onresult = (event) => { const transcript = event.results[0][0].transcript; - resolve(transcript); + const words = transcript.toLowerCase().split(' '); + // Resolve when the last word is "expectations". + if (words.length > 0 && words[words.length - 1] === "expectations") { + resolve(transcript); + } }; }); recognition2.start(audioTrack); diff --git a/tests/wpt/tests/subresource-integrity/integrity-policy/script.https.html b/tests/wpt/tests/subresource-integrity/integrity-policy/script.https.html index 783374db920..57b4d3e3582 100644 --- a/tests/wpt/tests/subresource-integrity/integrity-policy/script.https.html +++ b/tests/wpt/tests/subresource-integrity/integrity-policy/script.https.html @@ -31,12 +31,6 @@ const blob_url = URL.createObjectURL(blob); - // Generated using https://sha2.it/ed25519.html (In Chrome Canary, with Experimental Web Platform Features enabled) - const signature = encodeURIComponent( - 'header(Unencoded-Digest, sha-384=:tqyFpeo21WFM8HDeUtLqH20GUq\/q3D1R6mqTzW3RtyTZ3dAYZJhC1wUcnkgOE2ak:)' + - '|header(Signature-Input, signature=\\("unencoded-digest";sf\\); keyid="JrQLj5P\/89iXES9+vFgrIy29clF9CC\/oPPsw3c5D0bs="; tag="sri")' + - '|header(Signature, signature=:qM19uLskHm2TQG5LJcH/hY0n0BWWzYOJztVWYlwk0cZb3u0JdgUMre1J4Jn8Tma0x2u5/kPBfbXRMbB+X+vTBw==:)'); - const test_cases = [ { description: "Ensure that a script without integrity did not run", @@ -99,16 +93,6 @@ expected: {blocked: "", ran: true }, }, { - description: "Ensure that a script with signature integrity runs", - url: "/content-security-policy/resources/ran.js?pipe=" + signature, - cross_origin: true, - integrity: "ed25519-JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs=", - policy_violation: false, - block: true, - endpoints: true, - expected: {blocked: "", ran: true }, - }, - { description: "Ensure that a data URI script with no integrity runs", url: "data:application/javascript,window.ran=true", cross_origin: true, diff --git a/tests/wpt/tests/subresource-integrity/integrity-policy/tentative/signature.https.html b/tests/wpt/tests/subresource-integrity/integrity-policy/tentative/signature.https.html new file mode 100644 index 00000000000..d54a6dfb7b0 --- /dev/null +++ b/tests/wpt/tests/subresource-integrity/integrity-policy/tentative/signature.https.html @@ -0,0 +1,51 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/dispatcher/dispatcher.js"></script> +<script src="/common/utils.js"></script> +<script src="/reporting/resources/report-helper.js"></script> + +<body> +<script> + promise_test(async () => { + // Generated using https://sha2.it/ed25519.html in a browser that supports Signature-Based SRI (e.g. Chrome 136+, with Experimental Web Platform Features enabled) + const signature = encodeURIComponent( + 'header(Unencoded-Digest, sha-384=:tqyFpeo21WFM8HDeUtLqH20GUq\/q3D1R6mqTzW3RtyTZ3dAYZJhC1wUcnkgOE2ak:)' + + '|header(Signature-Input, signature=\\("unencoded-digest";sf\\); keyid="JrQLj5P\/89iXES9+vFgrIy29clF9CC\/oPPsw3c5D0bs="; tag="sri")' + + '|header(Signature, signature=:qM19uLskHm2TQG5LJcH/hY0n0BWWzYOJztVWYlwk0cZb3u0JdgUMre1J4Jn8Tma0x2u5/kPBfbXRMbB+X+vTBw==:)'); + + const REMOTE_EXECUTOR = + `/common/dispatcher/remote-executor.html`; + const iframe_uuid = token(); + + let header = + `header(Integrity-Policy,blocked-destinations=\\(script\\)\\, endpoints=\\(integrity-endpoint-1 integrity-endpoint-2\\))`; + header += + `|header(Integrity-Policy-Report-Only,blocked-destinations=\\(script\\)\\, endpoints=\\(integrity-endpoint-3\\))`; + const params = new URLSearchParams(); + params.set('uuid', iframe_uuid); + params.set('pipe', header); + + const iframe = document.createElement('iframe'); + iframe.src = `${REMOTE_EXECUTOR}?${params}`; + document.body.appendChild(iframe); + + // Execute code directly from the iframe. + const ctx = new RemoteContext(iframe_uuid); + const result = await ctx.execute_script(async (signature) => { + window.ran = false; + // Load the script + await new Promise(resolve => { + const script = document.createElement('script'); + script.crossOrigin="anonymous"; + script.integrity = "ed25519-JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs="; + script.onload = resolve; + script.onerror = resolve; + script.src = "/content-security-policy/resources/ran.js?pipe=" + signature; + document.body.appendChild(script); + }); + return { ran: window.ran }; + }, [signature]); + assert_equals(result.ran, true); + }, "Ensure that a script with signature integrity runs"); +</script> diff --git a/tests/wpt/tests/svg/animations/svgpath-animation-2.tentative.html b/tests/wpt/tests/svg/animations/svgpath-animation-2.tentative.html new file mode 100644 index 00000000000..68114581172 --- /dev/null +++ b/tests/wpt/tests/svg/animations/svgpath-animation-2.tentative.html @@ -0,0 +1,34 @@ +<!doctype html> +<title>'inherit' path animation</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/SVGAnimationTestCase-testharness.js"></script> +<script src="support/animated-path-helpers.js"></script> +<svg> + <g style="d: path('M0,50h100')"> + <path stroke-width="100" stroke="green"> + <animate attributeName="d" attributeType="CSS" values="M0,50h50; inherit" + dur="5s" fill="freeze"/> + </path> + </g> +</svg> +<script> +const rootSVGElement = document.querySelector("svg"); + +smil_async_test(t => { + const path = document.querySelector("svg > g > path"); + const expectedValues = [ + // [animationId, time, sampleCallback] + ["animation", 0, () => { + assert_animated_path_equals(path, "M 0 50 h 50"); + }], + ["animation", 2.5, () => { + assert_animated_path_equals(path, "M 0 50 h 75"); + }], + ["animation", 5, () => { + assert_animated_path_equals(path, "M 0 50 h 100"); + }] + ]; + runAnimationTest(t, expectedValues); +}); +</script> diff --git a/tests/wpt/tests/svg/embedded/image-embedding-nesteder-data-url.html b/tests/wpt/tests/svg/embedded/image-embedding-nesteder-data-url.html index 48fb4fa48b7..4f8335dcd19 100644 --- a/tests/wpt/tests/svg/embedded/image-embedding-nesteder-data-url.html +++ b/tests/wpt/tests/svg/embedded/image-embedding-nesteder-data-url.html @@ -1,6 +1,9 @@ <!doctype html> +<html class="reftest-wait"> <title>SVG image that uses a data: URL and then again</title> <link rel="match" href="../struct/reftests/reference/green-100x100.html"> +<script src="/common/reftest-wait.js"></script> +<script src="/common/rendering-utils.js"></script> <img src="data:image/svg+xml, <svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> <image href='data:image/svg+xml, @@ -14,3 +17,9 @@ '/> </svg> "> +<script> +waitForAtLeastOneFrame().then(() => { + takeScreenshot(); +}); +</script> +</html> diff --git a/tests/wpt/tests/svg/embedded/image-modify-href-4.svg b/tests/wpt/tests/svg/embedded/image-modify-href-4.svg index f7e550e5def..e900ee71387 100644 --- a/tests/wpt/tests/svg/embedded/image-modify-href-4.svg +++ b/tests/wpt/tests/svg/embedded/image-modify-href-4.svg @@ -16,15 +16,17 @@ const doc = document.implementation.createDocument(SVG_NS, "svg"); const image = doc.createElementNS(SVG_NS, "image"); + image.addEventListener('load', function() { + waitForAtLeastOneFrame().then(() => { + takeScreenshot(); + }); + }); image.setAttribute("width", 100); image.setAttribute("height", 100); image.setAttribute("href", "reference/green-rect-100x100.svg"); doc.documentElement.appendChild(image); document.documentElement.appendChild(document.adoptNode(image)); - - await waitForAtLeastOneFrame(); - takeScreenshot(); } </script> </svg> diff --git a/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform-ref.html b/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform-ref.html new file mode 100644 index 00000000000..78117251a36 --- /dev/null +++ b/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform-ref.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> + +<style> +iframe { + display: block; + border: none; +} +</style> + +<p>None of the marker rects should be visible as disruptions in the gradient, regardless of transforms:</p> +<iframe width=300 height=150 src='support/svg-marker-ref.svg'></iframe> +<iframe width=300 height=150 src='support/svg-marker-ref.svg'></iframe> +<iframe width=300 height=150 src='support/svg-marker-ref.svg'></iframe> diff --git a/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform.html b/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform.html new file mode 100644 index 00000000000..507e9a360cc --- /dev/null +++ b/tests/wpt/tests/svg/painting/reftests/marker-context-fill-transform.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> + +<title>SVG rendering test: context-fill in markers with transform</title> + +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1969782"> +<link rel="match" href="marker-context-fill-transform-ref.html"> + +<style> +iframe { + display: block; + border: none; +} +#a { + zoom: 1; +} +#b { + zoom: 2; +} +#c { + zoom: 0.25; +} +</style> + +<p>None of the marker rects should be visible as disruptions in the gradient, regardless of transforms:</p> +<iframe id=a width=300 height=150 src='support/svg-marker-context-paint.svg'></iframe> +<iframe id=b width=150 height=75 src='support/svg-marker-context-paint.svg'></iframe> +<iframe id=c width=1200 height=600 src='support/svg-marker-context-paint.svg'></iframe> diff --git a/tests/wpt/tests/svg/painting/reftests/small-nested-viewbox.html b/tests/wpt/tests/svg/painting/reftests/small-nested-viewbox.html index 3d9fb8cb45f..308835ce5b4 100644 --- a/tests/wpt/tests/svg/painting/reftests/small-nested-viewbox.html +++ b/tests/wpt/tests/svg/painting/reftests/small-nested-viewbox.html @@ -5,14 +5,14 @@ <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> <link rel="match" href="small-nested-viewbox-ref.html"> <style> - svg { + svg#root { width: 16px; padding: 4px; background: #ccc; color: #000; } </style> -<svg viewBox="0 0 4 4"> +<svg id="root" viewBox="0 0 4 4"> <svg viewBox='0 0 256 256'> <rect width="256" height="256" x="0" y="0" fill="green" /> </svg> diff --git a/tests/wpt/tests/svg/painting/reftests/support/svg-marker-context-paint.svg b/tests/wpt/tests/svg/painting/reftests/support/svg-marker-context-paint.svg new file mode 100644 index 00000000000..8c97058d71e --- /dev/null +++ b/tests/wpt/tests/svg/painting/reftests/support/svg-marker-context-paint.svg @@ -0,0 +1,29 @@ +<svg id="svg-root" viewBox="0 0 1600 900" + xmlns="http://www.w3.org/2000/svg" + xmlns:html="http://www.w3.org/1999/xhtml"> + <defs> + <linearGradient id="lg"> + <stop offset="0" stop-color="red"/> + <stop offset="1" stop-color="blue"/> + </linearGradient> + + <!-- + This marker will render two rectangles, both within the filled area + of the path we're using, so they should be indistinguishable from it. + --> + <marker id="marker" refX="-10" refY="-10" markerWidth="600" markerHeight="400" > + <rect y="0" width="200" height="100" fill="context-fill"/> + <rect x="250" y="270" width="300" height="100" fill="context-fill"/> + </marker> + </defs> + + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z" marker-start="url(#marker)"/> + + <g transform="translate(300 450) scale(0.75 0.5) rotate(60)"> + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z" marker-start="url(#marker)"/> + </g> + + <g transform="translate(600 450) scale(1.5 0.5) rotate(-30)"> + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z" marker-start="url(#marker)"/> + </g> +</svg> diff --git a/tests/wpt/tests/svg/painting/reftests/support/svg-marker-ref.svg b/tests/wpt/tests/svg/painting/reftests/support/svg-marker-ref.svg new file mode 100644 index 00000000000..1e823431105 --- /dev/null +++ b/tests/wpt/tests/svg/painting/reftests/support/svg-marker-ref.svg @@ -0,0 +1,20 @@ +<svg id="svg-root" viewBox="0 0 1600 900" + xmlns="http://www.w3.org/2000/svg" + xmlns:html="http://www.w3.org/1999/xhtml"> + <defs> + <linearGradient id="lg"> + <stop offset="0" stop-color="red"/> + <stop offset="1" stop-color="blue"/> + </linearGradient> + </defs> + + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z"/> + + <g transform="translate(300 450) scale(0.75 0.5) rotate(60)"> + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z"/> + </g> + + <g transform="translate(600 450) scale(1.5 0.5) rotate(-30)"> + <path fill="url(#lg)" d="M 10 10 h 600 v 400 h -600 Z"/> + </g> +</svg> diff --git a/tests/wpt/tests/svg/styling/nested-svg-sizing-expected.svg b/tests/wpt/tests/svg/styling/nested-svg-sizing-expected.svg new file mode 100644 index 00000000000..a8fa5211842 --- /dev/null +++ b/tests/wpt/tests/svg/styling/nested-svg-sizing-expected.svg @@ -0,0 +1,5 @@ +<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"> + <svg width="50" height="50"> + <circle cx="50" cy="50" r="40" fill="green" /> + </svg> +</svg> diff --git a/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use-expected.svg b/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use-expected.svg new file mode 100644 index 00000000000..daef973aa5d --- /dev/null +++ b/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use-expected.svg @@ -0,0 +1,5 @@ +<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg"> + <svg id="target" width="50" height="50"> + <circle cx="50" cy="50" r="40" fill="green" /> + </svg> +</svg> diff --git a/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use.svg b/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use.svg new file mode 100644 index 00000000000..5f3c4eed490 --- /dev/null +++ b/tests/wpt/tests/svg/styling/nested-svg-sizing-with-use.svg @@ -0,0 +1,12 @@ +<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"> + <title>Width and Height as presentation attributes on nested svg</title> + <html:link rel="help" href="https://svgwg.org/svg2-draft/styling.html#TermPresentationAttribute"/> + <html:link rel="match" href="nested-svg-sizing-with-use-expected.svg" /> + <defs> + <svg id="target" style="width:50px; height:50px;"> + <circle cx="50" cy="50" r="40" fill="green" /> + </svg> + </defs> + + <use href="#target"/> +</svg> diff --git a/tests/wpt/tests/svg/styling/nested-svg-sizing.svg b/tests/wpt/tests/svg/styling/nested-svg-sizing.svg new file mode 100644 index 00000000000..6c8c45f6d42 --- /dev/null +++ b/tests/wpt/tests/svg/styling/nested-svg-sizing.svg @@ -0,0 +1,8 @@ +<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"> + <title>Width and Height as presentation attributes on nested svg</title> + <html:link rel="help" href="https://svgwg.org/svg2-draft/styling.html#TermPresentationAttribute"/> + <html:link rel="match" href="nested-svg-sizing-expected.svg" /> + <svg style="width:50px;height:50px;"> + <circle cx="50" cy="50" r="40" fill="green" /> + </svg> +</svg> diff --git a/tests/wpt/tests/tools/META.yml b/tests/wpt/tests/tools/META.yml index db7d4d786b4..b204d814921 100644 --- a/tests/wpt/tests/tools/META.yml +++ b/tests/wpt/tests/tools/META.yml @@ -2,3 +2,4 @@ suggested_reviewers: - jgraham - foolip - DanielRyanSmith + - jonathan-j-lee diff --git a/tests/wpt/tests/tools/ci/jobs.py b/tests/wpt/tests/tools/ci/jobs.py index be600ee3974..f18cd66e420 100644 --- a/tests/wpt/tests/tools/ci/jobs.py +++ b/tests/wpt/tests/tools/ci/jobs.py @@ -145,6 +145,8 @@ def create_parser(): help="Jobs to check for. Return code is 0 if all jobs are found, otherwise 1") parser.add_argument("--json", action="store_true", help="Output jobs as JSON, instead of one per line") + parser.add_argument("--json-indent", type=int, + help="Indent the JSON with this many spaces (default: no indentation, single line output)") return parser @@ -153,7 +155,7 @@ def run(**kwargs): jobs = get_jobs(paths, **kwargs) if not kwargs["includes"]: if kwargs["json"]: - json.dump(sorted(jobs), sys.stdout, indent=2) + json.dump(sorted(jobs), sys.stdout, indent=kwargs["json_indent"]) sys.stdout.write("\n") else: for item in sorted(jobs): diff --git a/tests/wpt/tests/tools/webdriver/webdriver/client.py b/tests/wpt/tests/tools/webdriver/webdriver/client.py index 5a54bf66ac6..f4e6259d547 100644 --- a/tests/wpt/tests/tools/webdriver/webdriver/client.py +++ b/tests/wpt/tests/tools/webdriver/webdriver/client.py @@ -9,24 +9,6 @@ from . import transport from .bidi.client import BidiSession -def command(func): - def inner(self, *args, **kwargs): - if hasattr(self, "session"): - session = self.session - else: - session = self - - if session.session_id is None: - session.start() - - return func(self, *args, **kwargs) - - inner.__name__ = func.__name__ - inner.__doc__ = func.__doc__ - - return inner - - class Timeouts: def __init__(self, session): @@ -111,7 +93,6 @@ class ActionSequence: d["parameters"] = self._pointer_params return d - @command def perform(self): """Perform all queued actions.""" self.session.actions.perform([self.dict]) @@ -271,7 +252,6 @@ class Actions: def __init__(self, session): self.session = session - @command def perform(self, actions=None): """Performs actions by tick from each action sequence in `actions`. @@ -283,7 +263,6 @@ class Actions: actions = self.session.send_session_command("POST", "actions", body) return actions - @command def release(self): return self.session.send_session_command("DELETE", "actions") @@ -299,7 +278,6 @@ class BrowserWindow: def __init__(self, session): self.session = session - @command def close(self): handles = self.session.send_session_command("DELETE", "window") if handles is not None and len(handles) == 0: @@ -309,24 +287,20 @@ class BrowserWindow: return handles @property - @command def rect(self): return self.session.send_session_command("GET", "window/rect") @rect.setter - @command def rect(self, new_rect): self.session.send_session_command("POST", "window/rect", new_rect) @property - @command def size(self): """Gets the window size as a tuple of `(width, height)`.""" rect = self.rect return (rect["width"], rect["height"]) @size.setter - @command def size(self, new_size): """Set window size by passing a tuple of `(width, height)`.""" try: @@ -339,14 +313,12 @@ class BrowserWindow: pass @property - @command def position(self): """Gets the window position as a tuple of `(x, y)`.""" rect = self.rect return (rect["x"], rect["y"]) @position.setter - @command def position(self, new_position): """Set window position by passing a tuple of `(x, y)`.""" try: @@ -358,15 +330,12 @@ class BrowserWindow: # for Android. Revert this once it is implemented. pass - @command def maximize(self): return self.session.send_session_command("POST", "window/maximize") - @command def minimize(self): return self.session.send_session_command("POST", "window/minimize") - @command def fullscreen(self): return self.session.send_session_command("POST", "window/fullscreen") @@ -375,7 +344,6 @@ class Find: def __init__(self, session): self.session = session - @command def css(self, element_selector, all=True): elements = self._find_element("css selector", element_selector, all) return elements @@ -391,21 +359,17 @@ class UserPrompt: def __init__(self, session): self.session = session - @command def dismiss(self): self.session.send_session_command("POST", "alert/dismiss") - @command def accept(self): self.session.send_session_command("POST", "alert/accept") @property - @command def text(self): return self.session.send_session_command("GET", "alert/text") @text.setter - @command def text(self, value): body = {"text": value} self.session.send_session_command("POST", "alert/text", body=body) @@ -591,41 +555,33 @@ class Session: return self.send_command(method, url, body, timeout) @property - @command def url(self): return self.send_session_command("GET", "url") @url.setter - @command def url(self, url): if urlparse.urlsplit(url).netloc is None: return self.url(url) body = {"url": url} return self.send_session_command("POST", "url", body) - @command def back(self): return self.send_session_command("POST", "back") - @command def forward(self): return self.send_session_command("POST", "forward") - @command def refresh(self): return self.send_session_command("POST", "refresh") @property - @command def title(self): return self.send_session_command("GET", "title") @property - @command def source(self): return self.send_session_command("GET", "source") - @command def new_window(self, type_hint="tab"): body = {"type": type_hint} value = self.send_session_command("POST", "window/new", body) @@ -633,12 +589,10 @@ class Session: return value["handle"] @property - @command def window_handle(self): return self.send_session_command("GET", "window") @window_handle.setter - @command def window_handle(self, handle): body = {"handle": handle} return self.send_session_command("POST", "window", body=body) @@ -654,16 +608,13 @@ class Session: return self.send_session_command("POST", url, body) @property - @command def handles(self): return self.send_session_command("GET", "window/handles") @property - @command def active_element(self): return self.send_session_command("GET", "element/active") - @command def cookies(self, name=None): if name is None: url = "cookie" @@ -673,7 +624,6 @@ class Session: raise TypeError("cookie name must be a str or None") return self.send_session_command("GET", url, {}) - @command def set_cookie(self, name, value, path=None, domain=None, secure=None, expiry=None, http_only=None): body = { @@ -704,7 +654,6 @@ class Session: #[...] - @command def execute_script(self, script, args=None): if args is None: args = [] @@ -715,7 +664,6 @@ class Session: } return self.send_session_command("POST", "execute/sync", body) - @command def execute_async_script(self, script, args=None): if args is None: args = [] @@ -728,11 +676,9 @@ class Session: #[...] - @command def screenshot(self): return self.send_session_command("GET", "screenshot") - @command def print(self, background=None, margin=None, @@ -785,13 +731,11 @@ class ShadowRoot: url = f"shadow/{self.id}/{uri}" return self.session.send_session_command(method, url, body) - @command def find_element(self, strategy, selector): body = {"using": strategy, "value": selector} return self.send_shadow_command("POST", "element", body) - @command def find_elements(self, strategy, selector): body = {"using": strategy, "value": selector} @@ -839,39 +783,31 @@ class WebElement: url = "element/%s/%s" % (self.id, uri) return self.session.send_session_command(method, url, body) - @command def find_element(self, strategy, selector): body = {"using": strategy, "value": selector} return self.send_element_command("POST", "element", body) - @command def click(self): self.send_element_command("POST", "click", {}) - @command def tap(self): self.send_element_command("POST", "tap", {}) - @command def clear(self): self.send_element_command("POST", "clear", {}) - @command def send_keys(self, text): return self.send_element_command("POST", "value", {"text": text}) @property - @command def text(self): return self.send_element_command("GET", "text") @property - @command def name(self): return self.send_element_command("GET", "name") - @command def style(self, property_name): if not isinstance(property_name, str): raise TypeError("property_name must be a str") @@ -879,42 +815,34 @@ class WebElement: return self.send_element_command("GET", "css/%s" % property_name) @property - @command def rect(self): return self.send_element_command("GET", "rect") @property - @command def selected(self): return self.send_element_command("GET", "selected") - @command def screenshot(self): return self.send_element_command("GET", "screenshot") @property - @command def shadow_root(self): return self.send_element_command("GET", "shadow") - @command def attribute(self, name): if not isinstance(name, str): raise TypeError("name must be a str") return self.send_element_command("GET", "attribute/%s" % name) - @command def get_computed_label(self): return self.send_element_command("GET", "computedlabel") - @command def get_computed_role(self): return self.send_element_command("GET", "computedrole") # This MUST come last because otherwise @property decorators above # will be overridden by this. - @command def property(self, name): if not isinstance(name, str): raise TypeError("name must be a str") diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/firefox.py b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/firefox.py index f8629878213..e5635c361cc 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/firefox.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/browsers/firefox.py @@ -256,6 +256,7 @@ def update_properties(): return ([ "os", "debug", + "display", "fission", "processor", "swgl", diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/base.py b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/base.py index 76d703e7829..4efe1660eb4 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/base.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/base.py @@ -767,15 +767,16 @@ class CallbackHandler: def process_action(self, url, payload): action = payload["action"] cmd_id = payload["id"] + params = payload["params"] self.logger.debug(f"Got action: {action}") try: action_handler = self.actions[action] except KeyError as e: raise ValueError(f"Unknown action {action}") from e try: - with ActionContext(self.logger, self.protocol, payload.get("context")): + with ActionContext(self.logger, self.protocol, params.get("context")): try: - result = action_handler(payload) + result = action_handler(params) except AttributeError as e: # If we fail to get an attribute from the protocol presumably that's a # ProtocolPart we don't implement @@ -839,8 +840,9 @@ class AsyncCallbackHandler(CallbackHandler): """ async_action_handler = self.async_actions[action] cmd_id = payload["id"] + params = payload["params"] try: - result = await async_action_handler(payload) + result = await async_action_handler(params) except AttributeError as e: # If we fail to get an attribute from the protocol presumably that's a # ProtocolPart we don't implement diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py index e27b111ee8b..8176d15ea2a 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py @@ -20,17 +20,14 @@ def do_delayed_imports(): def __init__(self, session): self.session = session - @webdriver.client.command def get_prefs(self, *prefs): body = {"prefs": list(prefs)} return self.session.send_session_command("POST", "servo/prefs/get", body) - @webdriver.client.command def set_prefs(self, prefs): body = {"prefs": prefs} return self.session.send_session_command("POST", "servo/prefs/set", body) - @webdriver.client.command def reset_prefs(self, *prefs): body = {"prefs": list(prefs)} return self.session.send_session_command("POST", "servo/prefs/reset", body) diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js b/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js index 3c2dd8b42dd..2a5bb3937fd 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/testdriver-extra.js @@ -160,7 +160,7 @@ let cmd_id; const action_msg = {type: "action", action: name, - ...params}; + params}; if (is_test_context()) { cmd_id = window.__wptrunner_message_queue.push(action_msg); } else { diff --git a/tests/wpt/tests/trusted-types/script-enforcement-001-outerHTML.xhtml b/tests/wpt/tests/trusted-types/script-enforcement-001-outerHTML.xhtml new file mode 100644 index 00000000000..f8ce7fee89d --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-001-outerHTML.xhtml @@ -0,0 +1,35 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"/> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"/> +</head> +<body> + <!--- See script-enforcement-001.html an explanation of this test. + The HTML parser won't create a child element for the span child of + scriptForOuterHTMLTest below, so we instead rely on the XHTML parser. --> +<div> + <script id="scriptForOuterHTMLTest" type="unknown"><span></span></script> +</div> +<div id="container"></div> +<script> + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").outerHTML = LOG_RUN_MESSAGE; + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.getElementById("scriptForOuterHTMLTest"); + script.remove(); + script.removeAttribute("type"); + script.firstElementChild.outerHTML = passthroughpolicy.createHTML(LOG_RUN_MESSAGE); + document.getElementById("container").appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.outerHTML drops trustworthiness."); +</script> +</body> +</html> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-001.html b/tests/wpt/tests/trusted-types/script-enforcement-001.html new file mode 100644 index 00000000000..9548987a22d --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-001.html @@ -0,0 +1,327 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +<!-- This test modifies the source of a new (initially disconnected) + HTMLScriptElement by various DOM APIs and verifies whether it will + remain trustworthy. This can be done by checking whether the script + is actually executed after insertion, because this page enforces + Trusted Types without defining any default policy. --> +<div id="container"></div> +<script> + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "The HTMLScriptElement is initially trusted."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").innerText = LOG_RUN_MESSAGE; + }), "TrustedScript required."); + let message = await script_message_for(_ => { + let script = document.createElement("script"); + script.innerText = passthroughpolicy.createScript(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Script source set via TrustedScript sink HTMLScriptElement.innerText keeps trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").textContent = LOG_RUN_MESSAGE; + }), "TrustedScript required."); + let message = await script_message_for(_ => { + let script = document.createElement("script"); + script.textContent = passthroughpolicy.createScript(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Script source set via TrustedScript sink HTMLScriptElement.textContent keeps trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").text = LOG_RUN_MESSAGE; + }), "TrustedScript required."); + let message = await script_message_for(_ => { + let script = document.createElement("script"); + script.text = passthroughpolicy.createScript(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Script source set via TrustedScript sink HTMLScriptElement.text keeps trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").innerHTML = LOG_RUN_MESSAGE; + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.createElement("script"); + script.innerHTML = passthroughpolicy.createHTML(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.innerHTML drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").setHTMLUnsafe(LOG_RUN_MESSAGE); + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.createElement("script"); + script.setHTMLUnsafe(passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.setHTMLUnsafe() drops trustworthiness."); + + if (HTMLScriptElement.prototype.setHTML) { + promise_test(async t => { + // https://wicg.github.io/sanitizer-api/#set-and-filter-html + let script = document.createElement("script"); + script.setHTML(LOG_RUN_MESSAGE); + assert_equals(script.text, ""); + }, "Script source cannot be set via Element.setHTML()."); + } + + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Splitting script source via Text.splitText() keeps trustworthiness."); + + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + script.normalize(); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Normalizing script source via Element.normalize() keeps trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.nodeValue = LOG_RUN_MESSAGE; + container.appendChild(script); + }); + }, "Script source set via Node.nodeValue drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.data = LOG_RUN_MESSAGE; + container.appendChild(script); + }); + }, "Setting script source via CharacterData.data drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.appendData(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.appendData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.insertData(0, LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.insertData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.replaceData(0, 0, LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.replaceData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`//${LOG_RUN_MESSAGE}`); + script.firstChild.deleteData(0, 2); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.deleteData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.before(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.before() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.after(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.after() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + script.firstChild.remove(); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.remove() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.firstChild.replaceWith(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.replaceWith() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.appendChild(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Node.appendChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.insertBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.insertBefore() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.replaceChild(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.replaceChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + script.removeChild(script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.removeChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.prepend(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.prepend() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.append(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.append() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.replaceChildren(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.replaceChildren() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.moveBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Element.moveBefore() drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").insertAdjacentHTML("afterbegin", LOG_RUN_MESSAGE); + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.insertAdjacentHTML("afterbegin", passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.insertAdjacentHTML("beforeend", passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via TrustedHTML sink Node.insertAdjacentHTML() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.insertAdjacentText("afterbegin", LOG_RUN_MESSAGE); + container.appendChild(script); + }); + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + script.insertAdjacentText("beforeend", LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via Node.insertAdjacentText() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`;`); + let range = new Range(); + range.selectNode(script.firstChild); + range.insertNode(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Range.insertNode() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`//;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(2); + let range = new Range(); + range.setStart(script.firstChild, 0); + range.setEnd(script.lastChild, 3); + range.deleteContents(); + container.appendChild(script); + }); + }, "Setting script source via Range.deleteContents() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + let clone = script.cloneNode(true); + container.appendChild(clone); + }); + }, "Cloning a script via Node.cloneNode() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let div = document.createElement("div"); + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + div.appendChild(script); + let range = new Range(); + range.selectNode(script); + let documentFragment = range.cloneContents(); + container.appendChild(documentFragment.firstElementChild); + }); + }, "Cloning a script via Range.cloneContents() drops trustworthiness."); +</script> +</body> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-002-outerHTML.xhtml b/tests/wpt/tests/trusted-types/script-enforcement-002-outerHTML.xhtml new file mode 100644 index 00000000000..79bb64852ce --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-002-outerHTML.xhtml @@ -0,0 +1,48 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"/> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"/> +</head> +<body> + <!--- See script-enforcement-002.html an explanation of this test. + The HTML parser won't create a child element for the span child of + scriptForOuterHTMLTest below, so we instead rely on the XHTML parser. --> +<div> + <script id="scriptForOuterHTMLTest" type="unknown"><span></span></script> +</div> +<div id="container"></div> +<script> + trustedTypes.createPolicy("default", { + createHTML: (value, _, sink) => { + window.log_message("CREATE_HTML"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_HTML"); + }, + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_SCRIPT"); + }, + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.getElementById("scriptForOuterHTMLTest"); + script.remove(); + script.removeAttribute("type"); + window.log_message("SET"); + script.firstElementChild.outerHTML = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + document.getElementById("container").appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element outerHTML", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.outerHTML."); +</script> +</body> +</html> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-002.html b/tests/wpt/tests/trusted-types/script-enforcement-002.html new file mode 100644 index 00000000000..ddbbc99ea6b --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-002.html @@ -0,0 +1,398 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +<!-- This test is similar to script-enforcement-001 but it defines a + default policy, so we can track precisely when its callbacks + are called, the sink names used as well as their effect on + the original script's source. --> +<div id="container"></div> +<script> + trustedTypes.createPolicy("default", { + createHTML: (value, _, sink) => { + window.log_message("CREATE_HTML"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_HTML"); + }, + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_SCRIPT"); + }, + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElement("script"); + window.log_message("SET"); + script.innerText = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_SCRIPT", "HTMLScriptElement innerText", "APPEND", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via HTMLScriptElement.innerText."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElement("script"); + window.log_message("SET"); + script.textContent = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_SCRIPT", "HTMLScriptElement textContent", "APPEND", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via HTMLScriptElement.textContent."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElement("script"); + window.log_message("SET"); + script.text = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_SCRIPT", "HTMLScriptElement text", "APPEND", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via HTMLScriptElement.text."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElement("script"); + window.log_message("SET"); + script.innerHTML = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element innerHTML", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.innerHTML."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElement("script"); + window.log_message("SET"); + script.setHTMLUnsafe(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element setHTMLUnsafe", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.setHTMLUnsafe()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + window.log_message("SET"); + script.firstChild.splitText(3); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "RUN"]); + }, "Default policy when splitting script source via Text.splitText()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.normalize(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "RUN"]); + }, "Default policy when normalizing script source via Element.normalize()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.nodeValue = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.nodeValue."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.data = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.data."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.appendData(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.appendData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.insertData(0, LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.insertData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.replaceData(0, 0, LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.replaceData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`//${LOG_RUN_MESSAGE}`); + window.log_message("SET"); + script.firstChild.deleteData(0, 2); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.deleteData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.before(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.before()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.after(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.after()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.firstChild.remove(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.remove()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.replaceWith(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.replaceWith()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.appendChild(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.appendChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.insertBefore()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.replaceChild(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.replaceChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.removeChild(script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.removeChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.prepend(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.prepend()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.append(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.append()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.replaceChildren(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.replaceChildren()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.moveBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.moveBefore()."); + + promise_test(async t => { + let messages1 = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentText("afterbegin", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages1, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + let messages2 = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentText("beforeend", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages2, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.insertAdjacentText()."); + + promise_test(async t => { + let messages1 = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentHTML("afterbegin", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages1, ["SET", "CREATE_HTML", "Element insertAdjacentHTML", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + let messages2 = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentHTML("beforeend", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages2, ["SET", "CREATE_HTML", "Element insertAdjacentHTML", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Node.insertAdjacentHTML()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`;`); + let range = new Range(); + range.selectNode(script.firstChild); + window.log_message("SET"); + range.insertNode(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting source via Range.insertNode()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`//;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(2); + let range = new Range(); + range.setStart(script.firstChild, 0); + range.setEnd(script.lastChild, 3); + window.log_message("SET"); + range.deleteContents(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Range.deleteContents()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + window.log_message("CLONE"); + let clone = script.cloneNode(true); + window.log_message("APPEND"); + container.appendChild(clone); + }); + assert_array_equals(messages, ["CLONE", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when cloning a script via Node.cloneNode()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let div = document.createElement("div"); + let script = create_html_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + div.appendChild(script); + let range = new Range(); + range.selectNode(script); + window.log_message("CLONE"); + let documentFragment = range.cloneContents(); + window.log_message("APPEND"); + container.appendChild(documentFragment.firstElementChild); + }); + assert_array_equals(messages, ["CLONE", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when cloning a script via Range.cloneContents()."); +</script> +</body> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-003.html b/tests/wpt/tests/trusted-types/script-enforcement-003.html new file mode 100644 index 00000000000..9ad31b795bc --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-003.html @@ -0,0 +1,354 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://github.com/w3c/trusted-types/issues/512"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +<!-- This test is similar to script-enforcement-001 but for the + SVGScriptElement, which has slightly different behavior: + - No equivalent to HTMLElement.innerText. + - No equivalent to HTMLScriptElement.text. + - innerHTML and textContent are not Trusted sinks. + - The HTML parser can insert elements inside the <script> tag. + --> +<svg> + <!-- Provide some static SVGScriptElements for use by + document.createElementNS(NSURI_SVG, "script"). See explanation in script-messages.js. --> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">//;;;window.log_message("RUN")</script> + <script type="unknown">//;;;window.log_message("RUN")</script> + <script type="unknown">//window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")/////</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN");;;</script> + <script type="unknown">window.log_message("RUN");;;</script> + <script type="unknown">window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN")</script> +</svg> +<svg> + <script id="scriptForOuterHTMLTest" type="unknown"><g></g></script> +</svg> +<svg id="container"></svg> +<script> + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "The SVGScriptElement is initially trusted."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + script.textContent = passthroughpolicy.createScript(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Script source set via Element.textContent drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElementNS(NSURI_SVG, "script").innerHTML = LOG_RUN_MESSAGE; + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + script.innerHTML = passthroughpolicy.createHTML(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.innerHTML drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElement("script").outerHTML = LOG_RUN_MESSAGE; + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.getElementById("scriptForOuterHTMLTest"); + script.remove(); + script.removeAttribute("type"); + script.firstElementChild.outerHTML = passthroughpolicy.createHTML(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.outerHTML drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElementNS(NSURI_SVG, "script").setHTMLUnsafe(LOG_RUN_MESSAGE); + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + script.setHTMLUnsafe(passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Script source set via TrustedHTML sink Element.setHTMLUnsafe() drops trustworthiness."); + + if (SVGScriptElement.prototype.setHTML) { + promise_test(async t => { + // https://wicg.github.io/sanitizer-api/#set-and-filter-html + let script = document.createElementNS(NSURI_SVG, "script"); + script.setHTML(LOG_RUN_MESSAGE); + assert_equals(script.textContent, ""); + }, "Script source cannot be set via Element.setHTML()."); + } + + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Splitting script source via Text.splitText() keeps trustworthiness."); + + promise_test(async t => { + let message = await script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + script.normalize(); + container.appendChild(script); + }); + assert_equals(message, "RUN"); + }, "Normalizing script source via Element.normalize() keeps trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.nodeValue = LOG_RUN_MESSAGE; + container.appendChild(script); + }); + }, "Script source set via Node.nodeValue drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.data = LOG_RUN_MESSAGE; + container.appendChild(script); + }); + }, "Setting script source via CharacterData.data drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.appendData(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.appendData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.insertData(0, LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.insertData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.replaceData(0, 0, LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.replaceData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`//${LOG_RUN_MESSAGE}`); + script.firstChild.deleteData(0, 2); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.deleteData() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.before(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.before() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.after(LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.after() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + script.firstChild.remove(); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.remove() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.firstChild.replaceWith(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via CharacterData.replaceWith() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.appendChild(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Node.appendChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.insertBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.insertBefore() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.replaceChild(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.replaceChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + script.removeChild(script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via Node.removeChild() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.prepend(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.prepend() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.append(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.append() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.replaceChildren(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Element.replaceChildren() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.moveBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + container.appendChild(script); + }); + }, "Setting script source via ElementmoveBefore() drops trustworthiness."); + + promise_test(async t => { + await promise_rejects_js(t, TypeError, script_messages_for(_ => { + document.createElementNS(NSURI_SVG, "script").insertAdjacentHTML("afterbegin", LOG_RUN_MESSAGE); + }), "TrustedHTML required."); + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.insertAdjacentHTML("afterbegin", passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.insertAdjacentHTML("beforeend", passthroughpolicy.createHTML(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via TrustedHTML sink Node.insertAdjacentHTML() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.insertAdjacentText("afterbegin", LOG_RUN_MESSAGE); + container.appendChild(script); + }); + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + script.insertAdjacentText("beforeend", LOG_RUN_MESSAGE); + container.appendChild(script); + }); + }, "Setting script source via Node.insertAdjacentText() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_html_script_with_trusted_source_text(`;`); + let range = new Range(); + range.selectNode(script.firstChild); + range.insertNode(document.createTextNode(LOG_RUN_MESSAGE)); + container.appendChild(script); + }); + }, "Setting script source via Range.insertNode() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`//;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(2); + let range = new Range(); + range.setStart(script.firstChild, 0); + range.setEnd(script.lastChild, 3); + range.deleteContents(); + container.appendChild(script); + }); + }, "Setting script source via Range.deleteContents() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + let clone = script.cloneNode(true); + container.appendChild(clone); + }); + }, "Cloning a script via Node.cloneNode() drops trustworthiness."); + + promise_test(async t => { + await no_script_message_for(_ => { + let div = document.createElement("div"); + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + div.appendChild(script); + let range = new Range(); + range.selectNode(script); + let documentFragment = range.cloneContents(); + container.appendChild(documentFragment.firstElementChild); + }); + }, "Cloning a script via Range.cloneContents() drops trustworthiness."); +</script> +</body> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-004.html b/tests/wpt/tests/trusted-types/script-enforcement-004.html new file mode 100644 index 00000000000..86e1020c3ad --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-004.html @@ -0,0 +1,432 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +<!-- This test is similar to script-enforcement-002 but for the + SVGScriptElement, which has slightly different behavior: + - No equivalent to HTMLElement.innerText. + - No equivalent to HTMLScriptElement.text. + - innerHTML and textContent are not Trusted sinks. + - The HTML parser can insert elements inside the <script> tag. + - Sink name uses "SVGScriptElement". + --> +<svg> + <!-- Provide some static SVGScriptElements for use by + document.createElementNS(NSURI_SVG, "script"). See explanation in script-messages.js. --> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">;</script> + <script type="unknown">//;;;window.log_message("RUN")</script> + <script type="unknown">//;;;window.log_message("RUN")</script> + <script type="unknown">//window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")/////</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">;;;window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN");;;</script> + <script type="unknown">window.log_message("RUN");;;</script> + <script type="unknown">window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN")</script> + <script type="unknown">window.log_message("RUN")</script> +</svg> +<svg> + <script id="scriptForOuterHTMLTest" type="unknown"><g></g></script> +</svg> +<svg id="container"></svg> +<script> + trustedTypes.createPolicy("default", { + createHTML: (value, _, sink) => { + window.log_message("CREATE_HTML"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_HTML"); + }, + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return value.replace("RUN", "RUN_TRUSTED_SCRIPT"); + }, + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + window.log_message("SET"); + script.textContent = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via SVGScriptElement.textContent."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + window.log_message("SET"); + script.innerHTML = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element innerHTML", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.innerHTML."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.getElementById("scriptForOuterHTMLTest"); + script.remove(); + script.removeAttribute("type"); + window.log_message("SET"); + script.firstElementChild.outerHTML = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element outerHTML", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.outerHTML."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + window.log_message("SET"); + script.setHTMLUnsafe(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "CREATE_HTML", "Element setHTMLUnsafe", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Element.setHTMLUnsafe()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + window.log_message("SET"); + script.firstChild.splitText(3); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "RUN"]); + }, "Default policy when splitting script source via Text.splitText()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE};;;`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.normalize(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "RUN"]); + }, "Default policy when normalizing script source via Element.normalize()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.nodeValue = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.nodeValue."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.data = LOG_RUN_MESSAGE; + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.data."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.appendData(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.appendData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.insertData(0, LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.insertData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.replaceData(0, 0, LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.replaceData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`//${LOG_RUN_MESSAGE}`); + window.log_message("SET"); + script.firstChild.deleteData(0, 2); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.deleteData()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.before(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.before()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.after(LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.after()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.firstChild.remove(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.remove()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.firstChild.replaceWith(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via CharacterData.replaceWith()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.appendChild(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.appendChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.insertBefore()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.replaceChild(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.replaceChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(3); + window.log_message("SET"); + script.removeChild(script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.removeChild()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.prepend(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.prepend()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.append(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.append()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.replaceChildren(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.replaceChildren()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.moveBefore(document.createTextNode(LOG_RUN_MESSAGE), script.firstChild); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Element.moveBefore()."); + + promise_test(async t => { + let messages1 = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentText("afterbegin", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages1, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + let messages2 = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentText("beforeend", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages2, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Node.insertAdjacentText()."); + + promise_test(async t => { + let messages1 = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentHTML("afterbegin", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages1, ["SET", "CREATE_HTML", "Element insertAdjacentHTML", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + let messages2 = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(";"); + window.log_message("SET"); + script.insertAdjacentHTML("beforeend", LOG_RUN_MESSAGE); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages2, ["SET", "CREATE_HTML", "Element insertAdjacentHTML", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT_TRUSTED_HTML"]); + }, "Default policy's calls when setting script source via Node.insertAdjacentHTML()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_trusted_source_text(`;`); + let range = new Range(); + range.selectNode(script.firstChild); + window.log_message("SET"); + range.insertNode(document.createTextNode(LOG_RUN_MESSAGE)); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "HTMLScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting source via Range.insertNode()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`//;;;${LOG_RUN_MESSAGE}`); + script.firstChild.splitText(2); + let range = new Range(); + range.setStart(script.firstChild, 0); + range.setEnd(script.lastChild, 3); + window.log_message("SET"); + range.deleteContents(); + window.log_message("APPEND"); + container.appendChild(script); + }); + assert_array_equals(messages, ["SET", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when setting script source via Range.deleteContents()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + window.log_message("CLONE"); + let clone = script.cloneNode(true); + window.log_message("APPEND"); + container.appendChild(clone); + }); + assert_array_equals(messages, ["CLONE", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when cloning a script via Node.cloneNode()."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let div = document.createElement("div"); + let script = create_svg_script_with_trusted_source_text(`${LOG_RUN_MESSAGE}`); + div.appendChild(script); + let range = new Range(); + range.selectNode(script); + window.log_message("CLONE"); + let documentFragment = range.cloneContents(); + window.log_message("APPEND"); + container.appendChild(documentFragment.firstElementChild); + }); + assert_array_equals(messages, ["CLONE", "APPEND", "CREATE_SCRIPT", "SVGScriptElement text", "RUN_TRUSTED_SCRIPT"]); + }, "Default policy's calls when cloning a script via Range.cloneContents()."); +</script> +</body> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-005.html b/tests/wpt/tests/trusted-types/script-enforcement-005.html new file mode 100644 index 00000000000..77b1e6b03c6 --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-005.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://html.spec.whatwg.org/#prepare-the-script-element"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +<!-- This test covers the following step from the "prepare the script element" + algorithm, verifying that "source text" is the one after application of + the default policy: "If el has no src attribute, and source text is the + empty string, then return." --> +<div id="htmlContainer"> + <script id="scriptToCreateNonEmptyHTMLScript" type="unknown">;</script> +</div> +<svg id="svgContainer"> + <script id="scriptToCreateNonEmptySVGScript" type="unknown">;</script> +</svg> +<script> + // Define a default policy that transforms empty script string to some source + // logging a RUN message and other script strings to empty. + trustedTypes.createPolicy("default", { + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return value.length ? "" : LOG_RUN_MESSAGE; + } + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + // Current version of the specification requires the script text to change + // in order to force a call to the default policy callback with sink + // "HTMLScriptElement text". If the following PR is accepted, this could + // be simplified to create_html_script_with_untrusted_source_text(""). + // https://github.com/w3c/trusted-types/pull/579 + let script = document.getElementById("scriptToCreateNonEmptyHTMLScript"); + script.remove(); + script.removeAttribute("type"); + script.firstChild.remove(); + htmlContainer.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "RUN"]); + }, "Empty HTMLScriptElement is executed if the default policy makes it non-empty."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_untrusted_source_text(LOG_RUN_MESSAGE); + htmlContainer.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text"]); + + }, "Non-empty HTMLScriptElement is not executed if the default policy makes it empty."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + // Note: Using create_html_script_with_untrusted_source_text("") may not + // guarantee the script to be untrusted for implementations using a + // script-based enforcement mechanism. So make sure we do modify the text. + let script = document.getElementById("scriptToCreateNonEmptySVGScript"); + script.remove(); + script.removeAttribute("type"); + script.firstChild.remove(); + svgContainer.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "RUN"]); + }, "Empty SVGScriptElement is executed if the default policy makes it non-empty."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_untrusted_source_text(LOG_RUN_MESSAGE); + svgContainer.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text"]); + + }, "Non-empty SVGScriptElement is not executed if the default policy makes it empty."); +</script> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-006.html b/tests/wpt/tests/trusted-types/script-enforcement-006.html new file mode 100644 index 00000000000..7673a686f4e --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-006.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://html.spec.whatwg.org/#prepare-the-script-element"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'"> +<!-- This test covers the following step from the "prepare the script element" + algorithm, verifying that "source text" is the one after application of + the default policy: "If el does not have a src content attribute: ... + Switch on el's type:" --> +<div id="container"></div> +<script> + const logMessageModulePath = "./support/logMessage-module.sub.js"; + + // Define a default policy that transforms the script's type to some valid + // source content. + trustedTypes.createPolicy("default", { + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + switch (value) { + case "classic": + return `window.log_message('CLASSIC');`; + case "module": + return `window.log_message('MODULE');`; + case "importmap": + return `{ "imports": { "${logMessageModulePath}?message=UNMAPPED": "${logMessageModulePath}?message=IMPORTMAP" }}`; + } + } + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_untrusted_source_text("classic"); + script.setAttribute("type", "application/ecmascript"); + // Appending the script will log "CLASSIC". + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "CLASSIC"]); + }, "Untrusted HTMLScriptElement with classic type uses the source text returned by the default policy."); + + // Firefox disallows import map after a module load, so place this promise + // test before the module test. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1916277#c4 + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_html_script_with_untrusted_source_text("importmap"); + script.setAttribute("type", "importmap"); + + // Appending the script sets up an import map for logMessageModulePath. + container.appendChild(script); + + // Importing logMessageModulePath will log message "IMPORTMAP" + await import(`${logMessageModulePath}?message=UNMAPPED`); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "IMPORTMAP"]); + }, "Untrusted HTMLScriptElement of importmap type uses the source text returned by the default policy."); + + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_html_script_with_untrusted_source_text("module"); + script.setAttribute("type", "module"); + + // Appending the script will log message "MODULE" + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "MODULE"]); + }, "Untrusted HTMLScriptElement of module type uses the source text returned by the default policy."); +</script> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-007.html b/tests/wpt/tests/trusted-types/script-enforcement-007.html new file mode 100644 index 00000000000..34d3831ab74 --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-007.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://html.spec.whatwg.org/#prepare-the-script-element"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'"> +<!-- This is the same test as script-enforcement-006 but for SVGScriptElement. --> +<svg id="container"></svg> +<script> + const logMessageModulePath = "./support/logMessage-module.sub.js"; + + // Define a default policy that transforms the script's type to some valid + // source content. + trustedTypes.createPolicy("default", { + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + switch (value) { + case "classic": + return `window.log_message('CLASSIC');`; + case "module": + return `window.log_message('MODULE');`; + case "importmap": + return `{ "imports": { "${logMessageModulePath}?message=UNMAPPED": "${logMessageModulePath}?message=IMPORTMAP" }}`; + } + } + }); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_untrusted_source_text("classic"); + script.setAttribute("type", "application/ecmascript"); + // Appending the script will log "CLASSIC". + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "CLASSIC"]); + }, "Untrusted SVGScriptElement with classic type uses the source text returned by the default policy."); + + // Firefox disallows import map after a module load, so place this promise + // test before the module test. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1916277#c4 + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_svg_script_with_untrusted_source_text("importmap"); + script.setAttribute("type", "importmap"); + + // Appending the script sets up an import map for logMessageModulePath. + container.appendChild(script); + + // Importing logMessageModulePath will log message "IMPORTMAP". + await import(`${logMessageModulePath}?message=UNMAPPED`); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "IMPORTMAP"]); + }, "Untrusted SVGScriptElement of importmap type uses the source text returned by the default policy."); + + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_svg_script_with_untrusted_source_text("module"); + script.setAttribute("type", "module"); + + // Appending the script will log message "MODULE". + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "MODULE"]); + }, "Untrusted SVGScriptElement of module type uses the source text returned by the default policy."); +</script> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-008.https.html b/tests/wpt/tests/trusted-types/script-enforcement-008.https.html new file mode 100644 index 00000000000..86d9ec6985a --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-008.https.html @@ -0,0 +1,87 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://html.spec.whatwg.org/#prepare-the-script-element"> +<link rel="help" href="https://w3c.github.io/webappsec-csp/#should-block-inline"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'"> +<meta id="metaTagForScriptSrc" http-equiv="Content-Security-Policy" content="script-src 'nonce-script-messages' 'nonce-self' 'sha256-IpCtvKVFQbqDBhwCvQEsZoqgVXvAd6T2uRWd/Pz7FuI=' 'sha256-xanaWuoRdfLzI0+K8zpwr8eHi4RK2P6GglgCFXv0r00=' 'sha256-BPWjrQT1GMyyQ+6Fmycn7pSqh8L945ToMJ/nfGClLBc='"> +<!-- This test covers the following step from the "prepare the script element" + algorithm, verifying that "source text" is the one after application of + the default policy: "If el does not have a src content attribute, and the + Should element's inline behavior be blocked by Content Security Policy? + algorithm returns "Blocked" when given el, "script", and source text, then + return." --> +<div id="container"></div> +<script nonce="self"> + const logMessageModulePath = "./support/logMessage-module.sub.js"; + + // Define a default policy that transforms the script's type to some valid + // source content. + function scriptTypeToValue(value) { + switch (value) { + case "classic": + return `window.log_message('CLASSIC');`; + case "module": + return `window.log_message('MODULE');`; + case "importmap": + return `{ "imports": { "${logMessageModulePath}?message=UNMAPPED": "${logMessageModulePath}?message=IMPORTMAP" }}`; + } + } + trustedTypes.createPolicy("default", { + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return scriptTypeToValue(value); + } + }); + + promise_test(async t => { + let classicHash = await base64_hash_for_inline_script(scriptTypeToValue("classic"), "SHA-256"); + let moduleHash = await base64_hash_for_inline_script(scriptTypeToValue("module"), "SHA-256"); + let importmapHash = await base64_hash_for_inline_script(scriptTypeToValue("importmap"), "SHA-256"); + let metaTagContent = document.getElementById("metaTagForScriptSrc").getAttribute("content"); + assert_equals(metaTagContent, `script-src 'nonce-script-messages' 'nonce-self' 'sha256-${classicHash}' 'sha256-${moduleHash}' 'sha256-${importmapHash}'`); + }, "script-src CSP directive is properly set."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_html_script_with_untrusted_source_text("classic"); + script.setAttribute("type", "application/ecmascript"); + // Appending the script will log "CLASSIC". + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "CLASSIC"]); + }, "Untrusted HTMLScriptElement with classic type uses the source text returned by the default policy for inline CSP check."); + + // Firefox disallows import map after a module load, so place this promise + // test before the module test. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1916277#c4 + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_html_script_with_untrusted_source_text("importmap"); + script.setAttribute("type", "importmap"); + + // Appending the script sets up an import map for logMessageModulePath. + container.appendChild(script); + + // Importing logMessageModulePath will log message "IMPORTMAP" + await import(`${logMessageModulePath}?message=UNMAPPED`); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "IMPORTMAP"]); + }, "Untrusted HTMLScriptElement of importmap type uses the source text returned by the default policy for inline CSP check."); + + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_html_script_with_untrusted_source_text("module"); + script.setAttribute("type", "module"); + + // Appending the script will log message "MODULE" + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "HTMLScriptElement text", "MODULE"]); + }, "Untrusted HTMLScriptElement of module type uses the source text returned by the default policy for inline CSP check."); +</script> diff --git a/tests/wpt/tests/trusted-types/script-enforcement-009.https.html b/tests/wpt/tests/trusted-types/script-enforcement-009.https.html new file mode 100644 index 00000000000..45f21b41eda --- /dev/null +++ b/tests/wpt/tests/trusted-types/script-enforcement-009.https.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/passthroughpolicy.js"></script> +<script src="support/script-messages.js"></script> +<link rel="help" href="https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts"> +<link rel="help" href="https://html.spec.whatwg.org/#prepare-the-script-element"> +<link rel="help" href="https://w3c.github.io/webappsec-csp/#should-block-inline"> +<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'"> +<meta id="metaTagForScriptSrc" http-equiv="Content-Security-Policy" content="script-src 'nonce-script-messages' 'nonce-self' 'sha256-IpCtvKVFQbqDBhwCvQEsZoqgVXvAd6T2uRWd/Pz7FuI=' 'sha256-xanaWuoRdfLzI0+K8zpwr8eHi4RK2P6GglgCFXv0r00=' 'sha256-BPWjrQT1GMyyQ+6Fmycn7pSqh8L945ToMJ/nfGClLBc='"> +<!-- This is the same test as script-enforcement-008 but for SVGScriptElement. --> +<svg id="container"></svg> +<script nonce="self"> + const logMessageModulePath = "./support/logMessage-module.sub.js"; + + // Define a default policy that transforms the script's type to some valid + // source content. + function scriptTypeToValue(value) { + switch (value) { + case "classic": + return `window.log_message('CLASSIC');`; + case "module": + return `window.log_message('MODULE');`; + case "importmap": + return `{ "imports": { "${logMessageModulePath}?message=UNMAPPED": "${logMessageModulePath}?message=IMPORTMAP" }}`; + } + } + trustedTypes.createPolicy("default", { + createScript: (value, _, sink) => { + window.log_message("CREATE_SCRIPT"); + window.log_message(sink); + return scriptTypeToValue(value); + } + }); + + promise_test(async t => { + let classicHash = await base64_hash_for_inline_script(scriptTypeToValue("classic"), "SHA-256"); + let moduleHash = await base64_hash_for_inline_script(scriptTypeToValue("module"), "SHA-256"); + let importmapHash = await base64_hash_for_inline_script(scriptTypeToValue("importmap"), "SHA-256"); + let metaTagContent = document.getElementById("metaTagForScriptSrc").getAttribute("content"); + assert_equals(metaTagContent, `script-src 'nonce-script-messages' 'nonce-self' 'sha256-${classicHash}' 'sha256-${moduleHash}' 'sha256-${importmapHash}'`); + }, "script-src CSP directive is properly set."); + + promise_test(async t => { + let messages = await script_messages_for(_ => { + let script = create_svg_script_with_untrusted_source_text("classic"); + script.setAttribute("type", "application/ecmascript"); + // Appending the script will log "CLASSIC". + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "CLASSIC"]); + }, "Untrusted SVGScriptElement with classic type uses the source text returned by the default policy for inline CSP check."); + + // Firefox disallows import map after a module load, so place this promise + // test before the module test. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1916277#c4 + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_svg_script_with_untrusted_source_text("importmap"); + script.setAttribute("type", "importmap"); + + // Appending the script sets up an import map for logMessageModulePath. + container.appendChild(script); + + // Importing logMessageModulePath will log message "IMPORTMAP" + await import(`${logMessageModulePath}?message=UNMAPPED`); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "IMPORTMAP"]); + }, "Untrusted SVGScriptElement of importmap type uses the source text returned by the default policy for inline CSP check."); + + promise_test(async t => { + let messages = await script_messages_for(async _ => { + let script = create_svg_script_with_untrusted_source_text("module"); + script.setAttribute("type", "module"); + + // Appending the script will log message "MODULE" + container.appendChild(script); + }); + assert_array_equals(messages, ["CREATE_SCRIPT", "SVGScriptElement text", "MODULE"]); + }, "Untrusted SVGScriptElement of module type uses the source text returned by the default policy for inline CSP check."); +</script> diff --git a/tests/wpt/tests/trusted-types/support/csp-violations.js b/tests/wpt/tests/trusted-types/support/csp-violations.js index 46c2ca1b30f..bc38da9e221 100644 --- a/tests/wpt/tests/trusted-types/support/csp-violations.js +++ b/tests/wpt/tests/trusted-types/support/csp-violations.js @@ -5,6 +5,8 @@ const cspDirectives = [ "trusted-types", // https://w3c.github.io/webappsec-csp/#script-src "script-src", + // https://w3c.github.io/webappsec-csp/#directive-script-src-elem + "script-src-elem", ]; // A generic helper that runs function fn and returns a promise resolving with diff --git a/tests/wpt/tests/trusted-types/support/logMessage-module.sub.js b/tests/wpt/tests/trusted-types/support/logMessage-module.sub.js new file mode 100644 index 00000000000..e886bd54b31 --- /dev/null +++ b/tests/wpt/tests/trusted-types/support/logMessage-module.sub.js @@ -0,0 +1 @@ +window.log_message("{{GET[message]}}"); diff --git a/tests/wpt/tests/trusted-types/support/passthroughpolicy.js b/tests/wpt/tests/trusted-types/support/passthroughpolicy.js new file mode 100644 index 00000000000..efe3ea62c0d --- /dev/null +++ b/tests/wpt/tests/trusted-types/support/passthroughpolicy.js @@ -0,0 +1,7 @@ +'use strict' + +const passthroughpolicy = trustedTypes.createPolicy("passthroughpolicy", { + createHTML: s => s, + createScript: s => s, + createScriptURL: s => s, +}); diff --git a/tests/wpt/tests/trusted-types/support/script-messages.js b/tests/wpt/tests/trusted-types/support/script-messages.js new file mode 100644 index 00000000000..ad4138be25b --- /dev/null +++ b/tests/wpt/tests/trusted-types/support/script-messages.js @@ -0,0 +1,104 @@ +'use strict' + +const LOG_RUN_MESSAGE = `window.log_message("RUN")`; + +function create_html_script_with_trusted_source_text(source_text) { + let script = document.createElement("script"); + script.text = passthroughpolicy.createScript(source_text); + return script; +} + +function create_html_script_with_untrusted_source_text(source_text) { + let script = document.createElement("script"); + // Setting script source via Node.appendChild() drops trustworthiness. + script.appendChild(document.createTextNode(source_text)); + return script; +} + +function create_svg_script_with_trusted_source_text(source_text) { + // SVGScriptElement has no API to set its source while preserving its + // trustworthiness. For now, we just expect a <script type="unknown"> tag + // with the desired source to already be present in the page, so we can just + // reuse it. See https://github.com/w3c/trusted-types/issues/512 + let script = + Array.from(document.querySelectorAll("svg script[type='unknown']")). + find(script => script.textContent === source_text); + assert_true(!!script, `<script type="unknown">${source_text}</script> not found!`); + script.remove(); + script.removeAttribute("type"); + return script; +} + +function create_svg_script_with_untrusted_source_text(source_text) { + let script = document.createElementNS(NSURI_SVG, "script") + // Setting script source via Node.appendChild() drops trustworthiness. + script.appendChild(document.createTextNode(source_text)); + return script; +} + +// A generic helper that runs function fn and returns a promise resolving with +// an array of received messages. A script forcing a "done" message is appended +// after calling fn, to make sure that all the messages reported by fn have been +// delivered. +function script_messages_for(fn) { + return new Promise(async (resolve, reject) => { + // Listen for messages. + let messages = []; + let exception = null; + window.log_message = message => { + if (message === "DONE") { + window.log_message = null; + if (exception) { + reject(exception); + } else { + resolve(messages); + } + } else { + messages.push(message); + } + }; + + // Execute the function. + try { + await fn(); + } catch(e) { + exception = e; + } + + // Indicate the last message. + // This is done by appending an inline script to make sure it is executed + // after processing any previously inserted inline script. Additionally, we + // delay by a double requestAnimationFrame to work around incompatible + // interop bugs: + // - WebKit/Chromium seems to give lower priority to module, so it looks + // like the appended script should have type="module" here to work with + // tests for inline modules. + // - but Firefox does not allow type="importmaps" after a type="module" so + // making the appended script a module would make importmap tests fail... + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1916277#c4 + requestAnimationFrame(_ => requestAnimationFrame(_ => { + let script = create_html_script_with_trusted_source_text(`window.log_message("DONE")`); + script.setAttribute("nonce", "script-messages"); + document.body.appendChild(script); + })); + }); +} + +async function script_message_for(fn) { + let messages = await script_messages_for(fn); + assert_equals(messages.length, 1, `Number of messages (${messages})`); + return messages[0]; +} + +async function no_script_message_for(fn) { + let messages = await script_messages_for(fn); + assert_equals(messages.length, 0, `Number of messages (${messages})`); +} + +async function base64_hash_for_inline_script(source_text, algorithm) { + const encoder = new TextEncoder(); + const data = encoder.encode(source_text); + const hashBuffer = await window.crypto.subtle.digest(algorithm, data); + const base64Array = (new Uint8Array(hashBuffer)).toBase64(); + return base64Array.toString(); +} diff --git a/tests/wpt/tests/trusted-types/trusted-types-reporting-for-HTMLScriptElement-children-change.html b/tests/wpt/tests/trusted-types/trusted-types-reporting-for-HTMLScriptElement-children-change.html new file mode 100644 index 00000000000..c006bc2315f --- /dev/null +++ b/tests/wpt/tests/trusted-types/trusted-types-reporting-for-HTMLScriptElement-children-change.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/csp-violations.js"></script> +<meta http-equiv="Content-Security-Policy" + content="require-trusted-types-for 'script'; connect-src 'none';"> +<meta http-equiv="Content-Security-Policy" content="script-src 'nonce-self'"> +<div id="container"></div> +<script nonce="self"> + const originalSource = `${';'.repeat(100)}`; + promise_test(async t => { + let violation = await trusted_type_violation_without_exception_for(_ => { + let script = document.createElement("script"); + script.setAttribute("nonce", "self"); + + // Node.appendChild() makes the script text untrusted. + script.appendChild(document.createTextNode(originalSource)); + document.body.appendChild(script); + }); + assert_equals(violation.blockedURI, "trusted-types-sink"); + assert_equals(violation.sample, `HTMLScriptElement text|${clipSampleIfNeeded(originalSource)}`); + }, `sink mismatch violation report when the script text is changed by manipulating its children.`); + + + promise_test(async t => { + const sourceAfterApplicationOfDefaultPolicy = `${';'.repeat(100)}`; + trustedTypes.createPolicy("default", { + createScript: value => sourceAfterApplicationOfDefaultPolicy, + }); + let violation = await trusted_type_violation_without_exception_for(async _ => { + let script = document.createElement("script"); + + // Node.appendChild() makes the script text untrusted. + script.appendChild(document.createTextNode(originalSource)); + document.body.appendChild(script); + }); + assert_equals(violation.effectiveDirective, "script-src-elem"); + assert_equals(violation.blockedURI, "inline"); + assert_equals(violation.sample, ""); + assert_equals(violation.originalPolicy, "script-src 'nonce-self'"); + }, `inline check violation report when the script text is changed by manipulating its children.`); +</script> diff --git a/tests/wpt/tests/trusted-types/trusted-types-reporting-for-SVGScriptElement-children-change.html b/tests/wpt/tests/trusted-types/trusted-types-reporting-for-SVGScriptElement-children-change.html new file mode 100644 index 00000000000..c187971f726 --- /dev/null +++ b/tests/wpt/tests/trusted-types/trusted-types-reporting-for-SVGScriptElement-children-change.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/namespaces.js"></script> +<script src="support/csp-violations.js"></script> +<meta http-equiv="Content-Security-Policy" + content="require-trusted-types-for 'script'; connect-src 'none';"> +<meta http-equiv="Content-Security-Policy" content="script-src 'nonce-self'"> +<svg id="container"></svg> +<script nonce="self"> + const originalSource = `${';'.repeat(100)}`; + promise_test(async t => { + let violation = await trusted_type_violation_without_exception_for(_ => { + let script = document.createElementNS(NSURI_SVG, "script"); + script.setAttribute("nonce", "self"); + + // Node.appendChild() makes the script text untrusted. + script.appendChild(document.createTextNode(originalSource)); + document.body.appendChild(script); + }); + assert_equals(violation.blockedURI, "trusted-types-sink"); + assert_equals(violation.sample, `SVGScriptElement text|${clipSampleIfNeeded(originalSource)}`); + }, `sink mismatch violation report when the script text is changed by manipulating its children.`); + + promise_test(async t => { + const sourceAfterApplicationOfDefaultPolicy = `${';'.repeat(100)}`; + trustedTypes.createPolicy("default", { + createScript: value => sourceAfterApplicationOfDefaultPolicy, + }); + let violation = await trusted_type_violation_without_exception_for(async _ => { + let script = document.createElementNS(NSURI_SVG, "script"); + + // Node.appendChild() makes the script text untrusted. + script.appendChild(document.createTextNode(originalSource)); + document.body.appendChild(script); + }); + assert_equals(violation.effectiveDirective, "script-src-elem"); + assert_equals(violation.blockedURI, "inline"); + assert_equals(violation.sample, ""); + assert_equals(violation.originalPolicy, "script-src 'nonce-self'"); + }, `inline check violation report when the script text is changed by manipulating its children.`); +</script> diff --git a/tests/wpt/tests/uievents/order-of-events/focus-events/focus-management-expectations.html b/tests/wpt/tests/uievents/order-of-events/focus-events/focus-management-expectations.html index 1845c15d716..65fe639e958 100644 --- a/tests/wpt/tests/uievents/order-of-events/focus-events/focus-management-expectations.html +++ b/tests/wpt/tests/uievents/order-of-events/focus-events/focus-management-expectations.html @@ -32,10 +32,10 @@ let buttonFocused = false to.addEventListener("click", t.unreached_func("Button should not be clicked")) to.addEventListener("focus", () => buttonFocused = true) - endTest.addEventListener('click', () => { + endTest.addEventListener('click', t.step_func(() => { assert_true(buttonFocused, "Button should be focused") t.step_timeout(() => t.done(), 200) - }) + })) // execute test from.focus() diff --git a/tests/wpt/tests/web-animations/interfaces/Animation/style-change-events.html b/tests/wpt/tests/web-animations/interfaces/Animation/style-change-events.html index c64400e869d..d1c1c96f7b0 100644 --- a/tests/wpt/tests/web-animations/interfaces/Animation/style-change-events.html +++ b/tests/wpt/tests/web-animations/interfaces/Animation/style-change-events.html @@ -306,13 +306,6 @@ const tests = { ), }); }, - trigger: UsePropertyTest(animation => { - // Get the trigger property. - animation.trigger; - - // Set the trigger property. - animation.trigger = new AnimationTrigger(); - }) }; // Check that each enumerable property and the constructor follow the diff --git a/tests/wpt/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html b/tests/wpt/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html index a2c4581c4e8..115e8aff1ac 100644 --- a/tests/wpt/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html +++ b/tests/wpt/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html @@ -1,71 +1,65 @@ <!DOCTYPE html> <html> - <head> - <title> - audiobuffer.html - </title> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <script src="/webaudio/resources/audit-util.js"></script> - <script src="/webaudio/resources/audit.js"></script> - </head> - <body> - <script id="layout-test-code"> - let sampleRate = 44100.0 - let lengthInSeconds = 2; - let numberOfChannels = 4; +<head> + <title>AudioBuffer API Test</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <script> + const sampleRate = 44100.0; + const lengthInSeconds = 2; + const numberOfChannels = 4; - let audit = Audit.createTaskRunner(); - - audit.define('Basic tests for AudioBuffer', function(task, should) { - let context = new AudioContext(); - let buffer = context.createBuffer( - numberOfChannels, sampleRate * lengthInSeconds, sampleRate); - - // Just for printing out a message describing what "buffer" is in the - // following tests. - should( - true, - 'buffer = context.createBuffer(' + numberOfChannels + ', ' + - (sampleRate * lengthInSeconds) + ', ' + sampleRate + ')') - .beTrue(); - - should(buffer.sampleRate, 'buffer.sampleRate').beEqualTo(sampleRate); - - should(buffer.length, 'buffer.length') - .beEqualTo(sampleRate * lengthInSeconds); - - should(buffer.duration, 'buffer.duration').beEqualTo(lengthInSeconds); + test(() => { + const buffer = new AudioBuffer({ + numberOfChannels, + length: sampleRate * lengthInSeconds, + sampleRate + }); - should(buffer.numberOfChannels, 'buffer.numberOfChannels') - .beEqualTo(numberOfChannels); + assert_true( + true, + `buffer = new AudioBuffer({numberOfChannels: ${numberOfChannels}, ` + + `length: ${sampleRate * lengthInSeconds}, ` + + `sampleRate: ${sampleRate}})`); - for (let index = 0; index < buffer.numberOfChannels; ++index) { - should( - buffer.getChannelData(index) instanceof window.Float32Array, - 'buffer.getChannelData(' + index + - ') instanceof window.Float32Array') - .beTrue(); - } + assert_equals(buffer.sampleRate, sampleRate, 'buffer.sampleRate'); + assert_equals( + buffer.length, sampleRate * lengthInSeconds, 'buffer.length'); + assert_equals(buffer.duration, lengthInSeconds, 'buffer.duration'); + assert_equals( + buffer.numberOfChannels, numberOfChannels, 'buffer.numberOfChannels'); - should( - function() { - buffer.getChannelData(buffer.numberOfChannels); - }, - 'buffer.getChannelData(' + buffer.numberOfChannels + ')') - .throw(DOMException, 'IndexSizeError'); + for (let i = 0; i < buffer.numberOfChannels; ++i) { + assert_true( + buffer.getChannelData(i) instanceof Float32Array, + `buffer.getChannelData(${i}) instanceof Float32Array`); + } - let buffer2 = context.createBuffer(1, 1000, 24576); - let expectedDuration = 1000 / 24576; + assert_throws_dom( + 'IndexSizeError', + () => buffer.getChannelData(buffer.numberOfChannels), + `buffer.getChannelData(${buffer.numberOfChannels}) throws`); - should( - buffer2.duration, 'context.createBuffer(1, 1000, 24576).duration') - .beEqualTo(expectedDuration); + // Non-standard values (1000 & 24576) to test edge-case duration behavior. + const testSampleRate = 24576; + const testLength = 1000; - task.done(); + const buffer2 = new AudioBuffer({ + numberOfChannels: 1, + length: testLength, + sampleRate: testSampleRate }); - audit.run(); - </script> - </body> + const expectedDuration = testLength / testSampleRate; + + assert_equals( + buffer2.duration, + expectedDuration, + 'new AudioBuffer({numberOfChannels: 1,\n' + + `length: ${testLength},sampleRate: ${testSampleRate}}).duration`); + }, 'AudioBuffer: creation and property validation'); + </script> +</body> </html> diff --git a/tests/wpt/tests/webdriver/tests/bidi/browser/create_user_context/invalid.py b/tests/wpt/tests/webdriver/tests/bidi/browser/create_user_context/invalid.py index 9af6cdd5232..01a2ce1d083 100644 --- a/tests/wpt/tests/webdriver/tests/bidi/browser/create_user_context/invalid.py +++ b/tests/wpt/tests/webdriver/tests/bidi/browser/create_user_context/invalid.py @@ -66,3 +66,107 @@ async def test_proxy_proxy_type_manual_socks_proxy_without_socks_version( "proxyType": "manual", "socksProxy": "127.0.0.1:1080" }) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_proxy_ftp_proxy_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "ftpProxy": value}) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_proxy_http_proxy_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "httpProxy": value}) + + +@pytest.mark.parametrize("value", [ + "http://foo", + "foo:-1", + "foo:65536", + "foo/test", + "foo#42", + "foo?foo=bar", + "2001:db8::1", +]) +async def test_params_proxy_http_proxy_invalid_value(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "httpProxy": value}) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_proxy_ssl_proxy_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "sslProxy": value}) + + +@pytest.mark.parametrize("value", [ + "https://foo", + "foo:-1", + "foo:65536", + "foo/test", + "foo#42", + "foo?foo=bar", + "2001:db8::1", +]) +async def test_params_proxy_ssl_proxy_invalid_value(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "sslProxy": value}) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_proxy_socks_proxy_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context( + proxy={"proxyType": "manual", "socksProxy": value, "socksVersion": 4} + ) + + +@pytest.mark.parametrize("value", [ + "https://foo", + "foo:-1", + "foo:65536", + "foo/test", + "foo#42", + "foo?foo=bar", + "2001:db8::1", +]) +async def test_params_proxy_socks_proxy_invalid_value(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "socksProxy": value}) + + +@pytest.mark.parametrize("value", ["foo", True, [], {}]) +async def test_params_socks_version_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context( + proxy={"proxyType": "manual", "socksProxy": "foo:1", "socksVersion": value} + ) + + +@pytest.mark.parametrize("value", [42, True, "foo", {}]) +async def test_params_no_proxy_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "noProxy": value}) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_no_proxy_element_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context(proxy={"proxyType": "manual", "noProxy": [value]}) + + +@pytest.mark.parametrize("value", [42, True, [], {}, None]) +async def test_params_autoconfig_url_invalid_type(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context( + proxy={"proxyType": "pac", "proxyAutoconfigUrl": value} + ) + + +@pytest.mark.parametrize("value", [42, True, [], {}]) +async def test_params_autoconfig_missing(create_user_context, value): + with pytest.raises(error.InvalidArgumentException): + await create_user_context( + proxy={"proxyType": "pac"} + ) diff --git a/tests/wpt/tests/webdriver/tests/bidi/browsing_context/fragment_navigated/fragment_navigated.py b/tests/wpt/tests/webdriver/tests/bidi/browsing_context/fragment_navigated/fragment_navigated.py index 45a65cacdf0..57680c5f630 100644 --- a/tests/wpt/tests/webdriver/tests/bidi/browsing_context/fragment_navigated/fragment_navigated.py +++ b/tests/wpt/tests/webdriver/tests/bidi/browsing_context/fragment_navigated/fragment_navigated.py @@ -143,6 +143,16 @@ async def test_iframe( await subscribe_events([FRAGMENT_NAVIGATED_EVENT]) + # Track all received browsingContext.fragmentNavigated events in the events array + events = [] + + async def on_event(method, data): + events.append(data) + + remove_listener = bidi_session.add_event_listener( + FRAGMENT_NAVIGATED_EVENT, on_event + ) + on_fragment_navigated = wait_for_event(FRAGMENT_NAVIGATED_EVENT) target_url = url(EMPTY_PAGE + '#bar') @@ -158,6 +168,10 @@ async def test_iframe( await wait_for_future_safe(on_fragment_navigated), ) + # Check that we only received one event for the iframe navigation. + assert len(events) == 1 + remove_listener() + @pytest.mark.parametrize( "hash_before, hash_after", diff --git a/tests/wpt/tests/webdriver/tests/bidi/browsing_context/history_updated/history_updated.py b/tests/wpt/tests/webdriver/tests/bidi/browsing_context/history_updated/history_updated.py index 9fbb0f26c9e..6ad4bd22b32 100644 --- a/tests/wpt/tests/webdriver/tests/bidi/browsing_context/history_updated/history_updated.py +++ b/tests/wpt/tests/webdriver/tests/bidi/browsing_context/history_updated/history_updated.py @@ -4,7 +4,7 @@ from webdriver.bidi.modules.script import ContextTarget from webdriver.error import TimeoutException from tests.support.sync import AsyncPoll -from ... import recursive_compare +from ... import any_int, int_interval, recursive_compare pytestmark = pytest.mark.asyncio @@ -13,6 +13,7 @@ FRAGMENT_NAVIGATED_EVENT = "browsingContext.fragmentNavigated" HISTORY_UPDATED_EVENT = "browsingContext.historyUpdated" CREATED_EVENT = "browsingContext.contextCreated" + @pytest.mark.parametrize( "hash_before, hash_after, history_method", [ @@ -24,10 +25,17 @@ CREATED_EVENT = "browsingContext.contextCreated" ("#foo", "#bar", "replaceState"), ("#foo", "#foo", "replaceState"), ("#bar", "", "replaceState"), - ] + ], ) async def test_history_url_update( - bidi_session, new_tab, url, subscribe_events, hash_before, hash_after, history_method + bidi_session, + new_tab, + url, + subscribe_events, + current_time, + hash_before, + hash_after, + history_method, ): target_context = new_tab["context"] @@ -39,43 +47,54 @@ async def test_history_url_update( fragment_navigated_events = [] history_updated_events = [] + async def on_event(method, data): if method == FRAGMENT_NAVIGATED_EVENT: - fragment_navigated_events.append(data) + fragment_navigated_events.append(data) if method == HISTORY_UPDATED_EVENT: - history_updated_events.append(data) + history_updated_events.append(data) - remove_fragment_navigated_listener = bidi_session.add_event_listener(FRAGMENT_NAVIGATED_EVENT, on_event) - remove_history_updated_listener = bidi_session.add_event_listener(HISTORY_UPDATED_EVENT, on_event) + remove_fragment_navigated_listener = bidi_session.add_event_listener( + FRAGMENT_NAVIGATED_EVENT, on_event + ) + remove_history_updated_listener = bidi_session.add_event_listener( + HISTORY_UPDATED_EVENT, on_event + ) try: - target_url = url(EMPTY_PAGE + hash_after) - - await bidi_session.script.call_function( - raw_result=True, - function_declaration="""(method, url) => { - history[method](null, null, url); - }""", - arguments=[ - {"type": "string", "value": history_method}, - {"type": "string", "value": target_url}, - ], - await_promise=False, - target=ContextTarget(target_context), - ) - - recursive_compare( - [{ - 'context': target_context, - 'url': target_url - }], - history_updated_events - ) - - assert len(fragment_navigated_events) == 0 + target_url = url(EMPTY_PAGE + hash_after) + + await bidi_session.script.call_function( + raw_result=True, + function_declaration="""(method, url) => { + history[method](null, null, url); + }""", + arguments=[ + {"type": "string", "value": history_method}, + {"type": "string", "value": target_url}, + ], + await_promise=False, + target=ContextTarget(target_context), + ) + + recursive_compare( + [ + { + "context": target_context, + "timestamp": any_int, + "url": target_url, + } + ], + history_updated_events, + ) + + # browsingContext.historyUpdated should not contain any navigation id. + assert "navigation" not in history_updated_events[0] + + assert len(fragment_navigated_events) == 0 finally: - remove_fragment_navigated_listener() - remove_history_updated_listener() + remove_fragment_navigated_listener() + remove_history_updated_listener() @pytest.mark.parametrize( @@ -83,7 +102,7 @@ async def test_history_url_update( [ ("pushState"), ("replaceState"), - ] + ], ) async def test_history_state_update( bidi_session, new_tab, url, subscribe_events, history_method @@ -99,45 +118,44 @@ async def test_history_state_update( fragment_navigated_events = [] history_updated_events = [] + async def on_event(method, data): if method == FRAGMENT_NAVIGATED_EVENT: - fragment_navigated_events.append(data) + fragment_navigated_events.append(data) if method == HISTORY_UPDATED_EVENT: - history_updated_events.append(data) + history_updated_events.append(data) - remove_fragment_navigated_listener = bidi_session.add_event_listener(FRAGMENT_NAVIGATED_EVENT, on_event) - remove_history_updated_listener = bidi_session.add_event_listener(HISTORY_UPDATED_EVENT, on_event) + remove_fragment_navigated_listener = bidi_session.add_event_listener( + FRAGMENT_NAVIGATED_EVENT, on_event + ) + remove_history_updated_listener = bidi_session.add_event_listener( + HISTORY_UPDATED_EVENT, on_event + ) try: - await bidi_session.script.call_function( - raw_result=True, - function_declaration="""(method) => { - history[method]({}, null); - }""", - arguments=[ - {"type": "string", "value": history_method}, - ], - await_promise=False, - target=ContextTarget(target_context), - ) - - recursive_compare( - [{ - 'context': target_context, - 'url': target_url - }], - history_updated_events - ) - - assert len(fragment_navigated_events) == 0 + await bidi_session.script.call_function( + raw_result=True, + function_declaration="""(method) => { + history[method]({}, null); + }""", + arguments=[ + {"type": "string", "value": history_method}, + ], + await_promise=False, + target=ContextTarget(target_context), + ) + + recursive_compare( + [{"context": target_context, "url": target_url}], history_updated_events + ) + + assert len(fragment_navigated_events) == 0 finally: - remove_fragment_navigated_listener() - remove_history_updated_listener() + remove_fragment_navigated_listener() + remove_history_updated_listener() -async def test_history_document_open( - bidi_session, new_tab, url, subscribe_events -): +async def test_history_document_open(bidi_session, new_tab, url, subscribe_events): target_context = new_tab["context"] target_url = url(EMPTY_PAGE) @@ -145,30 +163,34 @@ async def test_history_document_open( context=new_tab["context"], url=target_url, wait="complete" ) - await subscribe_events([FRAGMENT_NAVIGATED_EVENT, HISTORY_UPDATED_EVENT, CREATED_EVENT]) + await subscribe_events( + [FRAGMENT_NAVIGATED_EVENT, HISTORY_UPDATED_EVENT, CREATED_EVENT] + ) fragment_navigated_events = [] history_updated_events = [] browsing_context_created_events = [] - async def on_event(method, data): if method == FRAGMENT_NAVIGATED_EVENT: - fragment_navigated_events.append(data) + fragment_navigated_events.append(data) if method == HISTORY_UPDATED_EVENT: - history_updated_events.append(data) + history_updated_events.append(data) if method == CREATED_EVENT: - browsing_context_created_events.append(data) - + browsing_context_created_events.append(data) - remove_fragment_navigated_listener = bidi_session.add_event_listener(FRAGMENT_NAVIGATED_EVENT, on_event) - remove_history_updated_listener = bidi_session.add_event_listener(HISTORY_UPDATED_EVENT, on_event) + remove_fragment_navigated_listener = bidi_session.add_event_listener( + FRAGMENT_NAVIGATED_EVENT, on_event + ) + remove_history_updated_listener = bidi_session.add_event_listener( + HISTORY_UPDATED_EVENT, on_event + ) remove_created_listener = bidi_session.add_event_listener(CREATED_EVENT, on_event) try: - await bidi_session.script.call_function( - raw_result=True, - function_declaration="""() => { + await bidi_session.script.call_function( + raw_result=True, + function_declaration="""() => { const frame = document.createElement("iframe"); document.body.append(frame); frame.contentDocument.open(); @@ -180,37 +202,144 @@ async def test_history_document_open( window.location.hash = "heya"; }); }""", - await_promise=True, - target=ContextTarget(target_context), - ) - - recursive_compare( - [{ - 'url': 'about:blank' - }], - browsing_context_created_events - ) - - recursive_compare( - [{ - 'context': target_context, - 'url': target_url + '#heya' - }], - fragment_navigated_events - ) - - # History updated URL should match the target_context's URL - # without the fragment per - # https://html.spec.whatwg.org/#document-open-steps step 12.2. - recursive_compare( - [{ - 'context': browsing_context_created_events[0]['context'], - 'url': target_url - }], - history_updated_events - ) + await_promise=True, + target=ContextTarget(target_context), + ) + + recursive_compare([{"url": "about:blank"}], browsing_context_created_events) + + recursive_compare( + [{"context": target_context, "url": target_url + "#heya"}], + fragment_navigated_events, + ) + + # History updated URL should match the target_context's URL + # without the fragment per + # https://html.spec.whatwg.org/#document-open-steps step 12.2. + recursive_compare( + [ + { + # This event is for the first document.open before setting the + # location hash, per spec it should be set to the parent's document + # url. + "context": browsing_context_created_events[0]["context"], + "url": target_url, + }, + { + # This is for the second document.open, after setting the hash. + # Again this should be set to target_url since the fragment should not + # be included. + "context": browsing_context_created_events[0]["context"], + "url": target_url, + }, + ], + history_updated_events, + ) + + finally: + remove_fragment_navigated_listener() + remove_history_updated_listener() + remove_created_listener() + + +async def test_history_back_forward( + bidi_session, new_tab, url, subscribe_events, wait_for_event, wait_for_future_safe +): + target_context = new_tab["context"] + + target_url = url(EMPTY_PAGE) + await bidi_session.browsing_context.navigate( + context=new_tab["context"], url=target_url, wait="complete" + ) + + await subscribe_events([FRAGMENT_NAVIGATED_EVENT, HISTORY_UPDATED_EVENT]) + + fragment_navigated_events = [] + history_updated_events = [] + + async def on_event(method, data): + if method == FRAGMENT_NAVIGATED_EVENT: + fragment_navigated_events.append(data) + elif method == HISTORY_UPDATED_EVENT: + history_updated_events.append(data) + + remove_fragment_navigated_listener = bidi_session.add_event_listener( + FRAGMENT_NAVIGATED_EVENT, on_event + ) + remove_history_updated_listener = bidi_session.add_event_listener( + HISTORY_UPDATED_EVENT, on_event + ) + try: + await bidi_session.script.evaluate( + expression=""" + history.pushState({}, "", "test1.html"); + history.pushState({}, "", "test2.html"); + """, + await_promise=False, + target=ContextTarget(target_context), + ) + + assert len(history_updated_events) == 2 + assert len(fragment_navigated_events) == 0 + + on_entry = wait_for_event(HISTORY_UPDATED_EVENT) + await bidi_session.script.evaluate( + expression="history.back();", + await_promise=False, + target=ContextTarget(target_context), + ) + + await wait_for_future_safe(on_entry) + assert len(history_updated_events) == 3 + assert len(fragment_navigated_events) == 0 + + on_entry = wait_for_event(HISTORY_UPDATED_EVENT) + await bidi_session.script.evaluate( + expression="history.forward();", + await_promise=False, + target=ContextTarget(target_context), + ) + + await wait_for_future_safe(on_entry) + assert len(history_updated_events) == 4 + assert len(fragment_navigated_events) == 0 finally: - remove_fragment_navigated_listener() - remove_history_updated_listener() - remove_created_listener() + remove_fragment_navigated_listener() + remove_history_updated_listener() + + +async def test_timestamp( + bidi_session, + current_time, + subscribe_events, + url, + new_tab, + wait_for_event, + wait_for_future_safe, +): + target_context = new_tab["context"] + await bidi_session.browsing_context.navigate( + context=new_tab["context"], url=url(EMPTY_PAGE), wait="complete" + ) + + await subscribe_events(events=[HISTORY_UPDATED_EVENT]) + + on_entry = wait_for_event(HISTORY_UPDATED_EVENT) + time_start = await current_time() + + await bidi_session.script.evaluate( + expression="""history.pushState({}, "", "test1.html")""", + await_promise=False, + target=ContextTarget(target_context), + ) + event = await wait_for_future_safe(on_entry) + time_end = await current_time() + + recursive_compare( + { + "context": target_context, + "timestamp": int_interval(time_start, time_end), + }, + event, + ) diff --git a/tests/wpt/tests/webdriver/tests/bidi/storage/set_cookie/partition.py b/tests/wpt/tests/webdriver/tests/bidi/storage/set_cookie/partition.py index bb171c61411..8866771b80c 100644 --- a/tests/wpt/tests/webdriver/tests/bidi/storage/set_cookie/partition.py +++ b/tests/wpt/tests/webdriver/tests/bidi/storage/set_cookie/partition.py @@ -44,6 +44,7 @@ async def test_partition_context(bidi_session, set_cookie, top_context, test_pag domain=domain_value(), name=cookie_name, value=NetworkStringValue(cookie_value), + secure=True, ), partition=partition, ) diff --git a/tests/wpt/tests/webdriver/tests/classic/add_cookie/add.py b/tests/wpt/tests/webdriver/tests/classic/add_cookie/add.py index 60b67d051ba..581040f7000 100644 --- a/tests/wpt/tests/webdriver/tests/classic/add_cookie/add.py +++ b/tests/wpt/tests/webdriver/tests/classic/add_cookie/add.py @@ -237,7 +237,8 @@ def test_add_cookie_with_valid_samesite_flag(session, url, same_site): new_cookie = { "name": "hello", "value": "world", - "sameSite": same_site + "secure": True, + "sameSite": same_site, } session.url = url("/common/blank.html") diff --git a/tests/wpt/tests/webnn/conformance_tests/averagePool2d.https.any.js b/tests/wpt/tests/webnn/conformance_tests/averagePool2d.https.any.js new file mode 100644 index 00000000000..c112cd89c03 --- /dev/null +++ b/tests/wpt/tests/webnn/conformance_tests/averagePool2d.https.any.js @@ -0,0 +1,1753 @@ +// META: title=test WebNN API averagePool2d operation +// META: global=window +// META: variant=?cpu +// META: variant=?gpu +// META: variant=?npu +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://www.w3.org/TR/webnn/#api-mlgraphbuilder-pool2d +// Compute a pooling operation across all the elements within the moving window +// over the input tensor. +// +// enum MLRoundingType { +// "floor", +// "ceil" +// }; +// +// dictionary MLPool2dOptions { +// sequence<[EnforceRange] unsigned long> windowDimensions; +// sequence<[EnforceRange] unsigned long> padding; +// sequence<[EnforceRange] unsigned long> strides; +// sequence<[EnforceRange] unsigned long> dilations; +// MLInputOperandLayout layout = "nchw"; +// MLRoundingType roundingType = "floor"; +// sequence<[EnforceRange] unsigned long> outputSizes; +// }; +// +// MLOperand averagePool2d( +// MLOperand input, optional MLPool2dOptions options = {}); + +const averagePool2dTests = [ + // float32 tests + { + 'name': + 'averagePool2d float32 4D constant tensor all positive default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor all positive default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor all negative default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + -83.87757873535156, -2.0740277767181396, -7.561108589172363, + -45.274261474609375, -16.36655616760254, -44.908512115478516, + -42.04186248779297, -44.77231979370117, -1.5066279172897339, + -52.65203857421875, -92.01856231689453, -48.004093170166016, + -61.522972106933594, -93.44403839111328, -25.780330657958984, + -95.51873779296875, -10.963757514953613, -59.132747650146484, + -32.60173797607422, -21.4510440826416, -87.115966796875, + -61.326114654541016, -41.989723205566406, -87.8764877319336, + -71.69316101074219, -80.24160766601562, -97.48886108398438, + -75.89422607421875, -45.08991622924805, -88.27134704589844, + -90.71282958984375, -93.32392120361328, -59.14753341674805, + -45.33106231689453, -51.32562255859375, -31.154796600341797, + -31.62424087524414, -62.80168151855469, -63.558509826660156, + -68.96183013916016, -43.09415054321289, -15.803443908691406, + -64.31092071533203, -66.45872497558594, -42.027252197265625, + -26.032955169677734, -22.73752784729004, -70.32036590576172, + -85.28227996826172, -92.10668182373047 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [-49.258975982666016, -60.52408981323242], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 43.46498107910156, 49.37273406982422, 42.7481689453125, + 50.038944244384766, 52.452327728271484, 58.46046447753906, + 32.15948486328125, 34.75465393066406, 54.00202560424805, + 49.65404510498047, 41.824440002441406, 35.84912109375, + 43.23125457763672, 37.842769622802734, 32.67961120605469, + 41.17021942138672, 42.79708480834961, 38.987247467041016 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'global averagePool2d float32 4D tensor all positive options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [5, 5]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.padding', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 52.43666076660156, 49.84208297729492, 47.26926803588867, + 46.15715408325195, 46.63268280029297, 43.616947174072266, + 44.72445297241211, 44.05451583862305 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.strides', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 43.46498107910156, 42.7481689453125, 32.15948486328125, + 54.00202560424805, 49.65404510498047, 35.84912109375, + 41.17021942138672, 38.987247467041016 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [32.2001838684082, 42.971012115478516], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': + [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 91.59549713134766, 78.15438079833984, + 65.64701080322266, 9.686111450195312, 55.14215087890625, + 51.298038482666016, 18.432437896728516, 32.193084716796875, + 49.34624099731445, 87.65037536621094, 15.648024559020996, + 87.25082397460938, 68.02723693847656, 39.49794006347656, + 20.342548370361328, 80.0996322631836, 26.727949142456055, + 10.220142364501953, 64.87446594238281, 52.602699279785156, + 46.5671501159668, 1.4128639698028564, 79.57833099365234, + 11.95406436920166, 4.33846378326416, 85.00074768066406, + 38.183837890625, 64.78374481201172, 45.25398254394531, + 88.03128814697266, 80.9718017578125, 11.333850860595703, + 67.58124542236328, 70.61659240722656, 6.0264997482299805, + 84.90442657470703, 29.7788143157959, 79.06687927246094, + 58.58993148803711, 7.3287248611450195, 2.2384984493255615, + 35.97796630859375, 14.50549030303955, 10.177306175231934, + 68.72449493408203, 1.4140757322311401, 76.45657348632812, + 78.10037994384766, 23.53263282775879 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': + [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'global averagePool2d float32 4D tensor options.layout=nhwc and options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 91.59549713134766, 78.15438079833984, + 65.64701080322266, 9.686111450195312, 55.14215087890625, + 51.298038482666016, 18.432437896728516, 32.193084716796875, + 49.34624099731445, 87.65037536621094, 15.648024559020996, + 87.25082397460938, 68.02723693847656, 39.49794006347656, + 20.342548370361328, 80.0996322631836, 26.727949142456055, + 10.220142364501953, 64.87446594238281, 52.602699279785156, + 46.5671501159668, 1.4128639698028564, 79.57833099365234, + 11.95406436920166, 4.33846378326416, 85.00074768066406, + 38.183837890625, 64.78374481201172, 45.25398254394531, + 88.03128814697266, 80.9718017578125, 11.333850860595703, + 67.58124542236328, 70.61659240722656, 6.0264997482299805, + 84.90442657470703, 29.7788143157959, 79.06687927246094, + 58.58993148803711, 7.3287248611450195, 2.2384984493255615, + 35.97796630859375, 14.50549030303955, 10.177306175231934, + 68.72449493408203, 1.4140757322311401, 76.45657348632812, + 78.10037994384766, 23.53263282775879 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [5, 5], 'layout': 'nhwc'}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.26926803588867, 44.72445297241211], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 37.16582489013672, 50.038944244384766, + 58.46046447753906, 52.73374557495117, 39.1442985534668, + 43.23125457763672, 32.67961120605469 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'averagePool2d float32 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 37.16582489013672, 21.206613540649414, + 50.038944244384766, 58.46046447753906, 51.3569221496582, + 37.24428939819336, 54.04661178588867, 78.58363342285156, + 52.73374557495117, 39.1442985534668, 57.1103515625, + 43.23125457763672, 32.67961120605469, 56.23945999145508, + 40.00800323486328, 43.85149002075195, 41.061283111572266 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.roundingType=ceil and no padding', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656 + ], + 'descriptor': {shape: [1, 2, 4, 4], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 51.20364761352539, 40.29140853881836, 50.77684020996094, + 51.70764923095703, 50.63130187988281, 49.3919792175293, + 53.128265380859375, 51.11610412597656 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.layout=nhwc and options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 91.59549713134766, 78.15438079833984, + 65.64701080322266, 9.686111450195312, 55.14215087890625, + 51.298038482666016, 18.432437896728516, 32.193084716796875, + 49.34624099731445, 87.65037536621094, 15.648024559020996, + 87.25082397460938, 68.02723693847656, 39.49794006347656, + 20.342548370361328, 80.0996322631836, 26.727949142456055, + 10.220142364501953, 64.87446594238281, 52.602699279785156, + 46.5671501159668, 1.4128639698028564, 79.57833099365234, + 11.95406436920166, 4.33846378326416, 85.00074768066406, + 38.183837890625, 64.78374481201172, 45.25398254394531, + 88.03128814697266, 80.9718017578125, 11.333850860595703, + 67.58124542236328, 70.61659240722656, 6.0264997482299805, + 84.90442657470703, 29.7788143157959, 79.06687927246094, + 58.58993148803711, 7.3287248611450195, 2.2384984493255615, + 35.97796630859375, 14.50549030303955, 10.177306175231934, + 68.72449493408203, 1.4140757322311401, 76.45657348632812, + 78.10037994384766, 23.53263282775879 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc', + 'roundingType': 'floor' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 52.73374557495117, 37.16582489013672, + 39.1442985534668, 50.038944244384766, 43.23125457763672, + 58.46046447753906, 32.67961120605469 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.layout=nhwc and options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 91.59549713134766, 78.15438079833984, + 65.64701080322266, 9.686111450195312, 55.14215087890625, + 51.298038482666016, 18.432437896728516, 32.193084716796875, + 49.34624099731445, 87.65037536621094, 15.648024559020996, + 87.25082397460938, 68.02723693847656, 39.49794006347656, + 20.342548370361328, 80.0996322631836, 26.727949142456055, + 10.220142364501953, 64.87446594238281, 52.602699279785156, + 46.5671501159668, 1.4128639698028564, 79.57833099365234, + 11.95406436920166, 4.33846378326416, 85.00074768066406, + 38.183837890625, 64.78374481201172, 45.25398254394531, + 88.03128814697266, 80.9718017578125, 11.333850860595703, + 67.58124542236328, 70.61659240722656, 6.0264997482299805, + 84.90442657470703, 29.7788143157959, 79.06687927246094, + 58.58993148803711, 7.3287248611450195, 2.2384984493255615, + 35.97796630859375, 14.50549030303955, 10.177306175231934, + 68.72449493408203, 1.4140757322311401, 76.45657348632812, + 78.10037994384766, 23.53263282775879 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc', + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 52.73374557495117, 37.16582489013672, + 39.1442985534668, 21.206613540649414, 57.1103515625, + 50.038944244384766, 43.23125457763672, 58.46046447753906, + 32.67961120605469, 51.3569221496582, 56.23945999145508, + 37.24428939819336, 40.00800323486328, 54.04661178588867, + 43.85149002075195, 78.58363342285156, 41.061283111572266 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 37.16582489013672, 21.206613540649414, + 50.038944244384766, 58.46046447753906, 51.3569221496582, + 37.24428939819336, 54.04661178588867, 78.58363342285156, + 52.73374557495117, 39.1442985534668, 57.1103515625, + 43.23125457763672, 32.67961120605469, 56.23945999145508, + 40.00800323486328, 43.85149002075195, 41.061283111572266 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.975555419921875, 78.15438079833984, 9.686111450195312, + 51.298038482666016, 32.193084716796875, 87.65037536621094, + 87.25082397460938, 39.49794006347656, 80.0996322631836, + 10.220142364501953, 52.602699279785156, 1.4128639698028564, + 11.95406436920166, 85.00074768066406, 64.78374481201172, + 88.03128814697266, 11.333850860595703, 70.61659240722656, + 84.90442657470703, 79.06687927246094, 7.3287248611450195, + 35.97796630859375, 10.177306175231934, 1.4140757322311401, + 78.10037994384766, 91.59549713134766, 65.64701080322266, + 55.14215087890625, 18.432437896728516, 49.34624099731445, + 15.648024559020996, 68.02723693847656, 20.342548370361328, + 26.727949142456055, 64.87446594238281, 46.5671501159668, + 79.57833099365234, 4.33846378326416, 38.183837890625, + 45.25398254394531, 80.9718017578125, 67.58124542236328, + 6.0264997482299805, 29.7788143157959, 58.58993148803711, + 2.2384984493255615, 14.50549030303955, 68.72449493408203, + 76.45657348632812, 23.53263282775879 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.20252990722656, 37.16582489013672, 50.038944244384766, + 58.46046447753906, 52.73374557495117, 39.1442985534668, + 43.23125457763672, 32.67961120605469 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'averagePool2d float32 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 70.71148681640625, 99.33489990234375, 76.41767883300781, + 39.40980911254883, 38.16328811645508, 45.971256256103516, + 65.3527603149414, 64.51607513427734, 7.725966930389404, + 41.7672004699707, 94.92633819580078, 53.475772857666016, + 95.46460723876953, 58.461795806884766, 15.831390380859375, + 78.41020202636719, 24.454092025756836, 20.630916595458984, + 32.06352233886719, 47.85192108154297, 91.60813903808594, + 72.3534927368164, 74.69429779052734, 28.860214233398438, + 71.82395935058594, 7.989691734313965, 88.16659545898438, + 58.69850540161133, 63.6061897277832, 55.88187789916992, + 52.809974670410156, 72.91474151611328, 46.957664489746094, + 22.10279655456543, 87.14309692382812, 89.6496810913086, + 63.19610595703125, 11.760882377624512, 70.68730926513672, + 57.70444107055664, 1.183821439743042, 25.26912498474121, + 95.29122924804688, 1.9658530950546265, 53.368465423583984, + 21.400854110717773, 55.86185836791992, 27.824508666992188, + 7.642839431762695, 82.34233093261719, 91.75215911865234, + 62.79155731201172, 28.11526107788086, 28.72478675842285, + 29.887035369873047, 66.4310302734375, 7.0103044509887695, + 34.33702087402344, 73.20159912109375, 7.8835601806640625, + 17.82563591003418, 33.799156188964844, 65.01251220703125, + 30.264028549194336, 75.76551818847656, 21.150800704956055, + 60.84249496459961, 98.56522369384766, 62.60990905761719, + 42.42991256713867, 53.142147064208984, 36.29545974731445, + 79.95863342285156, 79.60734558105469, 16.059114456176758, + 19.27552032470703, 53.93022918701172, 48.41620635986328, + 93.00965118408203, 62.086524963378906, 83.50532531738281, + 61.07964324951172, 75.51439666748047, 54.193782806396484, + 2.572873830795288, 59.47652053833008, 34.22541427612305, + 13.07015323638916, 12.419061660766602, 55.82337188720703, + 4.553813934326172, 63.47830581665039, 62.3555908203125, + 56.961090087890625, 34.77016067504883, 0.9611223936080933, + 35.30686950683594, 98.00790405273438 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 42.940242767333984, 55.268165588378906, 51.6013298034668, + 50.220027923583984, 72.13362884521484, 41.542198181152344, + 48.91604232788086, 38.775962829589844, 61.21329879760742, + 49.504154205322266, 57.72294998168945, 38.6922492980957, + 50.19099807739258, 29.15436363220215, 52.98439025878906, + 43.10562515258789, 66.77796936035156, 55.2725830078125 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} + } + } + } + }, + + // float16 tests + { + 'name': + 'averagePool2d float16 4D constant tensor all positive default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor all positive default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor all negative default options', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + -83.875, -2.07421875, -7.5625, -45.28125, -16.359375, + -44.90625, -42.03125, -44.78125, -1.5068359375, -52.65625, + -92, -48, -61.53125, -93.4375, -25.78125, + -95.5, -10.9609375, -59.125, -32.59375, -21.453125, + -87.125, -61.3125, -42, -87.875, -71.6875, + -80.25, -97.5, -75.875, -45.09375, -88.25, + -90.6875, -93.3125, -59.15625, -45.34375, -51.3125, + -31.15625, -31.625, -62.8125, -63.5625, -68.9375, + -43.09375, -15.8046875, -64.3125, -66.4375, -42.03125, + -26.03125, -22.734375, -70.3125, -85.3125, -92.125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [{'input': 'averagePool2dInput'}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [-49.25, -60.53125], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 43.46875, 49.375, 42.75, 50.03125, 52.4375, 58.46875, 32.15625, + 34.75, 54, 49.65625, 41.8125, 35.84375, 43.21875, 37.84375, 32.6875, + 41.1875, 42.78125, 39 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'global averagePool2d float16 4D tensor all positive options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [5, 5]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.padding', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 52.4375, 49.84375, 47.28125, 46.15625, 46.625, 43.625, 44.71875, + 44.0625 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.strides', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': + [43.46875, 42.75, 32.15625, 54, 49.65625, 35.84375, 41.1875, 39], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [32.21875, 42.96875], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': + [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 91.625, 78.125, 65.625, 9.6875, + 55.15625, 51.3125, 18.4375, 32.1875, 49.34375, + 87.625, 15.6484375, 87.25, 68, 39.5, + 20.34375, 80.125, 26.734375, 10.21875, 64.875, + 52.59375, 46.5625, 1.4130859375, 79.5625, 11.953125, + 4.33984375, 85, 38.1875, 64.8125, 45.25, + 88.0625, 81, 11.3359375, 67.5625, 70.625, + 6.02734375, 84.875, 29.78125, 79.0625, 58.59375, + 7.328125, 2.23828125, 35.96875, 14.5078125, 10.1796875, + 68.75, 1.4140625, 76.4375, 78.125, 23.53125 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': + [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'global averagePool2d float16 4D tensor options.layout=nhwc and options.windowDimensions', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 91.625, 78.125, 65.625, 9.6875, + 55.15625, 51.3125, 18.4375, 32.1875, 49.34375, + 87.625, 15.6484375, 87.25, 68, 39.5, + 20.34375, 80.125, 26.734375, 10.21875, 64.875, + 52.59375, 46.5625, 1.4130859375, 79.5625, 11.953125, + 4.33984375, 85, 38.1875, 64.8125, 45.25, + 88.0625, 81, 11.3359375, 67.5625, 70.625, + 6.02734375, 84.875, 29.78125, 79.0625, 58.59375, + 7.328125, 2.23828125, 35.96875, 14.5078125, 10.1796875, + 68.75, 1.4140625, 76.4375, 78.125, 23.53125 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, + {'options': {'windowDimensions': [5, 5], 'layout': 'nhwc'}} + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [47.28125, 44.71875], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 37.1875, 50.03125, 58.46875, 52.71875, 39.15625, 43.21875, + 32.6875 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'averagePool2d float16 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 37.1875, 21.203125, 50.03125, 58.46875, 51.375, 37.25, + 54.0625, 78.625, 52.71875, 39.15625, 57.125, 43.21875, 32.6875, + 56.25, 40, 43.84375, 41.0625 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.roundingType=ceil and no padding', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, 87.625, + 87.25, 39.5, 80.125, 10.21875, 52.59375, 1.4130859375, + 11.953125, 85, 64.8125, 88.0625, 11.3359375, 70.625, + 84.875, 79.0625, 7.328125, 35.96875, 10.1796875, 1.4140625, + 78.125, 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68 + ], + 'descriptor': {shape: [1, 2, 4, 4], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 51.1875, 40.28125, 50.78125, 51.71875, 50.625, 49.375, 53.125, + 51.09375 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.layout=nhwc and options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 91.625, 78.125, 65.625, 9.6875, + 55.15625, 51.3125, 18.4375, 32.1875, 49.34375, + 87.625, 15.6484375, 87.25, 68, 39.5, + 20.34375, 80.125, 26.734375, 10.21875, 64.875, + 52.59375, 46.5625, 1.4130859375, 79.5625, 11.953125, + 4.33984375, 85, 38.1875, 64.8125, 45.25, + 88.0625, 81, 11.3359375, 67.5625, 70.625, + 6.02734375, 84.875, 29.78125, 79.0625, 58.59375, + 7.328125, 2.23828125, 35.96875, 14.5078125, 10.1796875, + 68.75, 1.4140625, 76.4375, 78.125, 23.53125 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc', + 'roundingType': 'floor' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 52.71875, 37.1875, 39.15625, 50.03125, 43.21875, 58.46875, + 32.6875 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.layout=nhwc and options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 91.625, 78.125, 65.625, 9.6875, + 55.15625, 51.3125, 18.4375, 32.1875, 49.34375, + 87.625, 15.6484375, 87.25, 68, 39.5, + 20.34375, 80.125, 26.734375, 10.21875, 64.875, + 52.59375, 46.5625, 1.4130859375, 79.5625, 11.953125, + 4.33984375, 85, 38.1875, 64.8125, 45.25, + 88.0625, 81, 11.3359375, 67.5625, 70.625, + 6.02734375, 84.875, 29.78125, 79.0625, 58.59375, + 7.328125, 2.23828125, 35.96875, 14.5078125, 10.1796875, + 68.75, 1.4140625, 76.4375, 78.125, 23.53125 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc', + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 52.71875, 37.1875, 39.15625, 21.203125, 57.125, 50.03125, + 43.21875, 58.46875, 32.6875, 51.375, 56.25, 37.25, 40, 54.0625, + 43.84375, 78.625, 41.0625 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 37.1875, 21.203125, 50.03125, 58.46875, 51.375, 37.25, + 54.0625, 78.625, 52.71875, 39.15625, 57.125, 43.21875, 32.6875, + 56.25, 40, 43.84375, 41.0625 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 22.96875, 78.125, 9.6875, 51.3125, 32.1875, + 87.625, 87.25, 39.5, 80.125, 10.21875, + 52.59375, 1.4130859375, 11.953125, 85, 64.8125, + 88.0625, 11.3359375, 70.625, 84.875, 79.0625, + 7.328125, 35.96875, 10.1796875, 1.4140625, 78.125, + 91.625, 65.625, 55.15625, 18.4375, 49.34375, + 15.6484375, 68, 20.34375, 26.734375, 64.875, + 46.5625, 79.5625, 4.33984375, 38.1875, 45.25, + 81, 67.5625, 6.02734375, 29.78125, 58.59375, + 2.23828125, 14.5078125, 68.75, 76.4375, 23.53125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 54.1875, 37.1875, 50.03125, 58.46875, 52.71875, 39.15625, 43.21875, + 32.6875 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'averagePool2d float16 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'averagePool2dInput': { + 'data': [ + 70.6875, 99.3125, 76.4375, 39.40625, 38.15625, + 45.96875, 65.375, 64.5, 7.7265625, 41.78125, + 94.9375, 53.46875, 95.4375, 58.46875, 15.828125, + 78.4375, 24.453125, 20.625, 32.0625, 47.84375, + 91.625, 72.375, 74.6875, 28.859375, 71.8125, + 7.98828125, 88.1875, 58.6875, 63.59375, 55.875, + 52.8125, 72.9375, 46.96875, 22.109375, 87.125, + 89.625, 63.1875, 11.7578125, 70.6875, 57.71875, + 1.18359375, 25.265625, 95.3125, 1.9658203125, 53.375, + 21.40625, 55.875, 27.828125, 7.64453125, 82.3125, + 91.75, 62.78125, 28.109375, 28.71875, 29.890625, + 66.4375, 7.01171875, 34.34375, 73.1875, 7.8828125, + 17.828125, 33.8125, 65, 30.265625, 75.75, + 21.15625, 60.84375, 98.5625, 62.625, 42.4375, + 53.15625, 36.28125, 79.9375, 79.625, 16.0625, + 19.28125, 53.9375, 48.40625, 93, 62.09375, + 83.5, 61.09375, 75.5, 54.1875, 2.572265625, + 59.46875, 34.21875, 13.0703125, 12.421875, 55.8125, + 4.5546875, 63.46875, 62.34375, 56.96875, 34.78125, + 0.9609375, 35.3125, 98 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'averagePool2d', + 'arguments': [ + {'input': 'averagePool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'averagePool2dOutput' + }], + 'expectedOutputs': { + 'averagePool2dOutput': { + 'data': [ + 42.9375, 55.25, 51.59375, 50.21875, 72.125, 41.53125, 48.90625, + 38.78125, 61.21875, 49.5, 57.71875, 38.6875, 50.1875, 29.15625, + 52.96875, 43.09375, 66.75, 55.28125 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float16'} + } + } + } + } +]; + +if (navigator.ml) { + averagePool2dTests.forEach((test) => { + webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + }); +} else { + test(() => assert_implements(navigator.ml, 'missing navigator.ml')); +} diff --git a/tests/wpt/tests/webnn/conformance_tests/equal.https.any.js b/tests/wpt/tests/webnn/conformance_tests/equal.https.any.js index dc01aa19379..a974ec0004f 100644 --- a/tests/wpt/tests/webnn/conformance_tests/equal.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/equal.https.any.js @@ -987,7 +987,8 @@ const equalTests = [ if (navigator.ml) { equalTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getEqualPrecisionTolerance, test); + buildAndExecuteGraph, getEqualPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/graph_devices.https.any.js b/tests/wpt/tests/webnn/conformance_tests/graph_devices.https.any.js new file mode 100644 index 00000000000..c380d810f36 --- /dev/null +++ b/tests/wpt/tests/webnn/conformance_tests/graph_devices.https.any.js @@ -0,0 +1,22 @@ +// META: title=test graph.devices +// META: global=window +// META: variant=?cpu +// META: variant=?gpu +// META: variant=?npu +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +if (navigator.ml) { + promise_test(async () => { + const context = await navigator.ml.createContext(contextOptions); + const builder = new MLGraphBuilder(context); + const a = builder.input('A', {dataType: 'float32', shape: []}); + const o = builder.add(a, a); + const graph = await builder.build({'o': o}); + assert_greater_than(graph.devices.length, 0, 'graph.devices is empty.'); + }); +} else { + test(() => assert_implements(navigator.ml, 'missing navigator.ml')); +} diff --git a/tests/wpt/tests/webnn/conformance_tests/greater.https.any.js b/tests/wpt/tests/webnn/conformance_tests/greater.https.any.js index 704e0c45776..21e8b07bd47 100644 --- a/tests/wpt/tests/webnn/conformance_tests/greater.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/greater.https.any.js @@ -991,7 +991,8 @@ const greaterTests = [ if (navigator.ml) { greaterTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getGreaterPrecisionTolerance, test); + buildAndExecuteGraph, getGreaterPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/greater_or_equal.https.any.js b/tests/wpt/tests/webnn/conformance_tests/greater_or_equal.https.any.js index 28a2e896027..f9ab2d66814 100644 --- a/tests/wpt/tests/webnn/conformance_tests/greater_or_equal.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/greater_or_equal.https.any.js @@ -986,7 +986,8 @@ const greaterOrEqualTests = [ if (navigator.ml) { greaterOrEqualTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getGreaterOrEqualPrecisionTolerance, test); + buildAndExecuteGraph, getGreaterOrEqualPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/l2Pool2d.https.any.js b/tests/wpt/tests/webnn/conformance_tests/l2Pool2d.https.any.js new file mode 100644 index 00000000000..f0e16be927b --- /dev/null +++ b/tests/wpt/tests/webnn/conformance_tests/l2Pool2d.https.any.js @@ -0,0 +1,1366 @@ +// META: title=test WebNN API l2Pool2d operation +// META: global=window +// META: variant=?cpu +// META: variant=?gpu +// META: variant=?npu +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://www.w3.org/TR/webnn/#api-mlgraphbuilder-pool2d +// Compute a pooling operation across all the elements within the moving window +// over the input tensor. +// +// enum MLRoundingType { +// "floor", +// "ceil" +// }; +// +// dictionary MLPool2dOptions { +// sequence<[EnforceRange] unsigned long> windowDimensions; +// sequence<[EnforceRange] unsigned long> padding; +// sequence<[EnforceRange] unsigned long> strides; +// sequence<[EnforceRange] unsigned long> dilations; +// MLInputOperandLayout layout = "nchw"; +// MLRoundingType roundingType = "floor"; +// sequence<[EnforceRange] unsigned long> outputSizes; +// }; +// +// MLOperand l2Pool2d( +// MLOperand input, optional MLPool2dOptions options = {}); + +const l2Pool2dTests = [ + // float32 tests + { + 'name': 'l2Pool2d float32 4D constant tensor all positive default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289.01953125, 292.6146545410156], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor all positive default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289.01953125, 292.6146545410156], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor all negative default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + -1.1957088708877563, -9.706199645996094, -39.54935836791992, + -82.34971618652344, -32.87415313720703, -50.22603225708008, + -31.17849349975586, -55.817893981933594, -46.70829391479492, + -38.68181228637695, -63.299320220947266, -35.09224319458008, + -80.93848419189453, -82.8619613647461, -40.41627502441406, + -34.86458206176758, -84.33639526367188, -84.11852264404297, + -5.525088787078857, -99.03114318847656, -75.505126953125, + -91.43389129638672, -96.71258544921875, -16.722585678100586, + -17.98292350769043, -58.06570816040039, -11.846800804138184, + -97.90313720703125, -38.69822692871094, -80.19510650634766, + -48.72047805786133, -90.86722564697266, -99.10758209228516, + -79.70288848876953, -59.3824462890625, -9.967330932617188, + -39.27534866333008, -10.469644546508789, -27.565326690673828, + -2.0468990802764893, -81.88761901855469, -66.88040161132812, + -85.98504638671875, -29.674592971801758, -19.649417877197266, + -89.39192199707031, -61.13504409790039, -84.16869354248047, + -77.36112213134766, -91.17266082763672 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [298.928955078125, 326.83587646484375], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 194.45481872558594, 189.54539489746094, 189.85488891601562, + 160.0518341064453, 167.1435546875, 149.63897705078125, + 161.15570068359375, 190.5449981689453, 168.4636688232422, + 170.331787109375, 155.60073852539062, 174.72145080566406, + 165.07762145996094, 165.45819091796875, 161.11062622070312, + 176.6307373046875, 174.245361328125, 180.60714721679688 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.padding', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 254.81358337402344, 233.14259338378906, 289.01953125, + 269.777587890625, 241.52200317382812, 212.99337768554688, + 292.6146545410156, 253.77178955078125 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.strides', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 194.45481872558594, 189.85488891601562, 161.15570068359375, + 168.4636688232422, 170.331787109375, 174.72145080566406, + 176.6307373046875, 180.60714721679688 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [189.47933959960938, 207.25343322753906], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': + [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289.01953125, 292.6146545410156], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 52.027313232421875, 76.55464172363281, + 6.397815227508545, 62.71847152709961, 84.54785919189453, + 83.8726577758789, 18.622516632080078, 73.10235595703125, + 34.10626220703125, 41.52470779418945, 73.96932220458984, + 39.3339729309082, 36.1437873840332, 86.59486389160156, + 60.73781967163086, 23.09039306640625, 55.09187316894531, + 53.650146484375, 63.8924446105957, 0.00902052316814661, + 59.36124038696289, 42.78899383544922, 50.91202926635742, + 81.03960418701172, 50.339813232421875, 33.48585510253906, + 59.31963348388672, 33.67196273803711, 70.78031921386719, + 0.42822372913360596, 35.56179428100586, 80.07991790771484, + 82.53382873535156, 5.929991722106934, 7.572360038757324, + 48.89164733886719, 61.90089416503906, 15.282920837402344, + 14.084012985229492, 13.335721969604492, 90.86540985107422, + 39.06557846069336, 39.56248474121094, 97.06050109863281, + 67.77167510986328, 83.68133544921875, 69.69512176513672, + 21.79571533203125, 89.54518127441406 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': + [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289.01953125, 292.6146545410156], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5061492919922, 164.9919891357422, 160.0518341064453, + 149.63897705078125, 142.6990966796875, 139.51637268066406, + 165.07762145996094, 161.11062622070312 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5061492919922, 164.9919891357422, 90.6768569946289, + 160.0518341064453, 149.63897705078125, 65.15908813476562, + 132.56260681152344, 139.84808349609375, 26.61993408203125, + 142.6990966796875, 139.51637268066406, 72.42569732666016, + 165.07762145996094, 161.11062622070312, 96.38701629638672, + 150.1616668701172, 146.8201904296875, 90.64601135253906 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5061492919922, 164.9919891357422, 90.6768569946289, + 160.0518341064453, 149.63897705078125, 65.15908813476562, + 132.56260681152344, 139.84808349609375, 26.61993408203125, + 142.6990966796875, 139.51637268066406, 72.42569732666016, + 165.07762145996094, 161.11062622070312, 96.38701629638672, + 150.1616668701172, 146.8201904296875, 90.64601135253906 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.07447814941406, 76.55464172363281, 62.71847152709961, + 83.8726577758789, 73.10235595703125, 41.52470779418945, + 39.3339729309082, 86.59486389160156, 23.09039306640625, + 53.650146484375, 0.00902052316814661, 42.78899383544922, + 81.03960418701172, 33.48585510253906, 33.67196273803711, + 0.42822372913360596, 80.07991790771484, 5.929991722106934, + 48.89164733886719, 15.282920837402344, 13.335721969604492, + 39.06557846069336, 97.06050109863281, 83.68133544921875, + 21.79571533203125, 52.027313232421875, 6.397815227508545, + 84.54785919189453, 18.622516632080078, 34.10626220703125, + 73.96932220458984, 36.1437873840332, 60.73781967163086, + 55.09187316894531, 63.8924446105957, 59.36124038696289, + 50.91202926635742, 50.339813232421875, 59.31963348388672, + 70.78031921386719, 35.56179428100586, 82.53382873535156, + 7.572360038757324, 61.90089416503906, 14.084012985229492, + 90.86540985107422, 39.56248474121094, 67.77167510986328, + 69.69512176513672, 89.54518127441406 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5061492919922, 164.9919891357422, 160.0518341064453, + 149.63897705078125, 142.6990966796875, 139.51637268066406, + 165.07762145996094, 161.11062622070312 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'l2Pool2d float32 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 6.5550384521484375, 26.254413604736328, 28.47271156311035, + 64.81202697753906, 39.65838623046875, 10.465584754943848, + 47.94060134887695, 42.208946228027344, 36.834041595458984, + 68.50249481201172, 2.0496721267700195, 49.73927688598633, + 59.97947311401367, 71.08380889892578, 0.20033331215381622, + 19.39293670654297, 70.1269302368164, 86.8837661743164, + 84.28858184814453, 9.695697784423828, 62.69126510620117, + 51.924110412597656, 5.412675857543945, 70.82118225097656, + 81.61302947998047, 29.148712158203125, 85.83409881591797, + 71.36548614501953, 44.09445571899414, 58.343570709228516, + 43.37118148803711, 54.025882720947266, 85.50556945800781, + 93.19215393066406, 10.992993354797363, 34.864158630371094, + 96.2605209350586, 44.29584503173828, 61.12482833862305, + 79.62699127197266, 4.066447734832764, 64.89644622802734, + 97.5897445678711, 11.257055282592773, 61.151283264160156, + 20.312341690063477, 39.862640380859375, 68.747314453125, + 89.61034393310547, 22.28224754333496, 41.36311721801758, + 62.9378662109375, 79.54936218261719, 55.64254379272461, + 54.47548294067383, 77.04864501953125, 56.83576965332031, + 80.57747650146484, 70.43293762207031, 85.67094421386719, + 19.527807235717773, 33.87490463256836, 14.498117446899414, + 92.85955810546875, 96.8167724609375, 28.399721145629883, + 99.917236328125, 48.76692199707031, 86.08634948730469, + 47.32324981689453, 7.223662376403809, 82.97200775146484, + 38.374778747558594, 22.10988426208496, 14.797550201416016, + 2.3872148990631104, 83.26342010498047, 46.41500473022461, + 28.659175872802734, 13.919462203979492, 55.413089752197266, + 62.68498992919922, 78.54127502441406, 31.142845153808594, + 4.806727886199951, 33.233642578125, 24.749773025512695, + 1.529007077217102, 42.976322174072266, 93.08572387695312, + 77.908935546875, 45.74395751953125, 62.868892669677734, + 60.689762115478516, 20.046878814697266, 13.203198432922363, + 33.33952713012695, 0.5279953479766846 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'dilations': [1, 1], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 120.20333862304688, 114.0977783203125, 127.63969421386719, + 119.95613861083984, 137.89837646484375, 152.24261474609375, + 194.9647216796875, 168.20205688476562, 197.7173309326172, + 169.85887145996094, 195.1484832763672, 190.96127319335938, + 158.64576721191406, 166.2051544189453, 171.07916259765625, + 148.70985412597656, 218.7123260498047, 153.33311462402344 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} + } + } + } + }, + + // float16 tests + { + 'name': 'l2Pool2d float16 4D constant tensor all positive default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289, 292.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor all positive default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289, 292.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor all negative default options', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + -1.1953125, -9.703125, -39.5625, -82.375, -32.875, -50.21875, + -31.171875, -55.8125, -46.71875, -38.6875, -63.3125, -35.09375, + -80.9375, -82.875, -40.40625, -34.875, -84.3125, -84.125, + -5.5234375, -99, -75.5, -91.4375, -96.6875, -16.71875, + -17.984375, -58.0625, -11.84375, -97.875, -38.6875, -80.1875, + -48.71875, -90.875, -99.125, -79.6875, -59.375, -9.96875, + -39.28125, -10.46875, -27.5625, -2.046875, -81.875, -66.875, + -86, -29.671875, -19.65625, -89.375, -61.125, -84.1875, + -77.375, -91.1875 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [{'input': 'l2Pool2dInput'}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [299, 326.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 194.5, 189.625, 189.875, 160.125, 167.125, 149.625, 161.125, 190.5, + 168.5, 170.375, 155.625, 174.75, 165.125, 165.5, 161.125, 176.625, + 174.25, 180.625 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.padding', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [254.875, 233.125, 289, 269.75, 241.5, 213, 292.75, 253.75], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.strides', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 194.5, 189.875, 161.125, 168.5, 170.375, 174.75, 176.625, 180.625 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [189.5, 207.25], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': + [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289, 292.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 52.03125, 76.5625, + 6.3984375, 62.71875, 84.5625, + 83.875, 18.625, 73.125, + 34.09375, 41.53125, 74, + 39.34375, 36.15625, 86.625, + 60.75, 23.09375, 55.09375, + 53.65625, 63.90625, 0.0090179443359375, + 59.375, 42.78125, 50.90625, + 81.0625, 50.34375, 33.5, + 59.3125, 33.6875, 70.75, + 0.42822265625, 35.5625, 80.0625, + 82.5625, 5.9296875, 7.57421875, + 48.90625, 61.90625, 15.28125, + 14.0859375, 13.3359375, 90.875, + 39.0625, 39.5625, 97.0625, + 67.75, 83.6875, 69.6875, + 21.796875, 89.5625 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': + [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [289, 292.75], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': + [171.5, 165, 160.125, 149.625, 142.75, 139.5, 165.125, 161.125], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5, 165, 90.6875, 160.125, 149.625, 65.1875, 132.5, 139.875, + 26.625, 142.75, 139.5, 72.4375, 165.125, 161.125, 96.375, 150.125, + 146.875, 90.6875 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'l2Pool2d float16 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 171.5, 165, 90.6875, 160.125, 149.625, 65.1875, 132.5, 139.875, + 26.625, 142.75, 139.5, 72.4375, 165.125, 161.125, 96.375, 150.125, + 146.875, 90.6875 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'l2Pool2d float16 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 94.0625, 76.5625, 62.71875, + 83.875, 73.125, 41.53125, + 39.34375, 86.625, 23.09375, + 53.65625, 0.0090179443359375, 42.78125, + 81.0625, 33.5, 33.6875, + 0.42822265625, 80.0625, 5.9296875, + 48.90625, 15.28125, 13.3359375, + 39.0625, 97.0625, 83.6875, + 21.796875, 52.03125, 6.3984375, + 84.5625, 18.625, 34.09375, + 74, 36.15625, 60.75, + 55.09375, 63.90625, 59.375, + 50.90625, 50.34375, 59.3125, + 70.75, 35.5625, 82.5625, + 7.57421875, 61.90625, 14.0859375, + 90.875, 39.5625, 67.75, + 69.6875, 89.5625 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': + [171.5, 165, 160.125, 149.625, 142.75, 139.5, 165.125, 161.125], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'l2Pool2d float16 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'l2Pool2dInput': { + 'data': [ + 6.5546875, 26.25, 28.46875, 64.8125, 39.65625, + 10.46875, 47.9375, 42.21875, 36.84375, 68.5, + 2.048828125, 49.75, 59.96875, 71.0625, 0.2003173828125, + 19.390625, 70.125, 86.875, 84.3125, 9.6953125, + 62.6875, 51.9375, 5.4140625, 70.8125, 81.625, + 29.15625, 85.8125, 71.375, 44.09375, 58.34375, + 43.375, 54.03125, 85.5, 93.1875, 10.9921875, + 34.875, 96.25, 44.28125, 61.125, 79.625, + 4.06640625, 64.875, 97.5625, 11.2578125, 61.15625, + 20.3125, 39.875, 68.75, 89.625, 22.28125, + 41.375, 62.9375, 79.5625, 55.65625, 54.46875, + 77.0625, 56.84375, 80.5625, 70.4375, 85.6875, + 19.53125, 33.875, 14.5, 92.875, 96.8125, + 28.40625, 99.9375, 48.78125, 86.0625, 47.3125, + 7.22265625, 83, 38.375, 22.109375, 14.796875, + 2.38671875, 83.25, 46.40625, 28.65625, 13.921875, + 55.40625, 62.6875, 78.5625, 31.140625, 4.80859375, + 33.21875, 24.75, 1.529296875, 42.96875, 93.0625, + 77.9375, 45.75, 62.875, 60.6875, 20.046875, + 13.203125, 33.34375, 0.52783203125 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'l2Pool2d', + 'arguments': [ + {'input': 'l2Pool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'dilations': [1, 1], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'l2Pool2dOutput' + }], + 'expectedOutputs': { + 'l2Pool2dOutput': { + 'data': [ + 120.1875, 114.0625, 127.625, 119.9375, 137.875, 152.25, 195, 168.25, + 197.75, 169.875, 195.125, 191, 158.625, 166.25, 171.125, 148.75, + 218.75, 153.375 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float16'} + } + } + } + } +]; + +if (navigator.ml) { + l2Pool2dTests.forEach((test) => { + webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + }); +} else { + test(() => assert_implements(navigator.ml, 'missing navigator.ml')); +} diff --git a/tests/wpt/tests/webnn/conformance_tests/lesser.https.any.js b/tests/wpt/tests/webnn/conformance_tests/lesser.https.any.js index 0588f3bcd6a..8978435c6e3 100644 --- a/tests/wpt/tests/webnn/conformance_tests/lesser.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/lesser.https.any.js @@ -998,7 +998,8 @@ const lesserTests = [ if (navigator.ml) { lesserTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getLesserPrecisionTolerance, test); + buildAndExecuteGraph, getLesserPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/lesser_or_equal.https.any.js b/tests/wpt/tests/webnn/conformance_tests/lesser_or_equal.https.any.js index cfcc74063ec..16aa5888cc2 100644 --- a/tests/wpt/tests/webnn/conformance_tests/lesser_or_equal.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/lesser_or_equal.https.any.js @@ -1105,7 +1105,8 @@ const lesserOrEqualTests = [ if (navigator.ml) { lesserOrEqualTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getLesserOrEqualPrecisionTolerance, test); + buildAndExecuteGraph, getLesserOrEqualPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/logical_and.https.any.js b/tests/wpt/tests/webnn/conformance_tests/logical_and.https.any.js index a4d71654bcb..1a03ef5444d 100644 --- a/tests/wpt/tests/webnn/conformance_tests/logical_and.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/logical_and.https.any.js @@ -414,7 +414,9 @@ const logicalAndTests = [ if (navigator.ml) { logicalAndTests.forEach((test) => { - webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + webnn_conformance_test( + buildAndExecuteGraph, getPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/logical_not.https.any.js b/tests/wpt/tests/webnn/conformance_tests/logical_not.https.any.js index 9d1861dd548..f8949672cc5 100644 --- a/tests/wpt/tests/webnn/conformance_tests/logical_not.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/logical_not.https.any.js @@ -214,7 +214,8 @@ const logicalNotTests = [ if (navigator.ml) { logicalNotTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getLogicalNotPrecisionTolerance, test); + buildAndExecuteGraph, getLogicalNotPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/logical_or.https.any.js b/tests/wpt/tests/webnn/conformance_tests/logical_or.https.any.js index f8941b633c9..83c261969f6 100644 --- a/tests/wpt/tests/webnn/conformance_tests/logical_or.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/logical_or.https.any.js @@ -414,7 +414,9 @@ const logicalOrTests = [ if (navigator.ml) { logicalOrTests.forEach((test) => { - webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + webnn_conformance_test( + buildAndExecuteGraph, getPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/logical_xor.https.any.js b/tests/wpt/tests/webnn/conformance_tests/logical_xor.https.any.js index 533d52aa6be..7a9446ea2e4 100644 --- a/tests/wpt/tests/webnn/conformance_tests/logical_xor.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/logical_xor.https.any.js @@ -414,7 +414,9 @@ const logicalXorTests = [ if (navigator.ml) { logicalXorTests.forEach((test) => { - webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + webnn_conformance_test( + buildAndExecuteGraph, getPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/maxPool2d.https.any.js b/tests/wpt/tests/webnn/conformance_tests/maxPool2d.https.any.js new file mode 100644 index 00000000000..6ee8b1976d2 --- /dev/null +++ b/tests/wpt/tests/webnn/conformance_tests/maxPool2d.https.any.js @@ -0,0 +1,1216 @@ +// META: title=test WebNN API maxPool2d operation +// META: global=window +// META: variant=?cpu +// META: variant=?gpu +// META: variant=?npu +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://www.w3.org/TR/webnn/#api-mlgraphbuilder-pool2d +// Compute a pooling operation across all the elements within the moving window +// over the input tensor. +// +// enum MLRoundingType { +// "floor", +// "ceil" +// }; +// +// dictionary MLPool2dOptions { +// sequence<[EnforceRange] unsigned long> windowDimensions; +// sequence<[EnforceRange] unsigned long> padding; +// sequence<[EnforceRange] unsigned long> strides; +// sequence<[EnforceRange] unsigned long> dilations; +// MLInputOperandLayout layout = "nchw"; +// MLRoundingType roundingType = "floor"; +// sequence<[EnforceRange] unsigned long> outputSizes; +// }; +// +// MLOperand maxPool2d( +// MLOperand input, optional MLPool2dOptions options = {}); + +const maxPool2dTests = [ + // float32 tests + { + 'name': 'maxPool2d float32 4D constant tensor default options', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [{'input': 'maxPool2dInput'}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.28312683105469, 81.73119354248047], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor default options', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [{'input': 'maxPool2dInput'}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.28312683105469, 81.73119354248047], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 99.28312683105469, 66.09259033203125, + 99.28312683105469, 99.28312683105469, 72.1085205078125, + 97.90348052978516, 72.1085205078125, 72.1085205078125, + 81.73119354248047, 72.44898986816406, 72.44898986816406, + 81.73119354248047, 72.8883056640625, 72.44898986816406, + 80.30484008789062, 72.8883056640625, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.padding', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 99.28312683105469, 99.28312683105469, + 99.28312683105469, 81.73119354248047, 72.8883056640625, + 81.73119354248047, 72.8883056640625 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.strides', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 66.09259033203125, 97.90348052978516, + 72.1085205078125, 81.73119354248047, 72.44898986816406, + 80.30484008789062, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [89.00830078125, 72.33577728271484], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': + [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.28312683105469, 81.73119354248047], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -76.72171020507812, -45.72039031982422, + 50.217063903808594, -61.306129455566406, -52.895477294921875, + -4.014514446258545, -44.642333984375, -94.54893493652344, + -97.86752319335938, 46.28090286254883, 81.73119354248047, + 99.28312683105469, 5.428491115570068, -10.057873725891113, + -29.22772789001465, 9.742474555969238, 72.44898986816406, + -39.03501892089844, -59.34124755859375, 75.08192443847656, + 39.19960021972656, 12.819415092468262, -65.99439239501953, + -33.01505661010742, -4.204323768615723, 38.691341400146484, + -60.54586410522461, 66.09259033203125, 55.890525817871094, + 97.90348052978516, 80.30484008789062, -8.737770080566406, + 72.8883056640625, -53.42162322998047, -46.59611129760742, + 72.1085205078125, 20.50387954711914, -40.423091888427734, + -31.126462936401367, -35.68864440917969, -57.294559478759766, + -87.64779663085938, -26.623577117919922, 38.874244689941406, + 15.935754776000977, 39.383602142333984, -78.77953338623047, + 7.429088115692139, 72.33577728271484 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': + [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.28312683105469, 81.73119354248047], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 9.742474555969238, 99.28312683105469, + 72.1085205078125, 81.73119354248047, 72.44898986816406, + 81.73119354248047, 72.44898986816406 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': 'maxPool2d float32 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 9.742474555969238, -39.03501892089844, + 99.28312683105469, 72.1085205078125, 66.09259033203125, + 97.90348052978516, 72.1085205078125, 7.429088115692139, + 81.73119354248047, 72.44898986816406, -59.34124755859375, + 81.73119354248047, 72.44898986816406, 55.890525817871094, + 80.30484008789062, 72.33577728271484, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'maxPool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 9.742474555969238, -39.03501892089844, + 99.28312683105469, 72.1085205078125, 66.09259033203125, + 97.90348052978516, 72.1085205078125, 7.429088115692139, + 81.73119354248047, 72.44898986816406, -59.34124755859375, + 81.73119354248047, 72.44898986816406, 55.890525817871094, + 80.30484008789062, 72.33577728271484, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'maxPool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89.00830078125, -45.72039031982422, -61.306129455566406, + -4.014514446258545, -94.54893493652344, 46.28090286254883, + 99.28312683105469, -10.057873725891113, 9.742474555969238, + -39.03501892089844, 75.08192443847656, 12.819415092468262, + -33.01505661010742, 38.691341400146484, 66.09259033203125, + 97.90348052978516, -8.737770080566406, -53.42162322998047, + 72.1085205078125, -40.423091888427734, -35.68864440917969, + -87.64779663085938, 38.874244689941406, 39.383602142333984, + 7.429088115692139, -76.72171020507812, 50.217063903808594, + -52.895477294921875, -44.642333984375, -97.86752319335938, + 81.73119354248047, 5.428491115570068, -29.22772789001465, + 72.44898986816406, -59.34124755859375, 39.19960021972656, + -65.99439239501953, -4.204323768615723, -60.54586410522461, + 55.890525817871094, 80.30484008789062, 72.8883056640625, + -46.59611129760742, 20.50387954711914, -31.126462936401367, + -57.294559478759766, -26.623577117919922, 15.935754776000977, + -78.77953338623047, 72.33577728271484 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.28312683105469, 9.742474555969238, 99.28312683105469, + 72.1085205078125, 81.73119354248047, 72.44898986816406, + 81.73119354248047, 72.44898986816406 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} + } + } + } + }, + { + 'name': + 'maxPool2d float32 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 34.69258117675781, -24.706249237060547, -60.428070068359375, + 35.93883514404297, 60.896095275878906, 79.42220306396484, + -77.85906219482422, 54.188209533691406, -21.576934814453125, + -49.10390853881836, 78.55176544189453, 74.28213500976562, + -87.92769622802734, 79.82047271728516, 11.680922508239746, + -12.154505729675293, -22.33293914794922, 33.084861755371094, + 8.640676498413086, 47.040645599365234, 95.7823486328125, + -88.01998138427734, -98.53630065917969, 16.158977508544922, + 21.396089553833008, 95.1323471069336, -40.80724334716797, + -88.70922088623047, -40.772769927978516, 67.89842987060547, + -50.337467193603516, -96.56610870361328, 12.508098602294922, + -6.6358113288879395, -44.80198287963867, 80.27474212646484, + -65.68411254882812, -14.884790420532227, -66.54857635498047, + 20.072338104248047, -27.954269409179688, -56.62217330932617, + 82.7479476928711, 93.30175018310547, -34.073394775390625, + -22.87164306640625, 73.25525665283203, 41.14021682739258, + -19.75514793395996, 80.07701110839844, -69.89276885986328, + 14.013250350952148, -61.36640167236328, 51.53046417236328, + 43.53886413574219, -89.5888671875, 51.45121765136719, + 73.9239730834961, -80.25264739990234, 94.72747802734375, + 95.25411224365234, 58.12575149536133, 19.885723114013672, + -70.0301284790039, 63.419517517089844, -54.11785125732422, + -97.22807312011719, -60.65826416015625, -31.04998016357422, + -14.646553039550781, -63.73688888549805, 47.34630584716797, + 85.56405639648438, -53.389251708984375, -70.84739685058594, + 47.355045318603516, 83.38397979736328, 7.361695289611816, + 46.85823440551758, 98.13465881347656, -43.9396858215332, + 50.33780288696289, 37.45563507080078, -54.52760696411133, + -6.212307929992676, 34.41734313964844, 11.8167724609375, + 72.44517517089844, 86.3460922241211, 4.14656925201416, + 88.33040618896484, 98.29994201660156, -66.72379302978516, + 58.0643424987793, -51.168277740478516, -17.768583297729492, + 9.961172103881836, -52.73843002319336 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'dilations': [1, 1], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 60.896095275878906, 79.42220306396484, 95.7823486328125, + 79.42220306396484, 78.55176544189453, 95.1323471069336, + 82.7479476928711, 93.30175018310547, 95.7823486328125, + 80.27474212646484, 43.53886413574219, 95.1323471069336, + 95.25411224365234, 94.72747802734375, 95.25411224365234, + 98.13465881347656, 63.419517517089844, 98.13465881347656 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} + } + } + } + }, + + // float16 tests + { + 'name': 'maxPool2d float16 4D constant tensor default options', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [{'input': 'maxPool2dInput'}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.3125, 81.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor default options', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [{'input': 'maxPool2dInput'}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.3125, 81.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.windowDimensions', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, {'options': {'windowDimensions': [3, 3]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 99.3125, 66.0625, 99.3125, 99.3125, 72.125, 97.875, 72.125, + 72.125, 81.75, 72.4375, 72.4375, 81.75, 72.875, 72.4375, 80.3125, + 72.875, 72.3125 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.padding', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 99.3125, 99.3125, 99.3125, 81.75, 72.875, 81.75, 72.875 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.strides', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 66.0625, 97.875, 72.125, 81.75, 72.4375, 80.3125, 72.3125 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.dilations', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, + {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [89, 72.3125], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.layout=nchw', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': + [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nchw'}}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.3125, 81.75], + 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.layout=nhwc', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -76.75, -45.71875, 50.21875, -61.3125, + -52.90625, -4.015625, -44.65625, -94.5625, -97.875, + 46.28125, 81.75, 99.3125, 5.4296875, -10.0546875, + -29.234375, 9.7421875, 72.4375, -39.03125, -59.34375, + 75.0625, 39.1875, 12.8203125, -66, -33, + -4.203125, 38.6875, -60.53125, 66.0625, 55.875, + 97.875, 80.3125, -8.734375, 72.875, -53.40625, + -46.59375, 72.125, 20.5, -40.4375, -31.125, + -35.6875, -57.28125, -87.625, -26.625, 38.875, + 15.9375, 39.375, -78.75, 7.4296875, 72.3125 + ], + 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': + [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nhwc'}}], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [99.3125, 81.75], + 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.roundingType=floor', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 9.7421875, 99.3125, 72.125, 81.75, 72.4375, 81.75, 72.4375 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'maxPool2d float16 4D tensor options.roundingType=ceil', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 9.7421875, -39.03125, 99.3125, 72.125, 66.0625, 97.875, + 72.125, 7.4296875, 81.75, 72.4375, -59.34375, 81.75, 72.4375, + 55.875, 80.3125, 72.3125, 72.3125 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'maxPool2d float16 4D tensor options.outputSizes ignores options.roundingType=floor', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'floor', + 'outputSizes': [3, 3] + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 9.7421875, -39.03125, 99.3125, 72.125, 66.0625, 97.875, + 72.125, 7.4296875, 81.75, 72.4375, -59.34375, 81.75, 72.4375, + 55.875, 80.3125, 72.3125, 72.3125 + ], + 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'maxPool2d float16 4D tensor options.outputSizes ignores options.roundingType=ceil', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 89, -45.71875, -61.3125, -4.015625, -94.5625, + 46.28125, 99.3125, -10.0546875, 9.7421875, -39.03125, + 75.0625, 12.8203125, -33, 38.6875, 66.0625, + 97.875, -8.734375, -53.40625, 72.125, -40.4375, + -35.6875, -87.625, 38.875, 39.375, 7.4296875, + -76.75, 50.21875, -52.90625, -44.65625, -97.875, + 81.75, 5.4296875, -29.234375, 72.4375, -59.34375, + 39.1875, -66, -4.203125, -60.53125, 55.875, + 80.3125, 72.875, -46.59375, 20.5, -31.125, + -57.28125, -26.625, 15.9375, -78.75, 72.3125 + ], + 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'roundingType': 'ceil', + 'outputSizes': [2, 2] + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 99.3125, 9.7421875, 99.3125, 72.125, 81.75, 72.4375, 81.75, 72.4375 + ], + 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': + 'maxPool2d float16 4D tensor options.dilations with options.strides', + 'graph': { + 'inputs': { + 'maxPool2dInput': { + 'data': [ + 34.6875, -24.703125, -60.4375, 35.9375, 60.90625, + 79.4375, -77.875, 54.1875, -21.578125, -49.09375, + 78.5625, 74.3125, -87.9375, 79.8125, 11.6796875, + -12.15625, -22.328125, 33.09375, 8.640625, 47.03125, + 95.8125, -88, -98.5625, 16.15625, 21.390625, + 95.125, -40.8125, -88.6875, -40.78125, 67.875, + -50.34375, -96.5625, 12.5078125, -6.63671875, -44.8125, + 80.25, -65.6875, -14.8828125, -66.5625, 20.078125, + -27.953125, -56.625, 82.75, 93.3125, -34.0625, + -22.875, 73.25, 41.125, -19.75, 80.0625, + -69.875, 14.015625, -61.375, 51.53125, 43.53125, + -89.5625, 51.4375, 73.9375, -80.25, 94.75, + 95.25, 58.125, 19.890625, -70, 63.40625, + -54.125, -97.25, -60.65625, -31.046875, -14.6484375, + -63.75, 47.34375, 85.5625, -53.375, -70.875, + 47.34375, 83.375, 7.36328125, 46.84375, 98.125, + -43.9375, 50.34375, 37.46875, -54.53125, -6.2109375, + 34.40625, 11.8203125, 72.4375, 86.375, 4.1484375, + 88.3125, 98.3125, -66.75, 58.0625, -51.15625, + -17.765625, 9.9609375, -52.75 + ], + 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'maxPool2d', + 'arguments': [ + {'input': 'maxPool2dInput'}, { + 'options': { + 'windowDimensions': [3, 3], + 'padding': [1, 0, 0, 1], + 'strides': [2, 2], + 'dilations': [1, 1], + 'layout': 'nhwc' + } + } + ], + 'outputs': 'maxPool2dOutput' + }], + 'expectedOutputs': { + 'maxPool2dOutput': { + 'data': [ + 60.90625, 79.4375, 95.8125, 79.4375, 78.5625, 95.125, 82.75, + 93.3125, 95.8125, 80.25, 43.53125, 95.125, 95.25, 94.75, 95.25, + 98.125, 63.40625, 98.125 + ], + 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float16'} + } + } + } + } +]; + +if (navigator.ml) { + maxPool2dTests.forEach((test) => { + webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); + }); +} else { + test(() => assert_implements(navigator.ml, 'missing navigator.ml')); +} diff --git a/tests/wpt/tests/webnn/conformance_tests/not_equal.https.any.js b/tests/wpt/tests/webnn/conformance_tests/not_equal.https.any.js index 3bba726d585..5aed1247e06 100644 --- a/tests/wpt/tests/webnn/conformance_tests/not_equal.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/not_equal.https.any.js @@ -22,6 +22,7 @@ const getNotEqualPrecisionTolerance = (graphResources) => { }; const notEqualTests = [ + // float32 tests { 'name': 'notEqual float32 0D scalar', 'graph': { @@ -524,13 +525,471 @@ const notEqualTests = [ } } } + }, + + // float16 tests + { + 'name': 'notEqual float16 0D scalar', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [-0.62841796875], + 'descriptor': {shape: [], dataType: 'float16'} + }, + 'inputB': { + 'data': [-4.41796875], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': {'data': [1], 'descriptor': {shape: [], dataType: 'uint8'}} + } + } + }, + { + 'name': 'notEqual float16 1D constant tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [24], dataType: 'float16'}, + 'constant': true + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [24], dataType: 'float16'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [24], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 1D tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [24], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [24], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [24], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 2D tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [4, 6], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 3D tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 3, 4], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 4D tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 5D tensors', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.83984375, 4.99609375, + 0.97265625, -6.171875, 2.806640625, 5.58984375, + 7.765625, -4.30859375, -5.89453125, -8.53125, + 2.806640625, 5.58984375, 0.1783447265625, -4.48046875, + 0.68212890625, -6.6875, 2.806640625, 5.58984375, + -9.0390625, -1.97265625, -3.01171875, 3.626953125 + ], + 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 1, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 broadcast 0D to 4D', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [2.806640625], + 'descriptor': {shape: [], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 broadcast 1D to 4D', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [2.806640625], + 'descriptor': {shape: [1], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 broadcast 2D to 4D', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, -4.9609375, -2.86328125, -3.01171875, + 3.626953125 + ], + 'descriptor': {shape: [2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 broadcast 3D to 4D', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + }, + 'inputB': { + 'data': [2.806640625, 5.58984375, -9.0390625, 3.626953125], + 'descriptor': {shape: [2, 2, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } + }, + { + 'name': 'notEqual float16 broadcast 4D to 4D', + 'graph': { + 'inputs': { + 'inputA': { + 'data': [2.806640625], + 'descriptor': {shape: [1, 1, 1, 1], dataType: 'float16'} + }, + 'inputB': { + 'data': [ + 2.806640625, 5.58984375, 2.85546875, 4.99609375, 0.97265625, + -4.7421875, 2.806640625, 5.58984375, -5.109375, 6.625, + -2.3203125, -7.0546875, 2.806640625, 5.58984375, 4.98046875, + -5.44140625, 1.1455078125, 7.7734375, 2.806640625, 5.58984375, + -6.24609375, -2.849609375, -2.6953125, 5.81640625 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'notEqual', + 'arguments': [{'a': 'inputA'}, {'b': 'inputB'}], + 'outputs': 'output' + }], + 'expectedOutputs': { + 'output': { + 'data': [ + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'} + } + } + } } ]; if (navigator.ml) { notEqualTests.forEach((test) => { webnn_conformance_test( - buildAndExecuteGraph, getNotEqualPrecisionTolerance, test); + buildAndExecuteGraph, getNotEqualPrecisionTolerance, test, + /*cast_to_supported_type=*/true); }); } else { test(() => assert_implements(navigator.ml, 'missing navigator.ml')); diff --git a/tests/wpt/tests/webnn/conformance_tests/pooling.https.any.js b/tests/wpt/tests/webnn/conformance_tests/pooling.https.any.js deleted file mode 100644 index 8f81ff565d2..00000000000 --- a/tests/wpt/tests/webnn/conformance_tests/pooling.https.any.js +++ /dev/null @@ -1,2312 +0,0 @@ -// META: title=test WebNN API pooling operations -// META: global=window -// META: variant=?cpu -// META: variant=?gpu -// META: variant=?npu -// META: script=../resources/utils.js -// META: timeout=long - -'use strict'; - -// https://www.w3.org/TR/webnn/#api-mlgraphbuilder-pool2d -// Compute a pooling operation across all the elements within the moving window -// over the input tensor. -// -// enum MLRoundingType { -// "floor", -// "ceil" -// }; -// -// dictionary MLPool2dOptions { -// sequence<[EnforceRange] unsigned long> windowDimensions; -// sequence<[EnforceRange] unsigned long> padding; -// sequence<[EnforceRange] unsigned long> strides; -// sequence<[EnforceRange] unsigned long> dilations; -// MLInputOperandLayout layout = "nchw"; -// MLRoundingType roundingType = "floor"; -// sequence<[EnforceRange] unsigned long> outputSizes; -// }; -// -// MLOperand averagePool2d( -// MLOperand input, optional MLPool2dOptions options = {}); -// MLOperand l2Pool2d( -// MLOperand input, optional MLPool2dOptions options = {}); -// MLOperand maxPool2d( -// MLOperand input, optional MLPool2dOptions options = {}); - -const poolingOperatorsTests = [ - // averagePool2d tests - { - 'name': - 'averagePool2d float32 4D constant tensor all positive default options', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, - 'constant': true - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [{'input': 'averagePool2dInput'}], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor all positive default options', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [{'input': 'averagePool2dInput'}], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor all negative default options', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - -83.87757873535156, -2.0740277767181396, -7.561108589172363, - -45.274261474609375, -16.36655616760254, -44.908512115478516, - -42.04186248779297, -44.77231979370117, -1.5066279172897339, - -52.65203857421875, -92.01856231689453, -48.004093170166016, - -61.522972106933594, -93.44403839111328, -25.780330657958984, - -95.51873779296875, -10.963757514953613, -59.132747650146484, - -32.60173797607422, -21.4510440826416, -87.115966796875, - -61.326114654541016, -41.989723205566406, -87.8764877319336, - -71.69316101074219, -80.24160766601562, -97.48886108398438, - -75.89422607421875, -45.08991622924805, -88.27134704589844, - -90.71282958984375, -93.32392120361328, -59.14753341674805, - -45.33106231689453, -51.32562255859375, -31.154796600341797, - -31.62424087524414, -62.80168151855469, -63.558509826660156, - -68.96183013916016, -43.09415054321289, -15.803443908691406, - -64.31092071533203, -66.45872497558594, -42.027252197265625, - -26.032955169677734, -22.73752784729004, -70.32036590576172, - -85.28227996826172, -92.10668182373047 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [{'input': 'averagePool2dInput'}], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [-49.258975982666016, -60.52408981323242], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.windowDimensions', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'windowDimensions': [3, 3]}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 43.46498107910156, 49.37273406982422, 42.7481689453125, - 50.038944244384766, 52.452327728271484, 58.46046447753906, - 32.15948486328125, 34.75465393066406, 54.00202560424805, - 49.65404510498047, 41.824440002441406, 35.84912109375, - 43.23125457763672, 37.842769622802734, 32.67961120605469, - 41.17021942138672, 42.79708480834961, 38.987247467041016 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'global averagePool2d float32 4D tensor all positive options.windowDimensions', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'windowDimensions': [5, 5]}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.padding', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'padding': [1, 0, 0, 1]}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 52.43666076660156, 49.84208297729492, 47.26926803588867, - 46.15715408325195, 46.63268280029297, 43.616947174072266, - 44.72445297241211, 44.05451583862305 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.strides', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 43.46498107910156, 42.7481689453125, 32.15948486328125, - 54.00202560424805, 49.65404510498047, 35.84912109375, - 41.17021942138672, 38.987247467041016 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.dilations', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [32.2001838684082, 42.971012115478516], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.layout=nchw', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': - [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nchw'}}], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.layout=nhwc', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 91.59549713134766, 78.15438079833984, - 65.64701080322266, 9.686111450195312, 55.14215087890625, - 51.298038482666016, 18.432437896728516, 32.193084716796875, - 49.34624099731445, 87.65037536621094, 15.648024559020996, - 87.25082397460938, 68.02723693847656, 39.49794006347656, - 20.342548370361328, 80.0996322631836, 26.727949142456055, - 10.220142364501953, 64.87446594238281, 52.602699279785156, - 46.5671501159668, 1.4128639698028564, 79.57833099365234, - 11.95406436920166, 4.33846378326416, 85.00074768066406, - 38.183837890625, 64.78374481201172, 45.25398254394531, - 88.03128814697266, 80.9718017578125, 11.333850860595703, - 67.58124542236328, 70.61659240722656, 6.0264997482299805, - 84.90442657470703, 29.7788143157959, 79.06687927246094, - 58.58993148803711, 7.3287248611450195, 2.2384984493255615, - 35.97796630859375, 14.50549030303955, 10.177306175231934, - 68.72449493408203, 1.4140757322311401, 76.45657348632812, - 78.10037994384766, 23.53263282775879 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': - [{'input': 'averagePool2dInput'}, {'options': {'layout': 'nhwc'}}], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'global averagePool2d float32 4D tensor options.layout=nhwc and options.windowDimensions', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 91.59549713134766, 78.15438079833984, - 65.64701080322266, 9.686111450195312, 55.14215087890625, - 51.298038482666016, 18.432437896728516, 32.193084716796875, - 49.34624099731445, 87.65037536621094, 15.648024559020996, - 87.25082397460938, 68.02723693847656, 39.49794006347656, - 20.342548370361328, 80.0996322631836, 26.727949142456055, - 10.220142364501953, 64.87446594238281, 52.602699279785156, - 46.5671501159668, 1.4128639698028564, 79.57833099365234, - 11.95406436920166, 4.33846378326416, 85.00074768066406, - 38.183837890625, 64.78374481201172, 45.25398254394531, - 88.03128814697266, 80.9718017578125, 11.333850860595703, - 67.58124542236328, 70.61659240722656, 6.0264997482299805, - 84.90442657470703, 29.7788143157959, 79.06687927246094, - 58.58993148803711, 7.3287248611450195, 2.2384984493255615, - 35.97796630859375, 14.50549030303955, 10.177306175231934, - 68.72449493408203, 1.4140757322311401, 76.45657348632812, - 78.10037994384766, 23.53263282775879 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, - {'options': {'windowDimensions': [5, 5], 'layout': 'nhwc'}} - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [47.26926803588867, 44.72445297241211], - 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.roundingType=floor', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 37.16582489013672, 50.038944244384766, - 58.46046447753906, 52.73374557495117, 39.1442985534668, - 43.23125457763672, 32.67961120605469 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'averagePool2d float32 4D tensor options.roundingType=ceil', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 37.16582489013672, 21.206613540649414, - 50.038944244384766, 58.46046447753906, 51.3569221496582, - 37.24428939819336, 54.04661178588867, 78.58363342285156, - 52.73374557495117, 39.1442985534668, 57.1103515625, - 43.23125457763672, 32.67961120605469, 56.23945999145508, - 40.00800323486328, 43.85149002075195, 41.061283111572266 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.roundingType=ceil and no padding', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656 - ], - 'descriptor': {shape: [1, 2, 4, 4], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'strides': [2, 2], - 'roundingType': 'ceil' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 51.20364761352539, 40.29140853881836, 50.77684020996094, - 51.70764923095703, 50.63130187988281, 49.3919792175293, - 53.128265380859375, 51.11610412597656 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.layout=nhwc and options.roundingType=floor', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 91.59549713134766, 78.15438079833984, - 65.64701080322266, 9.686111450195312, 55.14215087890625, - 51.298038482666016, 18.432437896728516, 32.193084716796875, - 49.34624099731445, 87.65037536621094, 15.648024559020996, - 87.25082397460938, 68.02723693847656, 39.49794006347656, - 20.342548370361328, 80.0996322631836, 26.727949142456055, - 10.220142364501953, 64.87446594238281, 52.602699279785156, - 46.5671501159668, 1.4128639698028564, 79.57833099365234, - 11.95406436920166, 4.33846378326416, 85.00074768066406, - 38.183837890625, 64.78374481201172, 45.25398254394531, - 88.03128814697266, 80.9718017578125, 11.333850860595703, - 67.58124542236328, 70.61659240722656, 6.0264997482299805, - 84.90442657470703, 29.7788143157959, 79.06687927246094, - 58.58993148803711, 7.3287248611450195, 2.2384984493255615, - 35.97796630859375, 14.50549030303955, 10.177306175231934, - 68.72449493408203, 1.4140757322311401, 76.45657348632812, - 78.10037994384766, 23.53263282775879 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'layout': 'nhwc', - 'roundingType': 'floor' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 52.73374557495117, 37.16582489013672, - 39.1442985534668, 50.038944244384766, 43.23125457763672, - 58.46046447753906, 32.67961120605469 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.layout=nhwc and options.roundingType=ceil', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 91.59549713134766, 78.15438079833984, - 65.64701080322266, 9.686111450195312, 55.14215087890625, - 51.298038482666016, 18.432437896728516, 32.193084716796875, - 49.34624099731445, 87.65037536621094, 15.648024559020996, - 87.25082397460938, 68.02723693847656, 39.49794006347656, - 20.342548370361328, 80.0996322631836, 26.727949142456055, - 10.220142364501953, 64.87446594238281, 52.602699279785156, - 46.5671501159668, 1.4128639698028564, 79.57833099365234, - 11.95406436920166, 4.33846378326416, 85.00074768066406, - 38.183837890625, 64.78374481201172, 45.25398254394531, - 88.03128814697266, 80.9718017578125, 11.333850860595703, - 67.58124542236328, 70.61659240722656, 6.0264997482299805, - 84.90442657470703, 29.7788143157959, 79.06687927246094, - 58.58993148803711, 7.3287248611450195, 2.2384984493255615, - 35.97796630859375, 14.50549030303955, 10.177306175231934, - 68.72449493408203, 1.4140757322311401, 76.45657348632812, - 78.10037994384766, 23.53263282775879 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'layout': 'nhwc', - 'roundingType': 'ceil' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 52.73374557495117, 37.16582489013672, - 39.1442985534668, 21.206613540649414, 57.1103515625, - 50.038944244384766, 43.23125457763672, 58.46046447753906, - 32.67961120605469, 51.3569221496582, 56.23945999145508, - 37.24428939819336, 40.00800323486328, 54.04661178588867, - 43.85149002075195, 78.58363342285156, 41.061283111572266 - ], - 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor', - 'outputSizes': [3, 3] - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 37.16582489013672, 21.206613540649414, - 50.038944244384766, 58.46046447753906, 51.3569221496582, - 37.24428939819336, 54.04661178588867, 78.58363342285156, - 52.73374557495117, 39.1442985534668, 57.1103515625, - 43.23125457763672, 32.67961120605469, 56.23945999145508, - 40.00800323486328, 43.85149002075195, 41.061283111572266 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 22.975555419921875, 78.15438079833984, 9.686111450195312, - 51.298038482666016, 32.193084716796875, 87.65037536621094, - 87.25082397460938, 39.49794006347656, 80.0996322631836, - 10.220142364501953, 52.602699279785156, 1.4128639698028564, - 11.95406436920166, 85.00074768066406, 64.78374481201172, - 88.03128814697266, 11.333850860595703, 70.61659240722656, - 84.90442657470703, 79.06687927246094, 7.3287248611450195, - 35.97796630859375, 10.177306175231934, 1.4140757322311401, - 78.10037994384766, 91.59549713134766, 65.64701080322266, - 55.14215087890625, 18.432437896728516, 49.34624099731445, - 15.648024559020996, 68.02723693847656, 20.342548370361328, - 26.727949142456055, 64.87446594238281, 46.5671501159668, - 79.57833099365234, 4.33846378326416, 38.183837890625, - 45.25398254394531, 80.9718017578125, 67.58124542236328, - 6.0264997482299805, 29.7788143157959, 58.58993148803711, - 2.2384984493255615, 14.50549030303955, 68.72449493408203, - 76.45657348632812, 23.53263282775879 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil', - 'outputSizes': [2, 2] - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 54.20252990722656, 37.16582489013672, 50.038944244384766, - 58.46046447753906, 52.73374557495117, 39.1442985534668, - 43.23125457763672, 32.67961120605469 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'averagePool2d float32 4D tensor options.dilations with options.strides', - 'graph': { - 'inputs': { - 'averagePool2dInput': { - 'data': [ - 70.71148681640625, 99.33489990234375, 76.41767883300781, - 39.40980911254883, 38.16328811645508, 45.971256256103516, - 65.3527603149414, 64.51607513427734, 7.725966930389404, - 41.7672004699707, 94.92633819580078, 53.475772857666016, - 95.46460723876953, 58.461795806884766, 15.831390380859375, - 78.41020202636719, 24.454092025756836, 20.630916595458984, - 32.06352233886719, 47.85192108154297, 91.60813903808594, - 72.3534927368164, 74.69429779052734, 28.860214233398438, - 71.82395935058594, 7.989691734313965, 88.16659545898438, - 58.69850540161133, 63.6061897277832, 55.88187789916992, - 52.809974670410156, 72.91474151611328, 46.957664489746094, - 22.10279655456543, 87.14309692382812, 89.6496810913086, - 63.19610595703125, 11.760882377624512, 70.68730926513672, - 57.70444107055664, 1.183821439743042, 25.26912498474121, - 95.29122924804688, 1.9658530950546265, 53.368465423583984, - 21.400854110717773, 55.86185836791992, 27.824508666992188, - 7.642839431762695, 82.34233093261719, 91.75215911865234, - 62.79155731201172, 28.11526107788086, 28.72478675842285, - 29.887035369873047, 66.4310302734375, 7.0103044509887695, - 34.33702087402344, 73.20159912109375, 7.8835601806640625, - 17.82563591003418, 33.799156188964844, 65.01251220703125, - 30.264028549194336, 75.76551818847656, 21.150800704956055, - 60.84249496459961, 98.56522369384766, 62.60990905761719, - 42.42991256713867, 53.142147064208984, 36.29545974731445, - 79.95863342285156, 79.60734558105469, 16.059114456176758, - 19.27552032470703, 53.93022918701172, 48.41620635986328, - 93.00965118408203, 62.086524963378906, 83.50532531738281, - 61.07964324951172, 75.51439666748047, 54.193782806396484, - 2.572873830795288, 59.47652053833008, 34.22541427612305, - 13.07015323638916, 12.419061660766602, 55.82337188720703, - 4.553813934326172, 63.47830581665039, 62.3555908203125, - 56.961090087890625, 34.77016067504883, 0.9611223936080933, - 35.30686950683594, 98.00790405273438 - ], - 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'averagePool2d', - 'arguments': [ - {'input': 'averagePool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'layout': 'nhwc' - } - } - ], - 'outputs': 'averagePool2dOutput' - }], - 'expectedOutputs': { - 'averagePool2dOutput': { - 'data': [ - 42.940242767333984, 55.268165588378906, 51.6013298034668, - 50.220027923583984, 72.13362884521484, 41.542198181152344, - 48.91604232788086, 38.775962829589844, 61.21329879760742, - 49.504154205322266, 57.72294998168945, 38.6922492980957, - 50.19099807739258, 29.15436363220215, 52.98439025878906, - 43.10562515258789, 66.77796936035156, 55.2725830078125 - ], - 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} - } - } - } - }, - - // l2Pool2d tests - { - 'name': 'l2Pool2d float32 4D constant tensor all positive default options', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, - 'constant': true - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [{'input': 'l2Pool2dInput'}], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [289.01953125, 292.6146545410156], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor default all positive options', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [{'input': 'l2Pool2dInput'}], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [289.01953125, 292.6146545410156], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor default all negative options', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - -1.1957088708877563, -9.706199645996094, -39.54935836791992, - -82.34971618652344, -32.87415313720703, -50.22603225708008, - -31.17849349975586, -55.817893981933594, -46.70829391479492, - -38.68181228637695, -63.299320220947266, -35.09224319458008, - -80.93848419189453, -82.8619613647461, -40.41627502441406, - -34.86458206176758, -84.33639526367188, -84.11852264404297, - -5.525088787078857, -99.03114318847656, -75.505126953125, - -91.43389129638672, -96.71258544921875, -16.722585678100586, - -17.98292350769043, -58.06570816040039, -11.846800804138184, - -97.90313720703125, -38.69822692871094, -80.19510650634766, - -48.72047805786133, -90.86722564697266, -99.10758209228516, - -79.70288848876953, -59.3824462890625, -9.967330932617188, - -39.27534866333008, -10.469644546508789, -27.565326690673828, - -2.0468990802764893, -81.88761901855469, -66.88040161132812, - -85.98504638671875, -29.674592971801758, -19.649417877197266, - -89.39192199707031, -61.13504409790039, -84.16869354248047, - -77.36112213134766, -91.17266082763672 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [{'input': 'l2Pool2dInput'}], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [298.928955078125, 326.83587646484375], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.windowDimensions', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, {'options': {'windowDimensions': [3, 3]}} - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 194.45481872558594, 189.54539489746094, 189.85488891601562, - 160.0518341064453, 167.1435546875, 149.63897705078125, - 161.15570068359375, 190.5449981689453, 168.4636688232422, - 170.331787109375, 155.60073852539062, 174.72145080566406, - 165.07762145996094, 165.45819091796875, 161.11062622070312, - 176.6307373046875, 174.245361328125, 180.60714721679688 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.padding', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 254.81358337402344, 233.14259338378906, 289.01953125, - 269.777587890625, 241.52200317382812, 212.99337768554688, - 292.6146545410156, 253.77178955078125 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.strides', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 194.45481872558594, 189.85488891601562, 161.15570068359375, - 168.4636688232422, 170.331787109375, 174.72145080566406, - 176.6307373046875, 180.60714721679688 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.dilations', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [189.47933959960938, 207.25343322753906], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.layout=nchw', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': - [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nchw'}}], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [289.01953125, 292.6146545410156], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.layout=nhwc', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 52.027313232421875, 76.55464172363281, - 6.397815227508545, 62.71847152709961, 84.54785919189453, - 83.8726577758789, 18.622516632080078, 73.10235595703125, - 34.10626220703125, 41.52470779418945, 73.96932220458984, - 39.3339729309082, 36.1437873840332, 86.59486389160156, - 60.73781967163086, 23.09039306640625, 55.09187316894531, - 53.650146484375, 63.8924446105957, 0.00902052316814661, - 59.36124038696289, 42.78899383544922, 50.91202926635742, - 81.03960418701172, 50.339813232421875, 33.48585510253906, - 59.31963348388672, 33.67196273803711, 70.78031921386719, - 0.42822372913360596, 35.56179428100586, 80.07991790771484, - 82.53382873535156, 5.929991722106934, 7.572360038757324, - 48.89164733886719, 61.90089416503906, 15.282920837402344, - 14.084012985229492, 13.335721969604492, 90.86540985107422, - 39.06557846069336, 39.56248474121094, 97.06050109863281, - 67.77167510986328, 83.68133544921875, 69.69512176513672, - 21.79571533203125, 89.54518127441406 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': - [{'input': 'l2Pool2dInput'}, {'options': {'layout': 'nhwc'}}], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [289.01953125, 292.6146545410156], - 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.roundingType=floor', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor' - } - } - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 171.5061492919922, 164.9919891357422, 160.0518341064453, - 149.63897705078125, 142.6990966796875, 139.51637268066406, - 165.07762145996094, 161.11062622070312 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.roundingType=ceil', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil' - } - } - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 171.5061492919922, 164.9919891357422, 90.6768569946289, - 160.0518341064453, 149.63897705078125, 65.15908813476562, - 132.56260681152344, 139.84808349609375, 26.61993408203125, - 142.6990966796875, 139.51637268066406, 72.42569732666016, - 165.07762145996094, 161.11062622070312, 96.38701629638672, - 150.1616668701172, 146.8201904296875, 90.64601135253906 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor', - 'outputSizes': [3, 3] - } - } - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 171.5061492919922, 164.9919891357422, 90.6768569946289, - 160.0518341064453, 149.63897705078125, 65.15908813476562, - 132.56260681152344, 139.84808349609375, 26.61993408203125, - 142.6990966796875, 139.51637268066406, 72.42569732666016, - 165.07762145996094, 161.11062622070312, 96.38701629638672, - 150.1616668701172, 146.8201904296875, 90.64601135253906 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 94.07447814941406, 76.55464172363281, 62.71847152709961, - 83.8726577758789, 73.10235595703125, 41.52470779418945, - 39.3339729309082, 86.59486389160156, 23.09039306640625, - 53.650146484375, 0.00902052316814661, 42.78899383544922, - 81.03960418701172, 33.48585510253906, 33.67196273803711, - 0.42822372913360596, 80.07991790771484, 5.929991722106934, - 48.89164733886719, 15.282920837402344, 13.335721969604492, - 39.06557846069336, 97.06050109863281, 83.68133544921875, - 21.79571533203125, 52.027313232421875, 6.397815227508545, - 84.54785919189453, 18.622516632080078, 34.10626220703125, - 73.96932220458984, 36.1437873840332, 60.73781967163086, - 55.09187316894531, 63.8924446105957, 59.36124038696289, - 50.91202926635742, 50.339813232421875, 59.31963348388672, - 70.78031921386719, 35.56179428100586, 82.53382873535156, - 7.572360038757324, 61.90089416503906, 14.084012985229492, - 90.86540985107422, 39.56248474121094, 67.77167510986328, - 69.69512176513672, 89.54518127441406 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil', - 'outputSizes': [2, 2] - } - } - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 171.5061492919922, 164.9919891357422, 160.0518341064453, - 149.63897705078125, 142.6990966796875, 139.51637268066406, - 165.07762145996094, 161.11062622070312 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'l2Pool2d float32 4D tensor options.dilations with options.strides', - 'graph': { - 'inputs': { - 'l2Pool2dInput': { - 'data': [ - 6.5550384521484375, 26.254413604736328, 28.47271156311035, - 64.81202697753906, 39.65838623046875, 10.465584754943848, - 47.94060134887695, 42.208946228027344, 36.834041595458984, - 68.50249481201172, 2.0496721267700195, 49.73927688598633, - 59.97947311401367, 71.08380889892578, 0.20033331215381622, - 19.39293670654297, 70.1269302368164, 86.8837661743164, - 84.28858184814453, 9.695697784423828, 62.69126510620117, - 51.924110412597656, 5.412675857543945, 70.82118225097656, - 81.61302947998047, 29.148712158203125, 85.83409881591797, - 71.36548614501953, 44.09445571899414, 58.343570709228516, - 43.37118148803711, 54.025882720947266, 85.50556945800781, - 93.19215393066406, 10.992993354797363, 34.864158630371094, - 96.2605209350586, 44.29584503173828, 61.12482833862305, - 79.62699127197266, 4.066447734832764, 64.89644622802734, - 97.5897445678711, 11.257055282592773, 61.151283264160156, - 20.312341690063477, 39.862640380859375, 68.747314453125, - 89.61034393310547, 22.28224754333496, 41.36311721801758, - 62.9378662109375, 79.54936218261719, 55.64254379272461, - 54.47548294067383, 77.04864501953125, 56.83576965332031, - 80.57747650146484, 70.43293762207031, 85.67094421386719, - 19.527807235717773, 33.87490463256836, 14.498117446899414, - 92.85955810546875, 96.8167724609375, 28.399721145629883, - 99.917236328125, 48.76692199707031, 86.08634948730469, - 47.32324981689453, 7.223662376403809, 82.97200775146484, - 38.374778747558594, 22.10988426208496, 14.797550201416016, - 2.3872148990631104, 83.26342010498047, 46.41500473022461, - 28.659175872802734, 13.919462203979492, 55.413089752197266, - 62.68498992919922, 78.54127502441406, 31.142845153808594, - 4.806727886199951, 33.233642578125, 24.749773025512695, - 1.529007077217102, 42.976322174072266, 93.08572387695312, - 77.908935546875, 45.74395751953125, 62.868892669677734, - 60.689762115478516, 20.046878814697266, 13.203198432922363, - 33.33952713012695, 0.5279953479766846 - ], - 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'l2Pool2d', - 'arguments': [ - {'input': 'l2Pool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'dilations': [1, 1], - 'layout': 'nhwc' - } - } - ], - 'outputs': 'l2Pool2dOutput' - }], - 'expectedOutputs': { - 'l2Pool2dOutput': { - 'data': [ - 120.20333862304688, 114.0977783203125, 127.63969421386719, - 119.95613861083984, 137.89837646484375, 152.24261474609375, - 194.9647216796875, 168.20205688476562, 197.7173309326172, - 169.85887145996094, 195.1484832763672, 190.96127319335938, - 158.64576721191406, 166.2051544189453, 171.07916259765625, - 148.70985412597656, 218.7123260498047, 153.33311462402344 - ], - 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} - } - } - } - }, - - // maxPool2d tests - { - 'name': 'maxPool2d float32 4D constant tensor default options', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'}, - 'constant': true - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [{'input': 'maxPool2dInput'}], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [99.28312683105469, 81.73119354248047], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor default options', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [{'input': 'maxPool2dInput'}], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [99.28312683105469, 81.73119354248047], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.windowDimensions', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, {'options': {'windowDimensions': [3, 3]}} - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 99.28312683105469, 66.09259033203125, - 99.28312683105469, 99.28312683105469, 72.1085205078125, - 97.90348052978516, 72.1085205078125, 72.1085205078125, - 81.73119354248047, 72.44898986816406, 72.44898986816406, - 81.73119354248047, 72.8883056640625, 72.44898986816406, - 80.30484008789062, 72.8883056640625, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.padding', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, {'options': {'padding': [1, 0, 0, 1]}} - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 99.28312683105469, 99.28312683105469, - 99.28312683105469, 81.73119354248047, 72.8883056640625, - 81.73119354248047, 72.8883056640625 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.strides', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'strides': [2, 2]}} - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 66.09259033203125, 97.90348052978516, - 72.1085205078125, 81.73119354248047, 72.44898986816406, - 80.30484008789062, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.dilations', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, - {'options': {'windowDimensions': [3, 3], 'dilations': [2, 2]}} - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [89.00830078125, 72.33577728271484], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.layout=nchw', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': - [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nchw'}}], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [99.28312683105469, 81.73119354248047], - 'descriptor': {shape: [1, 2, 1, 1], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.layout=nhwc', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -76.72171020507812, -45.72039031982422, - 50.217063903808594, -61.306129455566406, -52.895477294921875, - -4.014514446258545, -44.642333984375, -94.54893493652344, - -97.86752319335938, 46.28090286254883, 81.73119354248047, - 99.28312683105469, 5.428491115570068, -10.057873725891113, - -29.22772789001465, 9.742474555969238, 72.44898986816406, - -39.03501892089844, -59.34124755859375, 75.08192443847656, - 39.19960021972656, 12.819415092468262, -65.99439239501953, - -33.01505661010742, -4.204323768615723, 38.691341400146484, - -60.54586410522461, 66.09259033203125, 55.890525817871094, - 97.90348052978516, 80.30484008789062, -8.737770080566406, - 72.8883056640625, -53.42162322998047, -46.59611129760742, - 72.1085205078125, 20.50387954711914, -40.423091888427734, - -31.126462936401367, -35.68864440917969, -57.294559478759766, - -87.64779663085938, -26.623577117919922, 38.874244689941406, - 15.935754776000977, 39.383602142333984, -78.77953338623047, - 7.429088115692139, 72.33577728271484 - ], - 'descriptor': {shape: [1, 5, 5, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': - [{'input': 'maxPool2dInput'}, {'options': {'layout': 'nhwc'}}], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [99.28312683105469, 81.73119354248047], - 'descriptor': {shape: [1, 1, 1, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.roundingType=floor', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor' - } - } - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 9.742474555969238, 99.28312683105469, - 72.1085205078125, 81.73119354248047, 72.44898986816406, - 81.73119354248047, 72.44898986816406 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': 'maxPool2d float32 4D tensor options.roundingType=ceil', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil' - } - } - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 9.742474555969238, -39.03501892089844, - 99.28312683105469, 72.1085205078125, 66.09259033203125, - 97.90348052978516, 72.1085205078125, 7.429088115692139, - 81.73119354248047, 72.44898986816406, -59.34124755859375, - 81.73119354248047, 72.44898986816406, 55.890525817871094, - 80.30484008789062, 72.33577728271484, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'maxPool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'floor', - 'outputSizes': [3, 3] - } - } - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 9.742474555969238, -39.03501892089844, - 99.28312683105469, 72.1085205078125, 66.09259033203125, - 97.90348052978516, 72.1085205078125, 7.429088115692139, - 81.73119354248047, 72.44898986816406, -59.34124755859375, - 81.73119354248047, 72.44898986816406, 55.890525817871094, - 80.30484008789062, 72.33577728271484, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 3, 3], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'maxPool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 89.00830078125, -45.72039031982422, -61.306129455566406, - -4.014514446258545, -94.54893493652344, 46.28090286254883, - 99.28312683105469, -10.057873725891113, 9.742474555969238, - -39.03501892089844, 75.08192443847656, 12.819415092468262, - -33.01505661010742, 38.691341400146484, 66.09259033203125, - 97.90348052978516, -8.737770080566406, -53.42162322998047, - 72.1085205078125, -40.423091888427734, -35.68864440917969, - -87.64779663085938, 38.874244689941406, 39.383602142333984, - 7.429088115692139, -76.72171020507812, 50.217063903808594, - -52.895477294921875, -44.642333984375, -97.86752319335938, - 81.73119354248047, 5.428491115570068, -29.22772789001465, - 72.44898986816406, -59.34124755859375, 39.19960021972656, - -65.99439239501953, -4.204323768615723, -60.54586410522461, - 55.890525817871094, 80.30484008789062, 72.8883056640625, - -46.59611129760742, 20.50387954711914, -31.126462936401367, - -57.294559478759766, -26.623577117919922, 15.935754776000977, - -78.77953338623047, 72.33577728271484 - ], - 'descriptor': {shape: [1, 2, 5, 5], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'roundingType': 'ceil', - 'outputSizes': [2, 2] - } - } - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 99.28312683105469, 9.742474555969238, 99.28312683105469, - 72.1085205078125, 81.73119354248047, 72.44898986816406, - 81.73119354248047, 72.44898986816406 - ], - 'descriptor': {shape: [1, 2, 2, 2], dataType: 'float32'} - } - } - } - }, - { - 'name': - 'maxPool2d float32 4D tensor options.dilations with options.strides', - 'graph': { - 'inputs': { - 'maxPool2dInput': { - 'data': [ - 34.69258117675781, -24.706249237060547, -60.428070068359375, - 35.93883514404297, 60.896095275878906, 79.42220306396484, - -77.85906219482422, 54.188209533691406, -21.576934814453125, - -49.10390853881836, 78.55176544189453, 74.28213500976562, - -87.92769622802734, 79.82047271728516, 11.680922508239746, - -12.154505729675293, -22.33293914794922, 33.084861755371094, - 8.640676498413086, 47.040645599365234, 95.7823486328125, - -88.01998138427734, -98.53630065917969, 16.158977508544922, - 21.396089553833008, 95.1323471069336, -40.80724334716797, - -88.70922088623047, -40.772769927978516, 67.89842987060547, - -50.337467193603516, -96.56610870361328, 12.508098602294922, - -6.6358113288879395, -44.80198287963867, 80.27474212646484, - -65.68411254882812, -14.884790420532227, -66.54857635498047, - 20.072338104248047, -27.954269409179688, -56.62217330932617, - 82.7479476928711, 93.30175018310547, -34.073394775390625, - -22.87164306640625, 73.25525665283203, 41.14021682739258, - -19.75514793395996, 80.07701110839844, -69.89276885986328, - 14.013250350952148, -61.36640167236328, 51.53046417236328, - 43.53886413574219, -89.5888671875, 51.45121765136719, - 73.9239730834961, -80.25264739990234, 94.72747802734375, - 95.25411224365234, 58.12575149536133, 19.885723114013672, - -70.0301284790039, 63.419517517089844, -54.11785125732422, - -97.22807312011719, -60.65826416015625, -31.04998016357422, - -14.646553039550781, -63.73688888549805, 47.34630584716797, - 85.56405639648438, -53.389251708984375, -70.84739685058594, - 47.355045318603516, 83.38397979736328, 7.361695289611816, - 46.85823440551758, 98.13465881347656, -43.9396858215332, - 50.33780288696289, 37.45563507080078, -54.52760696411133, - -6.212307929992676, 34.41734313964844, 11.8167724609375, - 72.44517517089844, 86.3460922241211, 4.14656925201416, - 88.33040618896484, 98.29994201660156, -66.72379302978516, - 58.0643424987793, -51.168277740478516, -17.768583297729492, - 9.961172103881836, -52.73843002319336 - ], - 'descriptor': {shape: [1, 7, 7, 2], dataType: 'float32'} - } - }, - 'operators': [{ - 'name': 'maxPool2d', - 'arguments': [ - {'input': 'maxPool2dInput'}, { - 'options': { - 'windowDimensions': [3, 3], - 'padding': [1, 0, 0, 1], - 'strides': [2, 2], - 'dilations': [1, 1], - 'layout': 'nhwc' - } - } - ], - 'outputs': 'maxPool2dOutput' - }], - 'expectedOutputs': { - 'maxPool2dOutput': { - 'data': [ - 60.896095275878906, 79.42220306396484, 95.7823486328125, - 79.42220306396484, 78.55176544189453, 95.1323471069336, - 82.7479476928711, 93.30175018310547, 95.7823486328125, - 80.27474212646484, 43.53886413574219, 95.1323471069336, - 95.25411224365234, 94.72747802734375, 95.25411224365234, - 98.13465881347656, 63.419517517089844, 98.13465881347656 - ], - 'descriptor': {shape: [1, 3, 3, 2], dataType: 'float32'} - } - } - } - } -]; - -if (navigator.ml) { - poolingOperatorsTests.forEach((test) => { - webnn_conformance_test(buildAndExecuteGraph, getPrecisionTolerance, test); - }); -} else { - test(() => assert_implements(navigator.ml, 'missing navigator.ml')); -} diff --git a/tests/wpt/tests/webnn/conformance_tests/qdq_subgraph.https.any.js b/tests/wpt/tests/webnn/conformance_tests/qdq_subgraph.https.any.js index 996a6b472c5..a6155fb25ce 100644 --- a/tests/wpt/tests/webnn/conformance_tests/qdq_subgraph.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/qdq_subgraph.https.any.js @@ -2041,6 +2041,72 @@ const subgraphTests = [ } }, { + 'name': 'quantized argMax', + 'graph': { + 'inputs': { + 'input': { + 'data': [ + 2.549168109893799, 4.794857501983643, 7.413617134094238, + 8.413617134094238, 6.108623504638672, 3.549168109893799, + ], + 'descriptor': {shape: [2, 3], dataType: 'float32'}, + 'constant': false + }, + 'inputScale': { + 'data': [0.343092918395996], + 'descriptor': {shape: [1], dataType: 'float32'}, + 'constant': true + }, + 'inputZeroPoint': { + 'data': [-128], + 'descriptor': {shape: [1], dataType: 'int8'}, + 'constant': true + }, + 'outputScale': { + 'data': [0.343092918395996], + 'descriptor': {shape: [1], dataType: 'float32'}, + 'constant': true + }, + 'outputZeroPoint': { + 'data': [-128], + 'descriptor': {shape: [1], dataType: 'int8'}, + 'constant': true + }, + }, + 'operators': [ + { + 'name': 'quantizeLinear', + 'arguments': [ + {'input': 'input'}, + {'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'} + ], + 'outputs': 'quantizedInput' + }, + { + 'name': 'dequantizeLinear', + 'arguments': [ + {'input': 'quantizedInput'}, + {'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'} + ], + 'outputs': 'dequantizedInput' + }, + { + 'name': 'argMax', + 'arguments': [{'input': 'dequantizedInput'}, {'axis': 0}], + 'outputs': 'output' + }, + ], + 'expectedOutputs': { + 'output': { + 'data': [ + 1, 1, 0, + ], + 'descriptor': {shape: [3], dataType: 'int32'} + } + } + } + }, + { 'name': 'quantized softmax', 'graph': { 'inputs': { @@ -2540,6 +2606,176 @@ const subgraphTests = [ } } }, + { + 'name': 'quantized pad with reflection mode', + 'graph': { + 'inputs': { + 'input': { + 'data': [ + 1.6811466217041016, 0.0479511022567749, 0.33355462551116943, + -0.1988269537687301, -0.0041167140007019, -0.0634240251779556, + ], + 'descriptor': {shape: [2, 3], dataType: 'float32'}, + 'constant': false + }, + 'inputScale': { + 'data': [0.003921568859368563], + 'descriptor': {shape: [1], dataType: 'float32'}, + 'constant': true + }, + 'inputZeroPoint': { + 'data': [0], + 'descriptor': {shape: [1], dataType: 'int8'}, + 'constant': true + }, + 'outputScale': { + 'data': [0.003921568859368563], + 'descriptor': {shape: [1], dataType: 'float32'}, + 'constant': true + }, + 'outputZeroPoint': { + 'data': [0], + 'descriptor': {shape: [1], dataType: 'int8'}, + 'constant': true + }, + }, + 'operators': [ + { + 'name': 'quantizeLinear', + 'arguments': [ + {'input': 'input'}, + {'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'} + ], + 'outputs': 'quantizedInput' + }, + { + 'name': 'dequantizeLinear', + 'arguments': [ + {'input': 'quantizedInput'}, + {'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'} + ], + 'outputs': 'dequantizedInput' + }, + { + 'name': 'pad', + 'arguments': [ + {'input': 'dequantizedInput'}, {'beginningPadding': [1, 2]}, + {'endingPadding': [1, 2]}, {'options': {'mode': 'reflection'}} + ], + 'outputs': 'padOutput' + }, + { + 'name': 'quantizeLinear', + 'arguments': [ + {'input': 'padOutput'}, + {'scale': 'outputScale', 'zeroPoint': 'outputZeroPoint'} + ], + 'outputs': 'quantizedPadOutput' + }, + { + 'name': 'dequantizeLinear', + 'arguments': [ + {'input': 'quantizedPadOutput'}, + {'scale': 'outputScale', 'zeroPoint': 'outputZeroPoint'} + ], + 'outputs': 'output' + } + ], + 'expectedOutputs': { + 'output': { + 'data': [ + -0.062745101749897, -0.003921568859368563, -0.20000001788139343, + -0.003921568859368563, -0.062745101749897, -0.003921568859368563, + -0.20000001788139343, 0.3333333432674408, 0.0470588281750679, + 0.49803924560546875, 0.0470588281750679, 0.3333333432674408, + 0.0470588281750679, 0.49803924560546875, -0.062745101749897, + -0.003921568859368563, -0.20000001788139343, -0.003921568859368563, + -0.062745101749897, -0.003921568859368563, -0.20000001788139343, + 0.3333333432674408, 0.0470588281750679, 0.49803924560546875, + 0.0470588281750679, 0.3333333432674408, 0.0470588281750679, + 0.49803924560546875, + ], + 'descriptor': {shape: [4, 7], dataType: 'float32'} + } + } + } + }, + { + 'name': 'quantized clamp', + 'graph': { + 'inputs': { + 'input': { + 'data': [ + 8.413617134094238, 6.108623504638672, 3.549168109893799, + 1.6811466217041016, -0.1988269537687301, -8.413617134094238, + ], + 'descriptor': {shape: [2, 3], dataType: 'float32'}, + 'constant': false + }, + 'scale': { + 'data': [0.343092918395996], + 'descriptor': {shape: [1], dataType: 'float32'}, + 'constant': true + }, + 'zeroPoint': { + 'data': [0], + 'descriptor': {shape: [1], dataType: 'int8'}, + 'constant': true + }, + }, + 'operators': [ + { + 'name': 'quantizeLinear', + 'arguments': [ + {'input': 'input'}, + {'scale': 'scale', 'zeroPoint': 'zeroPoint'} + ], + 'outputs': 'quantizedInput' + }, + { + 'name': 'dequantizeLinear', + 'arguments': [ + {'input': 'quantizedInput'}, + {'scale': 'scale', 'zeroPoint': 'zeroPoint'} + ], + 'outputs': 'dequantizedInput' + }, + { + 'name': 'clamp', + 'arguments': [ + {'input': 'dequantizedInput'}, + {'options': {'minValue': 0, 'maxValue': 6}} + ], + 'outputs': 'clampOutput' + }, + { + 'name': 'quantizeLinear', + 'arguments': [ + {'input': 'clampOutput'}, + {'scale': 'scale', 'zeroPoint': 'zeroPoint'} + ], + 'outputs': 'quantizedClampOutput' + }, + { + 'name': 'dequantizeLinear', + 'arguments': [ + {'input': 'quantizedClampOutput'}, + {'scale': 'scale', 'zeroPoint': 'zeroPoint'} + ], + 'outputs': 'output' + } + ], + 'expectedOutputs': { + 'output': { + 'data': [ + 5.832579612731934, 5.832579612731934, 3.430929183959961, + 1.7154645919799805, 0, 0, + ], + 'descriptor': {shape: [2, 3], dataType: 'float32'} + } + } + } + }, ]; if (navigator.ml) { diff --git a/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-audiolevel.html b/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-audiolevel.html new file mode 100644 index 00000000000..14b76efb575 --- /dev/null +++ b/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-audiolevel.html @@ -0,0 +1,79 @@ +<!doctype html> +<meta charset=utf-8> +<title>Audio Level in RTCEncodedAudioFrameMetadata</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/webrtc/RTCPeerConnection-helper.js"></script> +<script src="RTCEncodedFrame-timestamps-helper.js"></script> +<script> +'use strict'; + +function doWorkExpectingAudioLevel() { + onrtctransform = async e => { + const reader = e.transformer.readable.getReader(); + const writer = e.transformer.writable.getWriter(); + for (let i = 0; i<10; i++) { + const frameOrDone = await reader.read(); + if (frameOrDone.done) { + self.postMessage("Unexpected end of stream"); + return; + } + const metadata = frameOrDone.value.getMetadata(); + if (metadata === undefined) { + self.postMessage("No audioLevel "); + return; + } + if (metadata.audioLevel < 0 || metadata.audioLevel > 1) { + self.postMessage("Invalid audioLevel value"); + return; + } + if (metadata.senderCaptureTimeOffset != 0) { + await writer.write(frameOrDone.value); + } + } + self.postMessage("OK"); + }; +} + +promise_test(async t => { + const worker = new Worker(`data:text/javascript,(${doWorkExpectingAudioLevel.toString()})()`); + const workerPromise = new Promise((resolve, reject) => { + worker.onmessage = t.step_func(message => { + if (message.data == "OK") { + resolve(); + } else { + reject(message.data); + } + }); + }); + + await initiateCall( + t, /*streamOptions=*/{audio: true, video: false}, + /*enableAbsCaptureTime=*/false, worker, /*enableSenderTransform=*/false, + /*enableReceiverTransform=*/true); + + return workerPromise; +}, 'audioLevel present in audio receiver'); + +promise_test(async t => { + const worker = new Worker(`data:text/javascript,(${doWorkExpectingAudioLevel.toString()})()`); + const workerPromise = new Promise((resolve, reject) => { + worker.onmessage = t.step_func(message => { + if (message.data == "OK") { + resolve(); + } else { + reject(message.data); + } + }); + }); + + await initiateCall( + t, /*streamOptions=*/{audio: true, video: false}, + /*enableAbsCaptureTime=*/false, worker, /*enableSenderTransform=*/true, + /*enableReceiverTransform=*/false); + + return workerPromise; +}, 'audioLevel present in audio sender'); + + +</script> diff --git a/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-metadata.https.html b/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-metadata.https.html index 1e148fe1b29..b9461940c63 100644 --- a/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-metadata.https.html +++ b/tests/wpt/tests/webrtc-encoded-transform/tentative/RTCEncodedAudioFrame-metadata.https.html @@ -42,6 +42,8 @@ promise_test(async t => { assert_equals(original.getMetadata().rtpTimestamp, newFrame.getMetadata().rtpTimestamp); assert_equals(original.getMetadata().captureTime, newFrame.getMetadata().captureTime); assert_equals(original.getMetadata().receiveTime, newFrame.getMetadata().receiveTime); + assert_true(original.getMetadata().hasOwnProperty('audioLevel')); + assert_equals(original.getMetadata().audioLevel, newFrame.getMetadata().audioLevel); assert_array_equals(Array.from(original.data), Array.from(newFrame.data)); await writer2.write(newFrame); resolve(); @@ -85,6 +87,7 @@ promise_test(async t => { assert_equals(newMetadata.rtpTimestamp, newFrame.getMetadata().rtpTimestamp); assert_equals(original.getMetadata().receiveTime, newFrame.getMetadata().receiveTime); assert_equals(original.getMetadata().captureTime, newFrame.getMetadata().captureTime); + assert_equals(original.getMetadata().audioLevel, newFrame.getMetadata().audioLevel); assert_array_equals(Array.from(original.data), Array.from(newFrame.data)); await writer2.write(newFrame); resolve(); @@ -133,6 +136,7 @@ promise_test(async t => { }, "Constructing audio frame with bad metadata argument before sending does not work"); promise_test(async t => { + const kAudioLevel = 0.5; const kCaptureTime = 12345; const pc1 = new RTCPeerConnection({encodedInsertableStreams:true}); t.add_cleanup(() => pc1.close()); @@ -147,6 +151,11 @@ promise_test(async t => { const receiverTransformer = new TransformStream({ async transform(encodedFrame, controller) { const metadata = encodedFrame.getMetadata(); + if (metadata.audioLevel === undefined) { + reject("No audioLevel"); + } else if (metadata.audioLevel < kAudioLevel - 0.1 || metadata.audioLevel > kAudioLevel + 0.1) { + reject("Unexpected audioLevel"); + } if (metadata.captureTime < kCaptureTime - 1 || metadata.captureTime > kCaptureTime + 1) { reject("Unexpected captureTime"); } @@ -169,6 +178,7 @@ promise_test(async t => { const senderTransformer = new TransformStream({ async transform(encodedFrame, controller) { let metadata = encodedFrame.getMetadata(); + metadata.audioLevel = kAudioLevel; metadata.captureTime = kCaptureTime; controller.enqueue(new RTCEncodedAudioFrame(encodedFrame, {metadata})); } diff --git a/tests/wpt/tests/webrtc/protocol/h264-unidirectional-codec-offer.https.html b/tests/wpt/tests/webrtc/protocol/h264-unidirectional-codec-offer.https.html index 708d59e5242..d5429fa80fa 100644 --- a/tests/wpt/tests/webrtc/protocol/h264-unidirectional-codec-offer.https.html +++ b/tests/wpt/tests/webrtc/protocol/h264-unidirectional-codec-offer.https.html @@ -3,7 +3,6 @@ <title>RTX codec integrity checks</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> -<script src="../RTCPeerConnection-helper.js"></script> <script> 'use strict'; @@ -52,61 +51,35 @@ function getCodecsWithDirection(mimeType, direction) { return codecs; } -// Returns an array of { mimeType, payloadType, sdpFmtpLine } entries in the -// order that they appeared in the SDP. +// Returns an array of { mimeType, payloadType, sdpFmtpLine } entries in codec +// preference order from the first m-section of the SDP. function parseCodecsFromSdp(sdp) { const codecs = []; - // For each a=rtpmap:... - const kRtpMapLineRegex = /\r\na=rtpmap:/g; - for (const match of sdp.matchAll(kRtpMapLineRegex)) { - const rtpmapIndex = match.index + 11; - const rtpmapSpaceIndex = sdp.indexOf(' ', rtpmapIndex) - const payloadType = Number(sdp.slice(rtpmapIndex, rtpmapSpaceIndex)); - const codecName = sdp.slice(rtpmapSpaceIndex + 1, - sdp.indexOf('/', rtpmapSpaceIndex)); - let sdpFmtpLine = undefined; // Can be undefined e.g. VP8. - const fmtpLineWithPT = `\r\na=fmtp:${payloadType} `; - let fmtpIndex = sdp.indexOf(fmtpLineWithPT, rtpmapIndex); - if (fmtpIndex != -1) { - fmtpIndex += fmtpLineWithPT.length; - const fmtpLineEnd = sdp.indexOf('\r\n', fmtpIndex); - if (fmtpLineEnd == -1) { - throw 'Parse error: Missing expected end of FMTP line'; - } - sdpFmtpLine = sdp.slice(fmtpIndex, fmtpLineEnd); - } - const codec = { mimeType: `video/${codecName}`, payloadType, sdpFmtpLine }; + const kMLineRegex = /\r\nm=video \d+ [A-Z\/]+ (?<pts>[\d\s]+)\r\n/; + const {groups: {pts}} = kMLineRegex.exec(sdp); + for (const pt of pts.split(" ")) { + const rtpmapRegex = new RegExp(`\r\na=rtpmap:${pt} (?<name>[^ \/]+)\/`); + const {groups: {name}} = rtpmapRegex.exec(sdp); + const fmtpRegex = new RegExp(`\r\na=fmtp:${pt} (?<sdpFmtpLine>.*)\r\n`); + // Guard against there not being an fmtp line. + const {groups: {sdpFmtpLine} = {}} = fmtpRegex.exec(sdp) ?? {}; + const codec = { mimeType: `video/${name}`, payloadType: pt, sdpFmtpLine }; codecs.push(codec); } return codecs; } -function replaceAllInSubstr( - str, startIndex, endIndex, pattern, replacement) { - return str.slice(0, startIndex) + - str.slice(startIndex, endIndex).replaceAll(pattern, replacement) + - str.slice(endIndex); -} - function replaceCodecInSdp(sdp, oldCodec, newCodec) { // Replace the payload type in the m=video line. - const mVideoStartIndex = sdp.indexOf('m=video'); - const mVideoEndIndex = sdp.indexOf('\r\n', mVideoStartIndex); - if (mVideoStartIndex == -1 || mVideoEndIndex == -1) { - throw 'Failed to parse m=video line in the codec replace algorithm'; - } - sdp = replaceAllInSubstr( - sdp, mVideoStartIndex, mVideoEndIndex, String(oldCodec.payloadType), - String(newCodec.payloadType)); - // Replace the payload type in all the RTP map and FMTP lines. - const rtpStartIndex = sdp.indexOf('a=rtpmap:' + oldCodec.payloadType); - const rtpEndIndex = sdp.indexOf(oldCodec.sdpFmtpLine); - if (rtpStartIndex == -1 || rtpEndIndex == -1) { - throw 'Failed to parse RTP/FMTP lines in the codec replace algorithm'; - } - sdp = replaceAllInSubstr( - sdp, rtpStartIndex, rtpEndIndex, ':' + oldCodec.payloadType, - ':' + newCodec.payloadType); + sdp = sdp.replace( + new RegExp(`(m=video [ \\dA-Z\/]+)${oldCodec.payloadType}`), + `$1${newCodec.payloadType}` + ); + // Replace the payload type in all rtpmap, fmtp and rtcp-fb lines. + sdp = sdp.replaceAll( + new RegExp(`(a=(rtpmap|fmtp|rtcp-fb):)${oldCodec.payloadType}`, "g"), + `$1${newCodec.payloadType}` + ); // Lastly, replace the actual "sdpFmtpLine" string. sdp = sdp.replace(oldCodec.sdpFmtpLine, newCodec.sdpFmtpLine); return sdp; @@ -173,6 +146,7 @@ promise_test(async t => { t.add_cleanup(() => pc.close()); const h264RecvOnlyCodecs = getCodecsWithDirection('video/H264', 'recvonly'); + const h264SendOnlyCodecs = getCodecsWithDirection('video/H264', 'sendonly'); const vp8SendRecvCodecs = getCodecsWithDirection('video/VP8', 'sendrecv'); // If any of the following optional asserts fail the test ends with // [PRECONDITION_FAILED] as opposed to [FAIL]. @@ -182,15 +156,40 @@ promise_test(async t => { assert_implements_optional( vp8SendRecvCodecs.length > 0, `There are no sendrecv VP8 codecs available in getCapabilities.`); - // Pick a level (3.1) that we're required to support for both sending and - // receiving. If such a codec is listed in `h264RecvOnlyCodecs` that means our - // sender capability has an even greater level. - const h264RecvOnlyCodec = h264RecvOnlyCodecs.find( - codec => codec.sdpFmtpLine.includes('profile-level-id=64001f')); + // Find a recvonly codec with the required level (3.1) for both sending and + // receiving, that has a corresponding sendonly codec with the same profile + // but a higher level. If there is such a match, we should be able to use the + // lower level of the two for sendrecv. + const kProfileLevelIdRegex = + /profile-level-id=(?<profile_idc>..)(?<profile_iop>..)(?<level_idc>..)/; + const kProfileLevelIdReqLevelRegex = /profile-level-id=....1f/; + const h264RecvOnlyReqLevelCodecs = h264RecvOnlyCodecs.filter( + codec => codec.sdpFmtpLine.match(kProfileLevelIdReqLevelRegex)); + const h264RecvOnlyCodec = h264RecvOnlyReqLevelCodecs.find(recv => { + const {groups: { + profile_idc: recvProfile, + profile_iop: recvConstraints, + level_idc: recvLevelIdc, + } + } = kProfileLevelIdRegex.exec(recv.sdpFmtpLine); + const recvLevel = parseInt(recvLevelIdc, 16); + return h264SendOnlyCodecs.find(send => { + const {groups: { + profile_idc: sendProfile, + profile_iop: sendConstraints, + level_idc: sendLevelIdc, + } + } = kProfileLevelIdRegex.exec(send.sdpFmtpLine); + const sendLevel = parseInt(sendLevelIdc, 16); + return sendProfile == recvProfile && + sendConstraints == recvConstraints && + sendLevelIdc > recvLevelIdc; + }); + }); assert_implements_optional( h264RecvOnlyCodec != undefined, - `profile-level-id=64001f is not exclusive to ` + - `RTCRtpReceiver.getCapabilities.`); + `No recvonly profile-level-id=....1f that matches a higher level ` + + `sendonly codec`); const vp8SendRecvCodec = vp8SendRecvCodecs[0]; const transceiver = pc.addTransceiver('video', {direction: 'sendrecv'}); |