mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
Merge pull request #1375 from lightpanda-io/nikneym/audio-constructor
Some checks failed
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-test / zig build release (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
e2e-test / zig build release (push) Has been cancelled
e2e-integration-test / zig build release (push) Has been cancelled
e2e-integration-test / demo-integration-scripts (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Add `Audio` constructor
This commit is contained in:
@@ -238,6 +238,15 @@
|
||||
testing.expectEqual('[object HTMLAudioElement]', audio.toString());
|
||||
testing.expectEqual(true, audio.paused);
|
||||
}
|
||||
|
||||
// Create with `Audio` constructor.
|
||||
{
|
||||
const audio = new Audio();
|
||||
testing.expectEqual(true, audio instanceof HTMLAudioElement);
|
||||
testing.expectEqual("[object HTMLAudioElement]", audio.toString());
|
||||
testing.expectEqual(true, audio.paused);
|
||||
testing.expectEqual("auto", audio.getAttribute("preload"));
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="create_video_element">
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const js = @import("../../../js/js.zig");
|
||||
const Page = @import("../../../Page.zig");
|
||||
|
||||
const Node = @import("../../Node.zig");
|
||||
const Element = @import("../../Element.zig");
|
||||
@@ -26,6 +27,21 @@ const Audio = @This();
|
||||
|
||||
_proto: *Media,
|
||||
|
||||
pub fn constructor(maybe_url: ?[]const u8, page: *Page) !*Media {
|
||||
const node = try page.createElementNS(.html, "audio", null);
|
||||
const el = node.as(Element);
|
||||
|
||||
const list = try el.getOrCreateAttributeList(page);
|
||||
// Always set to "auto" initially.
|
||||
_ = try list.putSafe("preload", "auto", el, page);
|
||||
// Set URL if provided.
|
||||
if (maybe_url) |url| {
|
||||
_ = try list.putSafe("src", url, el, page);
|
||||
}
|
||||
|
||||
return node.as(Media);
|
||||
}
|
||||
|
||||
pub fn asMedia(self: *Audio) *Media {
|
||||
return self._proto;
|
||||
}
|
||||
@@ -43,7 +59,10 @@ pub const JsApi = struct {
|
||||
|
||||
pub const Meta = struct {
|
||||
pub const name = "HTMLAudioElement";
|
||||
pub const constructor_alias = "Audio";
|
||||
pub const prototype_chain = bridge.prototypeChain();
|
||||
pub var class_id: bridge.ClassId = undefined;
|
||||
};
|
||||
|
||||
pub const constructor = bridge.constructor(Audio.constructor, .{});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user