LibWeb/WebGL: Don't crash on unknown getParameter on the context

And allow the implementation to set the error code.
This commit is contained in:
Andrew Kaster 2024-12-05 23:30:17 -07:00 committed by Alexander Kalenik
parent af536e1192
commit 56d45282ea
Notes: github-actions[bot] 2024-12-06 14:36:34 +00:00
3 changed files with 6 additions and 3 deletions

View file

@ -73,7 +73,7 @@ private:
GLenum m_error { 0 };
void set_error(GLenum error);
virtual void set_error(GLenum error) override;
};
}

View file

@ -72,7 +72,7 @@ private:
GLenum m_error { 0 };
void set_error(GLenum error);
virtual void set_error(GLenum error) override;
};
void fire_webgl_context_event(HTML::HTMLCanvasElement& canvas_element, FlyString const& type);

View file

@ -231,7 +231,9 @@ static void generate_get_parameter(SourceGenerator& generator)
generator.appendln(R"~~~(
default:
TODO();
dbgln("Unknown WebGL parameter name: {:x}", pname);
set_error(GL_INVALID_ENUM);
return JS::js_null();
})~~~");
}
@ -389,6 +391,7 @@ public:
virtual void present() = 0;
virtual void needs_to_present() = 0;
virtual void set_error(GLenum) = 0;
)~~~");
for (auto const& function : interface.functions) {