Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/WebKit/WebKit
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 11, 2025
2 parents 60477ef + 29a03fe commit adda519
Show file tree
Hide file tree
Showing 693 changed files with 11,386 additions and 4,314 deletions.
17 changes: 17 additions & 0 deletions JSTests/stress/array-prototype-indexOf-string-use.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function sameValue(a, b) {
if (a !== b)
throw new Error(`Expected ${b} but got ${a}`);
}

function test(array, value) {
return array.indexOf(value);
}
noInline(test);

print(testLoopCount);

var array = [1, 2, 3.4, "foo", 5, 6, 6, 4];
for (let i = 0; i < testLoopCount; i++) {
sameValue(test(array, "foo"), 3);
sameValue(test(array, "bar"), -1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
function shouldBe(a, b) {
if (a !== b)
throw new Error(`Expected ${b} but got ${a}`);
}


function shouldThrowAsync(run, errorType, message) {
let actual;
var hadError = false;
run().then(function(value) { actual = value; },
function(error) { hadError = true; actual = error; });
drainMicrotasks();
if (!hadError)
throw new Error("Expected " + run + "() to throw " + errorType.name + ", but did not throw.");
if (!(actual instanceof errorType))
throw new Error("Expected " + run + "() to throw " + errorType.name + ", but threw '" + actual + "'");
if (message !== void 0 && actual.message !== message)
throw new Error("Expected " + run + "() to throw '" + message + "', but threw '" + actual.message + "'");
}

{
let finallyCount = 0;

function OurError() {}

function* iterator() {
try {
yield Promise.reject(new OurError());
} finally {
finallyCount += 1;
}
}

shouldThrowAsync(async () => {
for await (const _ of iterator());
}, OurError);
drainMicrotasks();

shouldBe(finallyCount, 1);
}

{
let returnCount = 0;

function OurError() {}

const syncIterator = {
[Symbol.iterator]() {
return {
next() {
return { value: Promise.reject(new OurError()), done: false };
},
return() {
returnCount += 1;
}
};
}
};

shouldThrowAsync(async () => {
for await (const _ of syncIterator);
}, OurError);
drainMicrotasks();

shouldBe(returnCount, 1);
}

{
let finallyCount = 0;

function OurError() {}

function* iterator() {
try {
yield Promise.reject(new OurError());
} finally {
finallyCount += 1;
}
}

async function* asyncIterator() {
yield* iterator()
}

shouldThrowAsync(async () => {
await asyncIterator().next();
}, OurError);
drainMicrotasks();

shouldBe(finallyCount, 1);

}

{
let returnCount = 0;

function OurError() {}

const syncIterator = {
[Symbol.iterator]() {
return {
next() {
return { value: Promise.reject(new OurError()), done: false };
},
return() {
returnCount += 1;
}
};
}
};

async function* asyncIterator() {
yield* syncIterator;
}

shouldThrowAsync(async () => {
await asyncIterator().next();
}, OurError);
drainMicrotasks();

shouldBe(returnCount, 1);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function shouldBe(a, b) {
if (a !== b)
throw new Error(`Expected ${b} but got ${a}`);
}


function shouldThrowAsync(run, errorType, message) {
let actual;
var hadError = false;
run().then(function(value) { actual = value; },
function(error) { hadError = true; actual = error; });
drainMicrotasks();
if (!hadError)
throw new Error("Expected " + run + "() to throw " + errorType.name + ", but did not throw.");
if (!(actual instanceof errorType))
throw new Error("Expected " + run + "() to throw " + errorType.name + ", but threw '" + actual + "'");
if (message !== void 0 && actual.message !== message)
throw new Error("Expected " + run + "() to throw '" + message + "', but threw '" + actual.message + "'");
}

{
let returnCount = 0;

function OurError() {}

var iterator = {
[Symbol.iterator]() {
return {
next() {
return { value: 1, done: false };
},
throw() {
return {
value: Promise.reject(new OurError()),
done: false
};
},
return() {
returnCount += 1;
}
};
}
};

async function* asyncIterator() {
return yield* iterator;
}

let iter = asyncIterator();

shouldThrowAsync(async () => {
await iter.next();
await iter.throw();
}, OurError);
drainMicrotasks();

shouldBe(returnCount, 1);
}

24 changes: 0 additions & 24 deletions JSTests/test262/expectations.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
---
test/annexB/language/function-code/block-decl-func-skip-arguments.js:
default: 'Test262Error: Expected SameValue(«"function arguments() {}"», «"[object Arguments]"») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-iterator-next-rejected-promise-close.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-next-rejected-promise-close.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/next-result-poisoned-wrapper.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/yield-iterator-next-rejected-promise-close.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/next/yield-next-rejected-promise-close.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: Expected SameValue(«0», «1») to be true'
test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js:
default: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
strict mode: 'Test262:AsyncTestFailure:Test262Error: Test262Error: iterator closed properly Expected SameValue(«0», «1») to be true'
test/built-ins/Date/prototype/setHours/date-value-read-before-tonumber-when-date-is-invalid.js:
default: 'Test262Error: time updated in valueOf Expected SameValue(«NaN», «0») to be true'
strict mode: 'Test262Error: time updated in valueOf Expected SameValue(«NaN», «0») to be true'
Expand Down
88 changes: 36 additions & 52 deletions JSTests/wasm/gc/const-exprs.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,68 +219,52 @@ async function testInvalidConstExprs() {
}

async function testConstExprGlobalOrdering() {
assert.throws(
() => compile(`
(module
(global i32 (i32.const 0))
(global i32 (global.get 0)))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 24: get_global import kind index 0 is non-import"
);
instantiate(`
(module
(global i32 (i32.const 0))
(global i32 (global.get 0)))
`);

assert.throws(
() => compile(`
(module
(global i32 (i32.const 0))
(global i32 (i32.const 1))
(global i32 (i32.const 2))
(global i32 (global.get 1))
(global i32 (global.get 3)))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 34: get_global import kind index 1 is non-import"
);
instantiate(`
(module
(global i32 (i32.const 0))
(global i32 (i32.const 1))
(global i32 (i32.const 2))
(global i32 (global.get 1))
(global i32 (global.get 3)))
`);

assert.throws(
() => compile(`
(module
(global i32 (i32.add (i32.const 0) (i32.const 1)))
(global (export "g") i32 (i32.add (i32.const 1 (global.get 0)))))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 27: get_global import kind index 0 is non-import"
);
{
let m = instantiate(`
(module
(global i32 (i32.add (i32.const 0) (i32.const 1)))
(global (export "g") i32 (i32.add (i32.const 1 (global.get 0)))))
`);

assert.eq(m.exports.g.value, 2);
}

instantiate(`
(module
(global (import "m" "g") externref)
(table 10 externref (global.get 0)))
`, { m: { g: "foo" } });

assert.throws(
() => compile(`
(module
(global i32 (i32.const 0))
(global i32 (i32.const 1))
(global i32 (i32.const 2))
(global i32 (global.get 1))
(global i32 (global.get 3)))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 34: get_global import kind index 1 is non-import"
);
instantiate(`
(module
(global i32 (i32.const 0))
(global i32 (i32.const 1))
(global i32 (i32.const 2))
(global i32 (global.get 1))
(global i32 (global.get 3)))
`);

assert.throws(
() => compile(`
(module
(table (export "t") 64 funcref)
(global i32 (i32.const 5))
(elem (table 0) (offset (i32.add (global.get 0) (i32.const 42))) funcref (ref.null func)))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 52: get_global import kind index 0 is non-import"
);
instantiate(`
(module
(table (export "t") 64 funcref)
(global i32 (i32.const 5))
(elem (table 0) (offset (i32.add (global.get 0) (i32.const 42))) funcref (ref.null func)))
`);

assert.throws(
() => compile(`
Expand Down
20 changes: 8 additions & 12 deletions JSTests/wasm/gc/simd.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,14 @@ function testJSAPI() {
}

function testSIMDGlobal() {
assert.throws(
() => compile(`
(module
(global v128 (v128.const i64x2 0 0))
(global v128 (v128.const i64x2 1 1))
(global v128 (v128.const i64x2 2 2))
(global v128 (global.get 1))
(global v128 (global.get 3)))
`),
WebAssembly.CompileError,
"WebAssembly.Module doesn't parse at byte 82: get_global import kind index 1 is non-import"
);
instantiate(`
(module
(global v128 (v128.const i64x2 0 0))
(global v128 (v128.const i64x2 1 1))
(global v128 (v128.const i64x2 2 2))
(global v128 (global.get 1))
(global v128 (global.get 3)))
`);
}

testSIMDStruct();
Expand Down
19 changes: 0 additions & 19 deletions JSTests/wasm/stress/init-expr-cannot-include-non-import-globals.js

This file was deleted.

Loading

0 comments on commit adda519

Please sign in to comment.