• Public
  • Public/Protected
  • All

Class ContextMasquerade

Mask object for context masquerade. It is used to artificially restrict the capabilities of context instances. It is intended to simplify cross-browser testing without actually using different browsers.

A mask can be instantiated in four different ways:

  1. by creating the object and explicitly configuring all values as required.
  2. from a preset identifier (all presets are stored in assets/masquerade.json).
  3. from an extension hash
  4. from GET parameters, either 'msqrd_p=' or 'msqrd_h='.

Intended use; when the context's static masquerade is set, all subsequent instances apply that mask:

Context.masquerade = ContextMasquerade.fromHash('288M01-o');


  • ContextMasquerade



Protected _backend

_backend: string


Protected _extensionsConceal

_extensionsConceal: string[] = new Array<string>()

Protected _extensionsStrive

_extensionsStrive: string[] = new Array<string>()

Protected _functionsUndefine

_functionsUndefine: string[] = new Array<string>()

Static Protected Readonly MASQUERADE_JSON

MASQUERADE_JSON: Array<Preset> = require('./data/masquerade.json')




  • get backend(): string


  • get extensionsConceal(): Array<string>
  • Extensions that the context should conceal support of. This only affects supported extensions, which will be reported to be not supported.

    Returns Array<string>


  • get extensionsStrive(): Array<string>
  • Extensions that the context should strive to support. The support can only go as far as the extensions are actually supported.

    Returns Array<string>


  • get functionsUndefine(): Array<string>
  • Functions that the context should delete during construction. Since WebGL context functions cannot be deleted they are undefined instead.

    Returns Array<string>


Static fromGET

  • Tries to generate a mask based on GET parameters: if msqrd_h is present, its value is interpreted as extensions hash and a mask is generated from hash. If no hash was found, presence of msqrd_p is evaluated and if found, a mask is generated from preset identifier.

    Returns ContextMasquerade | undefined

Static fromHash

  • Generates a mask based on an extensions hash (encoding backend and extensions_strive). If extensions are strived for, all extensions that are not explicitly mentioned will be added to the list of concealed extensions.


    • hash: string

      Hash that is to be decoded for backend and extensions data.

    Returns ContextMasquerade

Static fromPreset

  • Creates a context mask based on a preset. Note that the presence of an extensions_hash overrides the backend, extensions_strive, as well as extensions_conceal. Only the functions_undefine will be preserved in that case.


    • identifier: string

      Name of a preset as specified in masquerade.json.

    Returns ContextMasquerade

Static presets