{"record":{"id":"84288f341eab5bc1","repo":"grafana/k6","slug":"emulating-media-w","errorCode":null,"errorMessage":"emulating media: %w","messagePattern":"emulating media: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":1081,"sourceCode":"func (p *Page) DispatchEvent(selector string, typ string, eventInit any, opts *FrameDispatchEventOptions) error {\n\tp.logger.Debugf(\"Page:DispatchEvent\", \"sid:%v selector:%s\", p.sessionID(), selector)\n\n\treturn p.MainFrame().DispatchEvent(selector, typ, eventInit, opts)\n}\n\n// EmulateMedia emulates the given media type.\nfunc (p *Page) EmulateMedia(popts *PageEmulateMediaOptions) error {\n\tp.logger.Debugf(\"Page:EmulateMedia\", \"sid:%v\", p.sessionID())\n\n\tp.mediaType = popts.Media\n\tp.colorScheme = popts.ColorScheme\n\tp.reducedMotion = popts.ReducedMotion\n\n\tp.frameSessionsMu.RLock()\n\tfor _, fs := range p.frameSessions {\n\t\tif err := fs.updateEmulateMedia(); err != nil {\n\t\t\tp.frameSessionsMu.RUnlock()\n\t\t\treturn fmt.Errorf(\"emulating media: %w\", err)\n\t\t}\n\t}\n\tp.frameSessionsMu.RUnlock()\n\n\tapplySlowMo(p.ctx)\n\n\treturn nil\n}\n\n// EmulateVisionDeficiency activates/deactivates emulation of a vision deficiency.\nfunc (p *Page) EmulateVisionDeficiency(typ string) error {\n\tp.logger.Debugf(\"Page:EmulateVisionDeficiency\", \"sid:%v typ:%s\", p.sessionID(), typ)\n\n\tvalidTypes := map[string]emulation.SetEmulatedVisionDeficiencyType{\n\t\t\"achromatopsia\": emulation.SetEmulatedVisionDeficiencyTypeAchromatopsia,\n\t\t\"blurredVision\": emulation.SetEmulatedVisionDeficiencyTypeBlurredVision,\n\t\t\"deuteranopia\":  emulation.SetEmulatedVisionDeficiencyTypeDeuteranopia,\n\t\t\"none\":          emulation.SetEmulatedVisionDeficiencyTypeNone,","sourceCodeStart":1063,"sourceCodeEnd":1099,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L1063-L1099","documentation":"Aggregated failure while applying emulated media (media type, color scheme, reduced motion) to every frame session of the page. Fires when any frame's CDP emulation command fails — detached iframe session, canceled context, or browser rejection of the emulation values.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:1076 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use supported values for media/colorScheme/reducedMotion in EmulateMedia options","Call EmulateMedia on a stable, fully loaded page","Retry if an out-of-process iframe attached mid-update"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}