Search completed in 0.98 seconds.
The arguments object - JavaScript
arguments is an array-like object accessible inside functions that contains the values of the
arguments passed to that function. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. description note: if you're writing es6 compatible code, then rest parameters should be preferred. note: “array-like” means that
arguments has a length property and properties indexed from zero, but it doesn't have array's built-in methods like foreach() or map(). see §description for details. the
arguments object is a local variable available within all non-arrow functions. ...
...if you're writing es6 compatible code, then rest parameters should be preferred. note: “array-like” means that
arguments has a length property and properties indexed from zero, but it doesn't have array's built-in methods like foreach() or map(). see §description for details. the
arguments object is a local variable available within all non-arrow functions. you can refer to a function's
arguments inside that function by using its
arguments object. it has entries for each argument the function was called with, with the first entry's index at 0. ...
...it is similar, but lacks all array properties except length. ...
...And 25 more matches
arguments.callee - JavaScript
the
arguments.callee property contains the currently executing function. description callee is a property of the
arguments object. it can be used to refer to the currently executing function inside the function body of that function. this is useful when the name of the function is unknown, such as within a function expression with no name (also called "anonymous functions"). warning: the 5th edition of ecmascript (es5) forbids use of
arguments.callee() in strict mode. avoid using
arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself. ...
...function. this is useful when the name of the function is unknown, such as within a function expression with no name (also called "anonymous functions"). warning: the 5th edition of ecmascript (es5) forbids use of
arguments.callee() in strict mode. avoid using
arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself. why was
arguments.callee removed from es5 strict mode? (adapted from a stack overflow answer by olliej) early versions of javascript did not allow named function expressions, and for this reason you could not make a recursive function expression. for example, this syntax worked: function factorial (n) { return !(n > 1) ? 1 : factorial(n - 1) * n; } [1, 2, 3, 4, 5].map(factorial); but: [1, 2, 3, 4, 5].ma...
...ascript did not allow named function expressions, and for this reason you could not make a recursive function expression. for example, this syntax worked: function factorial (n) { return !(n > 1) ? 1 : factorial(n - 1) * n; } [1, 2, 3, 4, 5].map(factorial); but: [1, 2, 3, 4, 5].map(function(n) { return !(n > 1) ? 1 : /* what goes here? */ (n - 1) * n; }); did not. ...
...And 12 more matches
JS_ConvertArguments
obsolete since jsapi 38this feature is obsolete. although it may still work in some browsers, its use is discouraged since it could be removed at any time. try to avoid using it. converts a series of js values, passed in an argument array, to their corresponding js types. syntax bool js_convert
arguments(jscontext *cx, const js::callargs &args, const char *format, ...); // added in spidermonkey 31 bool js_convert
arguments(jscontext *cx, unsigned argc, jsval *argv, const char *format, ...); // obsolete since jsapi 30 name type description cx jscontext * the context in which to perform any necessary conversions. cx also affects the interpretation of format, if js_addargumentformatter has been called. requi...
...ce jsapi 30 name type description cx jscontext * the context in which to perform any necessary conversions. cx also affects the interpretation of format, if js_addargumentformatter has been called. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. args const js::callargs & reference to the
arguments to convert. added in spidermonkey 31 argc unsigned the number of
arguments to convert. obsolete since jsapi 30 argv jsval * pointer to the vector of
arguments to convert. obsolete since jsapi 30 this must be an argv pointer created by the js engine and passed to a jsnative or jsfastnative callback, not an array created by application code. in certain er...
... spidermonkey 31 argc unsigned the number of
arguments to convert. obsolete since jsapi 30 argv jsval * pointer to the vector of
arguments to convert. obsolete since jsapi 30 this must be an argv pointer created by the js engine and passed to a jsnative or jsfastnative callback, not an array created by application code. in certain error cases, js_convert
arguments calls js_argv_callee(argv), which accesses memory outside the range [argv .. argv+argc). js_convert
arguments may modify argv in place by replacing an argument with the converted value. (the purpose is to ensure gc safety.) format const char * null-terminated string describing the types of the out parameters and how to convert the values in argv. ... void * ...
...And 7 more matches
JS_ConvertArgumentsVA
obsolete since jsapi 38this feature is obsolete. although it may still work in some browsers, its use is discouraged since it could be removed at any time. try to avoid using it. converts a series of js values, passed in a va_list, to their corresponding jsapi types. syntax bool js_convert
argumentsva(jscontext *cx, const js::callargs &args, const char *format, va_list ap); bool js_convert
argumentsva(jscontext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); name type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. args const js::callargs &am...
...tsva(jscontext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); name type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. args const js::callargs & reference to the
arguments to convert. added in spidermonkey 31 argc unsigned the number of
arguments to convert. obsolete since jsapi 30 argv jsval * pointer to the vector of
arguments to convert. obsolete since jsapi 30 format const char * character array containing the recognized format to which to convert. ap va_list the list of pointers into which to stor...
...obsolete since jsapi 30 format const char * character array containing the recognized format to which to convert. ap va_list the list of pointers into which to store the converted types. there should be one pointer for each converted value. the type va_list is a standard feature of the c programming language. ...
...And 6 more matches
JS_PushArguments
obsolete since javascript 1.8.5this feature is obsolete. although it may still work in some browsers, its use is discouraged since it could be removed at any time. try to avoid using it. convert any number of
arguments to jsvals and store the resulting jsvals in an array. syntax jsval * js_push
arguments(jscontext *cx, void **markp, const char *format, ...); jsval * js_push
argumentsva(jscontext *cx, void **markp, const char *format, va_list ap); name type description cx jscontext * the context in which to perform any necessary conversions. cx also affects the interpretation of format, if js_addargumentformatter has been called. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. markp void ** out p...
...xt * the context in which to perform any necessary conversions. cx also affects the interpretation of format, if js_addargumentformatter has been called. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. markp void ** out parameter. on success, *markp receives the internally allocated stack mark which should be passed to js_pop
arguments. ...
...dargumentformatter has been called. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. markp void ** out parameter. on success, *markp receives the internally allocated stack mark which should be passed to js_pop
arguments. format const char * null-terminated string holding a list of format types to convert the following
arguments to. ... various (in js_push
arguments) a variable number of
arguments to be converted to jsvals. there must be one argument for each argument described in format. ap va_list (in js_push
argumentsva) the list of
arguments to be converted to jsvals. there must be one argument for each argument described in format. the type va_list is a standard feature of the c programmi...
...And 6 more matches
ReferenceError: deprecated caller or arguments usage - JavaScript
the javascript strict mode-only exception "deprecated caller or
arguments usage" occurs when the deprecated function.caller or function.
arguments properties are used. message typeerror: '
arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context (edge) warning: referenceerror: deprecated caller usage (firefox) warning: referenceerror: deprecated
arguments usage (firefox) typeerror: 'callee' and 'caller' cannot be accessed in strict mode. (safari) error type a strict-mode-only warning that a referenceerror occurred. javascript execution won't be halted. what went wrong? in strict mode, the function.caller or function.
arguments properties are used and shouldn't be. they are deprecated, because they leak the function caller, are non-standard, ha...
...ype a strict-mode-only warning that a referenceerror occurred. javascript execution won't be halted. what went wrong? in strict mode, the function.caller or function.
arguments properties are used and shouldn't be. they are deprecated, because they leak the function caller, are non-standard, hard to optimize and potentially a performance-harmful feature. examples deprecated function.caller or
arguments.callee.caller function.caller and
arguments.callee.caller are deprecated (see the reference articles for more information). 'use strict'; function myfunc() { if (myfunc.caller == null) { return 'the function was called from the top!'; } else { return 'this function\'s caller was ' + myfunc.caller; } } myfunc(); // warning: referenceerror: deprecated caller usage // "the function...
...rguments.callee.caller are deprecated (see the reference articles for more information). ...
...And 5 more matches
TypeError: More arguments needed - JavaScript
the javascript exception "more
arguments needed" occurs when there is an error with how a function is called. more
arguments need to be provided. message typeerror: argument is not an object and is not null (edge) typeerror: object.create requires at least 1 argument, but only 0 were passed typeerror: object.setprototypeof requires at least 2
arguments, but only 0 were passed typeerror: object.defineproperties requires at least 1 argument, but only 0 were passed error type typeerror. what went wrong? ...
...argument is not an object and is not null (edge) typeerror: object.create requires at least 1 argument, but only 0 were passed typeerror: object.setprototypeof requires at least 2
arguments, but only 0 were passed typeerror: object.defineproperties requires at least 1 argument, but only 0 were passed error type typeerror. what went wrong? there is an error with how a function is called. more
arguments need to be provided. ...
...peerror: object.create requires at least 1 argument, but only 0 were passed typeerror: object.setprototypeof requires at least 2
arguments, but only 0 were passed typeerror: object.defineproperties requires at least 1 argument, but only 0 were passed error type typeerror. what went wrong? there is an error with how a function is called. more
arguments need to be provided. ...
...And 2 more matches
JS_PopArguments
obsolete since javascript 1.8.5this feature is obsolete. although it may still work in some browsers, its use is discouraged since it could be removed at any time. try to avoid using it. frees the stack entry allocated by js_push
arguments. syntax void js_pop
arguments(jscontext *cx, void *mark); name type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. ...
... syntax void js_pop
arguments(jscontext *cx, void *mark); name type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. mark void * pointer to a void * which holds the stack frame pointer previously supplied by js_push
arguments. description js_pop
arguments frees the stack frame pointer previously allocated by js_push
arguments and unroots the jsvals which have been associated with it (those returned by js_push
arguments as well). ...
...he caller must be in a request on this jscontext. mark void * pointer to a void * which holds the stack frame pointer previously supplied by js_push
arguments. ...
...ark void * pointer to a void * which holds the stack frame pointer previously supplied by js_push
arguments. description js_pop
arguments frees the stack frame pointer previously allocated by js_push
arguments and unroots the jsvals which have been associated with it (those returned by js_push
arguments as well). ...
TypeError: invalid arguments - JavaScript
the javascript exception "invalid
arguments" occurs when typed array constructors are provided with a wrong argument. message typeerror: invalid
arguments (firefox) error type typeerror what went wrong? ...
... the javascript exception "invalid
arguments" occurs when typed array constructors are provided with a wrong argument. message typeerror: invalid
arguments (firefox) error type typeerror what went wrong? ...
...ther typed array, array-like objects, iterable objects or an arraybuffer object to create a new typed array. other constructor
arguments will not create a valid typed array. examples no strings in typed arrays typed arrays, for example a uint8array, can't be constructed from a string. in fact, strings can't be in typed arrays at all. ...
Window.dialogArguments - Web APIs
the dialog
arguments property returns the parameters that were passed into the window.showmodaldialog() method. this lets you determine what parameters were specified when the modal dialog was created. ...
... the dialog
arguments property returns the parameters that were passed into the window.showmodaldialog() method. this lets you determine what parameters were specified when the modal dialog was created. ...
Function.arguments - JavaScript
the function.
arguments property refers to an an array-like object corresponding to the
arguments passed to a function. use the simple variable
arguments instead. this property is restricted to non-strict functions. description the syntax function.
arguments is deprecated. the recommended way to access the
arguments object available within functions is simply to refer to the variable
arguments. in the case of recursion, i.e. if function f appears several times on the call stack, the value of f.
arguments represents the
arguments corresponding to the most recent invocation of the function. the value of the
arguments property is normally null if there is no outstanding invocation of the function in progress (that is, the function has been called but has not yet returned. examples using the argu...
...e of f.
arguments represents the
arguments corresponding to the most recent invocation of the function. the value of the
arguments property is normally null if there is no outstanding invocation of the function in progress (that is, the function has been called but has not yet returned. examples using the
arguments object function f(n) { g(n - 1) } function g(n) { console.log('before: ' + g.
arguments[0]) if (n > 0) { f(n) } console.log('after: ' + g.
arguments[0]) } f(2) console.log('returned: ' + g.
arguments) // output // before: 1 // before: 0 // after: 0 // after: 1 // returned: null specifications not part of any standard. deprecated in favor of
arguments in ecmascript 3. ...
arguments.caller - Archive of obsolete content
the obsolete
arguments.caller property used to provide the function that invoked the currently executing function. this property has been removed and no longer works. description this property is not available anymore, but you can still use function.caller. function whocalled() { if (whocalled.caller == null) console.log('i was called from the global scope.'); else console.log(whocalled.caller + ' called me!'); } examples the following code was used to check the value of
arguments.caller in a function, but doesn't work anymore. function whocalled() { if (
arguments.caller == null) console.log('i was called from the global scope.'); else console.log(
arguments.caller + ' called me!'); } specifications not part of any standard. implemented in javascript 1...
arguments[@@iterator]() - JavaScript
the initial value of the @@iterator property is the same function object as the initial value of the array.prototype.values property. syntax
arguments[symbol.iterator]() examples iteration using for...of loop function f() { // your browser must support for..of loop // and let-scoped variables in for loops for (let letter of
arguments) { console.log(letter); } } f('w', 'y', 'k', 'o', 'p'); specifications specification ecmascript (ecma-262)the definition of 'createunmapped
argumentsobject' in that specification. ecmascript (ecma-262)the definition of 'createmapped
argumentsobject' in that specification. ...
arguments.length - JavaScript
the
arguments.length property contains the number of
arguments passed to the function. description the
arguments.length property provides the number of
arguments actually passed to a function. this can be more or less than the defined parameter's count (see function.length). examples using
arguments.length in this example we define a function that can add two or more numbers together. function adder(base /*, n2, ... */) { base = number(base); for (var i = 1; i <
arguments.length; i++) { base += number(
arguments[i]); } return base; } note the difference between function.length and
arguments.length specifications specification ecmascript (ecma-262)the definition of '
arguments exotic objects' in that specification. ...
jspage - Archive of obsolete content
{var o=this.prototype[n];if((n=o)){return j(this,l,n,p); }}for(var m in n){this.alias(m,n[m],l);}return this;};d.implement=function(m,l,o){if(typeof m=="string"){return j(this,m,l,o);}for(var n in m){j(this,n,m[n],l); }return this;};if(c){d.implement(c);}return d;};native.genericize=function(b,c,a){if((!a||!b[c])&&typeof b.prototype[c]=="function"){b[c]=function(){var d=array.prototype.slice.call(
arguments); return b.prototype[c].apply(d.shift(),d);};}};native.implement=function(d,c){for(var b=0,a=d.length;b<a;b++){d[b].implement(c);}};native.typize=function(a,b){if(!a.type){a.type=function(c){return($type(c)===b); };}};(function(){var a={array:array,date:date,function:function,number:number,regexp:regexp,string:string};for(var h in a){new native({name:h,initialize:a[h],protect:true}); }var d={"boo...
... b;},getlength:function(){var b=0;for(var a in this){if(this.hasownproperty(a)){b++; }}return b;}});hash.alias("foreach","each");array.implement({foreach:function(c,d){for(var b=0,a=this.length;b<a;b++){c.call(d,this[b],b,this);}}});array.alias("foreach","each"); function $a(b){if(b.item){var a=b.length,c=new array(a);while(a--){c[a]=b[a];}return c;}return array.prototype.slice.call(b);}function $
arguments(a){return function(){return
arguments[a]; };}function $chk(a){return !!(a||a===0);}function $clear(a){cleartimeout(a);clearinterval(a);return null;}function $defined(a){return(a!=undefined);}function $each(c,b,d){var a=$type(c); ((a=="
arguments"||a=="collection"||a=="array")?array:hash).each(c,b,d);}function $empty(){}function $extend(c,a){for(var b in (a||{})){c[b]=a[b];}return c; }function $h(a...
...(a);return null;}function $defined(a){return(a!=undefined);}function $each(c,b,d){var a=$type(c); ((a=="
arguments"||a=="collection"||a=="array")?array:hash).each(c,b,d);}function $empty(){}function $extend(c,a){for(var b in (a||{})){c[b]=a[b];}return c; }function $h(a){return new hash(a);}function $lambda(a){return($type(a)=="function")?a:function(){return a;};}function $merge(){var a=array.slice(
arguments); a.unshift({});return $mixin.apply(null,a);}function $mixin(e){for(var d=1,a=
arguments.length;d<a;d++){var b=
arguments[d];if($type(b)!="object"){continue; }for(var c in b){var g=b[c],f=e[c];e[c]=(f&&$type(g)=="object"&&$type(f)=="object")?$mixin(f,g):$unlink(g);}}return e;}function $pick(){for(var b=0,a=
arguments.length; b<a;b++){if(
arguments[b]!=undefined){return
arguments[b];}}return null;}fun...
...And 33 more matches
WebIDL bindings
you don't need to add an entry either and the code generator will simply assume the defaults here. note that using a 'headerfile' annotation is generally not recommended. if you do use it, you will need to make sure your header includes all the headers needed for your func annotations. add external interface entries to bindings.conf for whatever non-webidl interfaces your new interface has as
arguments or return values. implement a wrapobject override on mozilla::dom::myinterface that just calls through to mozilla::dom::myinterface_binding::wrap. note that if your c++ type is implementing multiple distinct web idl interfaces, you need to choose which mozilla::dom::myinterface_binding::wrap to call here. see audiocontext::wrapobject, for example. expose whatever methods the interface needs on...
...a getter and no setter. the getter's name is the name of the attribute with the first letter converted to uppercase. this has get prepended to it if any of these conditions hold: the type of the attribute is nullable. the getter can throw. the return value of the attribute is returned via an out parameter in the c++. the method signature for the getter looks just like an operation with no
arguments and the attribute's type as the return type. the setter's name is set followed by the name of the attribute with the first letter converted to uppercase. the method signature looks just like an operation with a void return value and a single argument whose type is the attribute's type. c++ reflections of webidl constructors a webidl constructor is turned into a static class method named constr...
...tribute's type as the return type. the setter's name is set followed by the name of the attribute with the first letter converted to uppercase. the method signature looks just like an operation with a void return value and a single argument whose type is the attribute's type. c++ reflections of webidl constructors a webidl constructor is turned into a static class method named constructor. the
arguments of this method will be the
arguments of the webidl constructor, with a const globalobject& for the relevant global prepended. for the non-worker case, the global is typically the inner window for the dom window the constructor function is attached to. if a jscontext* is also needed due to some of the argument types, it will come after the global. the return value of the constructor for myinterfac...
...And 30 more matches
Index
ware command-line proxy. it watches tcp connections and displays the data going by. if a connection is ssl, the data display includes interpreted ssl records and handshaking. 212 nss tools : cmsutil name cmsutil — performs basic cryptograpic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. synopsis cmsutil [options]
arguments description the cmsutil command-line uses the s/mime toolkit to perform basic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each opt...
... command-line uses the s/mime toolkit to perform basic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options. options and
arguments options options specify an action. option
arguments modify an action. the options and
arguments for the cmsutil command are defined as follows: -d decode a message. -c encrypt a message. -e envelope a message. -o create a certificates-only...
... -c content use this detached content (decode only). ...
...And 25 more matches
Functions - JavaScript
unction using the above syntax (i.e. function funcname(){}). the code below will not work. this means that function hoisting only works with function declarations—not with function expressions. console.log(square) // square is hoisted with an initial value undefined. console.log(square(5)) // uncaught typeerror: square is not a function const square = function(n) { return n * n; } the
arguments of a function are not limited to strings and numbers. you can pass whole objects to a function. the show_props() function (defined in working with objects) is an example of a function that takes an object as an argument. a function can call itself. for example, here is a function that computes factorials recursively: function factorial(n) { if ((n === 0) || (n === 1)) return 1; else ...
...pute the factorials of 1 through 5 as follows: var a, b, c, d, e; a = factorial(1); // a gets the value 1 b = factorial(2); // b gets the value 2 c = factorial(3); // c gets the value 6 d = factorial(4); // d gets the value 24 e = factorial(5); // e gets the value 120 there are other ways to call functions. there are often cases where a function needs to be called dynamically, or the number of
arguments to a function vary, or in which the context of the function call needs to be set to a specific object determined at runtime. it turns out that functions are themselves objects—and in turn, these objects have methods. (see the function object.) one of these, the apply() method, can be used to achieve this goal. function scope variables defined inside a function cannot be accessed from anywher...
...ly(); // returns 60 // a nested function example function getscore() { var num1 = 2, num2 = 3; function add() { return name + ' scored ' + (num1 + num2); } return add(); } getscore(); // returns "chamahk scored 5" scope and the function stack recursion a function can refer to and call itself. there are three ways for a function to refer to itself: the function's name
arguments.callee an in-scope variable that refers to the function for example, consider the following function definition: var foo = function bar() { // statements go here } within the function body, the following are all equivalent: bar()
arguments.callee() foo() a function that calls itself is called a recursive function. in some ways, recursion is analogous to a loop. both execute the sa...
...And 19 more matches
StringView - Archive of obsolete content
nding on the chosen encoding). bufferview read only arraybufferview an arraybufferview containing the representation of the whole buffer as array of 8-bit, 16-bit, or 32-bit integers (depending on the chosen encoding). constructor syntax new stringview(input[, encoding[, startoffset[, length]]]) description create a new string-like object based upon an arraybuffer.
arguments input (required) the argument the stringview is constructed from. it can be: another stringview a string a number an arraybuffer a typed array of uint8array, uint16array, or uint32array subclass any other kind of ordered object (like arrays, collections, etc.) if it is a number it will become the length of the new stringview; otherwise it will become its content. the followin...
...become its content. the following table shows the behavior of the stringview constructor. input class stringview.buffer stringview.rawdata stringview.bufferview stringview a new arraybuffer will be created. object reference to stringview.bufferview or a new arraybufferview of stringview.buffer will be created (depending on startoffset and length
arguments passed). a new arraybufferview of stringview.buffer will be created. domstring a new arraybuffer will be created. object reference to stringview.bufferview or a new arraybufferview of stringview.buffer will be created (depending on startoffset and length
arguments passed). a new arraybufferview of stringview.buffer will be created. number a new arraybuf...
...buffer will be created. number a new arraybuffer will be created. object reference to stringview.bufferview. a new arraybufferview of stringview.buffer will be created. arraybuffer object reference to input.buffer. object reference to stringview.bufferview or a new arraybufferview of stringview.buffer will be created (depending on startoffset and length
arguments passed). a new arraybufferview of stringview.buffer will be created. arraybufferview object reference to input.buffer. object reference to input or a new arraybufferview of the buffer input.buffer (depending on many factors regarding the position of the focused parts). object reference to input or a new arraybufferview of the buffer input.buffer (depending on many fact...
...And 18 more matches
OS.File for the main thread
stat(in string path, [optional] in object options); promise<void> unixsymlink(in string targetpath, in string createpath); promise<void> writeatomic(in string path, in arrayview data, in object options); methods os.file.open() use method os.file.open() to open a file. promise<file> open( in string path, [optional] in object mode, [optional] in object options )
arguments path the full native name of the file to open. modeoptional the opening mode for the file, as an object that may contain a subset of the following fields: read if true, the file will be opened for reading. depending on other fields, it may also be opened for writing. write if true, the file will be opened for writing. depending on other fields, it may also be opened for reading. ...
...e edited from other places, close the file. file.close(); this example is from stackoverflow: os.file check last modified date before os.read os.file.openunique() creates and opens a file with a unique name. by default, generate a random hex number and use it to create a unique new file name. promise<object> openunique( in string path, [optional] in object options ) throws os.file.error
arguments path the full native name of the file to open. optionsoptional additional options for file opening. this implementation interprets the following fields: humanreadable if true, create a new filename appending a decimal number, e.g., filename-1.ext, filename-2.ext. if false use hex numbers, e.g., filename-a65bc0.ext. maxattempts used to limit the amount of tries after a failed file ...
...attempts used to limit the amount of tries after a failed file creation. default is 99. promise resolves to an object contains a file object{file} and the path{path}. promise can be rejected with os.file.error if the file could not be opened. os.file.copy() copy a file. void copy( in string sourcepath, in string destpath [optional] in object options) throws os.file.error
arguments sourcepath the full path of the file to copy. at the time of this writing, this function does not copy directories. destpath the full path of the destination. note that this is not a directory but a file. optionsoptional an optional object used to control the behavior of this function. you may pass an object with a subset of the following fields: nooverwrite if destpath already exists, ...
...And 18 more matches
Function.prototype.bind() - JavaScript
the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax let boundfunc = func.bind(thisarg[, arg1[, arg2[, ...argn]]]) parameters thisarg the value to be passed as the this parameter to the target function func when the bound function is called. ...
...isarg[, arg1[, arg2[, ...argn]]]) parameters thisarg the value to be passed as the this parameter to the target function func when the bound function is called. the value is ignored if the bound function is constructed using the new operator. when using bind to create a function (supplied as a callback) inside a settimeout, any primitive value passed as thisarg is converted to object. if no
arguments are provided to bind , or if the thisarg is null or undefined, the this of the executing scope is treated as the thisarg for the new function. arg1, arg2, ...argn optional
arguments to prepend to
arguments provided to the bound function when invoking func. return value a copy of the given function with the specified this value, and initial
arguments (if provided). description the bind() f...
... exotic function object (a term from ecmascript 2015) that wraps the original function object. calling the bound function generally results in the execution of its wrapped function. a bound function has the following internal properties: [[boundtargetfunction]] the wrapped function object [[boundthis]] the value that is always passed as this value when calling the wrapped function. [[bound
arguments]] a list of values whose elements are used as the first
arguments to any call to the wrapped function. [[call]] executes code associated with this object. invoked via a function call expression. the
arguments to the internal method are a this value and a list containing the
arguments passed to the function by a call expression. when a bound function is called, it calls internal method [[call...
...And 18 more matches
JIT Optimization Strategies
either success or a reason why the strategy failed to apply. this page documents the various optimization strategies and their outcomes. it provides information on what they attempt to do, what general level of speed-up they provide, what kind of program characteristics can prevent them from being used, and common ways to enable the engine to utilize that optimization. ...
...egy failed to apply. this page documents the various optimization strategies and their outcomes. it provides information on what they attempt to do, what general level of speed-up they provide, what kind of program characteristics can prevent them from being used, and common ways to enable the engine to utilize that optimization. getproperty getproperty_
argumentslength attempts to optimize an
arguments.length property access. ...
...ategies and their outcomes. it provides information on what they attempt to do, what general level of speed-up they provide, what kind of program characteristics can prevent them from being used, and common ways to enable the engine to utilize that optimization. getproperty getproperty_
argumentslength attempts to optimize an
arguments.length property access. this optimization only works if the
arguments object is used in well-understood ways within the function. ...
...And 16 more matches
JavaScript Daemons Management - Archive of obsolete content
timeout) daemon-methods.js (a wide and highly scalable collection of methods) the only independent module is daemon.js: both the daemon-safe.js module and the daemon-methods.js module require daemon.js to work. for a fast overview on the code proposed here you can git clone https://github.com/madmurphy/daemon.js.git. or, at your choice, directly download this .zip file. ...
...is released under the gnu public license, version 3 or later. ...
... http://www.gnu.org/licenses/gpl-3.0.html |*| \*/ "use strict"; /**************************** * the daemon system * ****************************/ /* the global "daemon" constructor */ function daemon (oowner, ftask, nrate, nlen, finit, fonstart) { if (!(this && this instanceof daemon)) { return; } if (
arguments.length < 2) { throw new typeerror("daemon - not enough
arguments"); } if (oowner) { this.owner = oowner }; this.task = ftask; if (isfinite(nrate) && nrate > 0) { this.rate = math.floor(nrate); } if (nlen > 0) { this.length = math.floor(nlen); } if (fonstart) { this.onstart = fonstart; } if (finit) { this.onstop = finit; finit.call(oowner, this.index, this.length, this.backw); } } /* create the daemon.blank() const...
...And 15 more matches
Rest parameters - JavaScript
only the last parameter can be a "rest parameter". ...
... array. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax function f(a, b, ...theargs) { // ... } description a function's last parameter can be prefixed with ... which will cause all remaining (user supplied)
arguments to be placed within a "standard" javascript array. only the last parameter can be a "rest parameter". function myfun(a, b, ...manymoreargs) { console.log("a", a) console.log("b", b) console.log("manymoreargs", manymoreargs) } myfun("one", "two", "three", "four", "five", "six") // console output: // a, one // b, two // manymoreargs, [three, four, five, six] difference between rest para...
...ithin a "standard" javascript array. only the last parameter can be a "rest parameter". ...
...And 15 more matches
Strict mode - JavaScript
) { // because this is a module, i'm strict by default } export default strict; changes in strict mode strict mode changes both syntax and runtime behavior. changes generally fall into these categories: changes converting mistakes into errors (as syntax errors or at runtime), changes simplifying how the particular variable for a given use of a name is computed, changes simplifying eval and
arguments, changes making it easier to write "secure" javascript, and changes anticipating future ecmascript evolution. converting mistakes into errors strict mode changes some previously-accepted mistakes into errors. javascript was designed to be easy for novice developers, and sometimes it gives operations which should be errors non-error semantics. sometimes this fixes the immediate problem, but some...
... change the property value other than by changing the last instance. duplicate property names are a syntax error in strict mode: this is no longer the case in ecmascript 2015 (bug 1041128). 'use strict'; var o = { p: 1, p: 2 }; // !!! syntax error fifth, strict mode requires that function parameter names be unique. in normal code the last duplicated argument hides previous identically-named
arguments. those previous
arguments remain available through
arguments[i], so they're not completely inaccessible. still, this hiding makes little sense and is probably undesirable (it might hide a typo, for example), so in strict mode duplicate argument names are a syntax error: function sum(a, a, c) { // !!! syntax error 'use strict'; return a + a + c; // wrong if this code ran } sixth, a strict m...
...code.'"); nonstrict("'use strict'; 'strict mode code!'"); thus names in strict mode eval code behave identically to names in strict mode code not being evaluated as the result of eval. third, strict mode forbids deleting plain names. ...
...And 15 more matches
WindowOrWorkerGlobalScope.setInterval() - Web APIs
can remove it later by calling clearinterval(). this method is defined by the windoworworkerglobalscope mixin. syntax var intervalid = scope.setinterval(func, [delay, arg1, arg2, ...]); var intervalid = scope.setinterval(function[, delay]); var intervalid = scope.setinterval(code, [delay]); parameters func a function to be executed every delay milliseconds. the function is not passed any
arguments, and no return value is expected. code an optional syntax allows you to include a string instead of a function, which is compiled and executed every delay milliseconds. this syntax is not recommended for the same reasons that make using eval() a security risk. delayoptional the time, in milliseconds (thousandths of a second), the timer should delay in between executions of the specified funct...
... and executed every delay milliseconds. this syntax is not recommended for the same reasons that make using eval() a security risk. delayoptional the time, in milliseconds (thousandths of a second), the timer should delay in between executions of the specified function or code. see delay restrictions below for details on the permitted range of delay values. arg1, ..., argn optional additional
arguments which are passed through to the function specified by func once the timer expires. note: passing additional
arguments to setinterval() in the first syntax does not work in internet explorer 9 and earlier. if you want to enable this functionality on that browser, you must use a polyfill (see the callback
arguments section). return value the returned intervalid is a numeric, non-zero value wh...
...uisque accumsan faucibus erat, vel varius tortor ultricies ac. lorem ipsum dolor sit amet, consectetur adipiscing elit. sed nec libero nunc. nullam tortor nunc, elementum a consectetur et, ultrices eu orci. lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque a nisl eu sem vehicula egestas.</p> </div> </body> </html> view this demo in action. see also: clearinterval(). callback
arguments as previously discussed, internet explorer versions 9 and below do not support the passing of
arguments to the callback function in either settimeout() or setinterval(). the following ie-specific code demonstrates a method for overcoming this limitation. to use, simply add the following code to the top of your script. /*\ |*| |*| ie-specific polyfill that enables the passage of arbitrary argu...
...And 13 more matches
Using the CSS Painting API - Web APIs
nt(ctx) { ctx.fillstyle = 'hsla(55, 90%, 60%, 1.0)'; ctx.fillrect(0, 15, 200, 20); /* order: x, y, w, h */ } }); in this class example we have defined a single context option with the contextoptions() function: we returned a simple object stating alpha transparency is allowed. we have then used the paint() function to paint to our canvas. a paint() function can take three
arguments. here we have provided one argument: the rendering context (we'll look at more in due course), often refered to by the variable name ctx. the 2d rendering context is a subset of the html5 canvas api; the version available to houdini (called the paintrenderingcontext2d) is a further subset containing most of the features available in the full canvas api with the exception of the canvasimagedata, c...
...hat support the css paint api, the example below should appear like the image above. custom properties in addition to accessing the size of the element, the worklet can also have access to css custom properties and regular css properties. registerpaint('csspaintfunctionname', class { static get inputproperties() { return ['propertyname1', '--custompropertyname2']; } static get input
arguments() { return ['<color>']; } static get contextoptions() { return {alpha: true}; } paint(drawingcontext, elementsize, stylemap) { // paint code goes here. } }); the three parameters of the paint() function include the drawing context, paint size and properties. to be able to access properties, we include the static inputproperties() method, which provides live access to cs...
...map) { // paint code goes here. } }); the three parameters of the paint() function include the drawing context, paint size and properties. to be able to access properties, we include the static inputproperties() method, which provides live access to css properties, including regular properties and custom properties, and returns an array of property names. we'll take a look at input
arguments in the last section. example let's create a list of items with a background image that rotates between three different colors and three widths. in our css, we provide a different color and a width subtractor for the background box we've created via the --boxcolor and --widthsubtractor custom properties. <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> <li>item 4</li> ...
...And 11 more matches
Using Web Workers - Web APIs
et the worker handle two simple operations for illustration: getting the difference of two numbers and making an alert after three seconds. in order to achieve that we first implement a sendquery method which queries if the worker actually has the corresponding methods to do what we want. /* this functions takes at least one argument, the method name we want to query. then we can pass in the
arguments that the method needs. */ this.sendquery = function() { if (
arguments.length < 1) { throw new typeerror('queryableworker.sendquery takes at least one argument'); return; } worker.postmessage({ 'querymethod':
arguments[0], 'query
arguments': array.prototype.slice.call(
arguments, 1) }); } we finish queryableworker with the onmessage method. if the ...
...error('queryableworker.sendquery takes at least one argument'); return; } worker.postmessage({ 'querymethod':
arguments[0], 'query
arguments': array.prototype.slice.call(
arguments, 1) }); } we finish queryableworker with the onmessage method. ...
...bleworker with the onmessage method. if the worker has the corresponding methods we queried, it should return the name of the corresponding listener and the
arguments it needs, we just need to find it in listeners.: worker.onmessage = function(event) { if (event.data instanceof object && event.data.hasownproperty('querymethodlistener') && event.data.hasownproperty('querymethod
arguments')) { listeners[event.data.querymethodlistener].apply(instance, event.data.querymethod
arguments); } else { this.defaultlistener.call(instance, event.data); } } now onto the worker. first we need to have the methods to handle the two simple operations: var queryablefunctions = { getdifference: function(a, b) { reply('printstuff', a - b); }, waitsometi...
...And 11 more matches
A re-introduction to JavaScript (JS tutorial) - JavaScript
terminating the function. if no return statement is used (or an empty return with no value), javascript returns undefined. the named parameters turn out to be more like guidelines than anything else. you can call a function without passing the parameters it expects, in which case they will be set to undefined. add(); // nan // you can't perform addition on undefined you can also pass in more
arguments than the function is expecting: add(2, 3, 4); // 5 // added the first two; 4 was ignored that may seem a little silly, but functions have access to an additional variable inside their body called
arguments, which is an array-like object holding all of the values passed to the function. let's re-write the add function to take as many values as we want: function add() { var sum = 0; for (va...
...ction is expecting: add(2, 3, 4); // 5 // added the first two; 4 was ignored that may seem a little silly, but functions have access to an additional variable inside their body called
arguments, which is an array-like object holding all of the values passed to the function. let's re-write the add function to take as many values as we want: function add() { var sum = 0; for (var i = 0, j =
arguments.length; i < j; i++) { sum +=
arguments[i]; } return sum; } add(2, 3, 4, 5); // 14 that's really not any more useful than writing 2 + 3 + 4 + 5 though. ...
... the function. let's re-write the add function to take as many values as we want: function add() { var sum = 0; for (var i = 0, j =
arguments.length; i < j; i++) { sum +=
arguments[i]; } return sum; } add(2, 3, 4, 5); // 14 that's really not any more useful than writing 2 + 3 + 4 + 5 though. let's create an averaging function: function avg() { var sum = 0; for (var i = 0, j =
arguments.length; i < j; i++) { sum +=
arguments[i]; } return sum /
arguments.length; } avg(2, 3, 4, 5); // 3.5 this is pretty useful, but it does seem a little verbose. to reduce this code a bit more we can look at substituting the use of the
arguments array through rest parameter syntax. in this way, we can pass in any number of
arguments into the function while keeping our code minimal. the r...
...And 9 more matches
Function.prototype.apply() - JavaScript
the apply() method calls a function with a given this value, and
arguments provided as an array (or an array-like object). the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax func.apply(thisarg, [ argsarray]) parameters thisarg the value of this provided for the call to func. note that this may not be the actual value seen by the method: if the method is a function in non-strict mode code, null and undefined will be replaced with the global object, and primitive values will be boxed. this argument is required. ...
...hisarg, [ argsarray]) parameters thisarg the value of this provided for the call to func. note that this may not be the actual value seen by the method: if the method is a function in non-strict mode code, null and undefined will be replaced with the global object, and primitive values will be boxed. this argument is required. argsarray optional an array-like object, specifying the
arguments with which func should be called, or null or undefined if no
arguments should be provided to the function. starting with ecmascript 5 these
arguments can be a generic array-like object instead of an array. see below for browser compatibility information. return value the result of calling the function with the specified this value and
arguments. description note: while the syntax of thi...
... note: when the first argument is undefined or null a similar outcome can be achieved using the array spread syntax. you can assign a different this object when calling an existing function. ...
...And 9 more matches
Bytecode Descriptions
ways an int32 or bigint value. format: jof_ic not stack: val ⇒ (!val) the logical not operator (!). val is first converted with toboolean, then logically negated. the result is always a boolean value. this does not call user-defined methods and can't throw. format: jof_ic binary operators bitor, bitxor, bitand stack: lval, rval ⇒ (lval op rval) binary bitwise operations (|, ^, &). the
arguments are converted to integers first. the conversion can call .tostring()/.valueof() methods and can throw. the result on success is always an int32 or bigint value. format: jof_ic eq, ne stack: lval, rval ⇒ (lval op rval) loose equality operators (== and !=). pop two values, compare them, and push the boolean result. the comparison may perform conversions that call .tostring()/.valueof() methods...
...rly hints to the vm that the callee is likely function.prototype.call. jsop::callignoresrv hints to the vm that the return value is ignored. this allows alternate faster implementations to be used that avoid unnecesary allocations. implements: evaluatecall steps 4, 5, and 7. format: jof_argc, jof_invoke, jof_typeset, jof_ic spreadcall stack: callee, this, args ⇒ rval like jsop::call, but the
arguments are provided in an array rather than a span of stack slots. used to implement spread-call syntax: f(...args). args must be an array object containing the actual
arguments. the array must be packed (dense and free of holes; see ispackedarray). this can be ensured by creating the array with jsop::newarray and populating it using jsop::initelemarray. format: jof_invoke, jof_spread, jof_typeset, jof_...
...w to rethrow. throwmsg operands: (throwmsgkind msgnumber) create and throw an error object. sometimes we know at emit time that an operation always throws. for example, delete super.prop; is allowed in methods, but always throws a referenceerror. msgnumber must be one of the error codes listed in js/src/js.msg; it determines the .message and [[prototype]] of the new error object. the number of
arguments in the error message must be 0. throwsetconst operands: (uint32_t nameindex) throws a runtime typeerror for invalid assignment to a const binding. format: jof_atom, jof_name try operands: (int32_t jumpatendoffset) no-op instruction that marks the top of the bytecode for a trystatement. the jumpatendoffset operand must be the offset (relative to the current op) of the jsop::goto at the end o...
...And 8 more matches
Shell global objects
rlaps with "built-in functions" in introduction to the javascript shell and is probably not complete. see js/src/shell/js.cpp (around shell_functions) for more. this page lists variables and functions available on spidermonkey 53. there may be some difference between each versions. you can get the list of functions by help() function in js shell. variables scriptargs an array that contains
arguments passed to js shell. scriptpath a string that is a path of script. console an object that has following property: log evaluate and print expressions to stdout. this function is an alias of the print() function. timesaccessed returns a number that indicates how many times this variable is accessed perfmeasurement see perfmeasurement.jsm. shell only functions functions always av...
...n alias of the print() function. timesaccessed returns a number that indicates how many times this variable is accessed perfmeasurement see perfmeasurement.jsm. shell only functions functions always available version([number]) get or force a script compilation version number. options([option ...]) get or toggle javascript options. load(['foo.js' ...]) load files named by string
arguments. filename is relative to the current working directory. loadrelativetoscript(['foo.js' ...]) load files named by string
arguments. filename is relative to the calling script. evaluate(code[, options]) evaluate code as though it were the contents of a file. options is an optional object that may have these properties: isrunonce use the isrunonce compiler option (default: false) noscrip...
...er line by line. print([exp ...]) evaluate and print expressions to stdout. printerr([exp ...]) evaluate and print expressions to stderr. putstr([exp]) evaluate and print expression without newline. datenow() return the current time with sub-ms precision. help([name ...]) display usage and help messages. quit() quit the shell. asserteq(actual, expected[, msg]) throw if the first two
arguments are not the same (both +0 or both -0, both nan, or non-zero and ===). starttimingmutator() start accounting time to mutator vs gc. stoptimingmutator() stop accounting time to mutator vs gc and dump the results. throwerror() throw an error from js_reporterror. intern(str) internalize str in the atom table. getslx(obj) get script line extent. evalcx(s[, o]) evaluate s in optional sandbo...
...And 8 more matches
WindowOrWorkerGlobalScope.setTimeout() - Web APIs
milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. if this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, the next event cycle. note that in either case, the actual delay may be longer than intended; see reasons for delays longer than specified below. arg1, ..., argn optional additional
arguments which are passed through to the function specified by function. note: passing additional parameters to the function in the first syntax does not work in internet explorer 9 and below. if you want to enable this functionality on that browser, you must use a polyfill (see the polyfill section). return value the returned timeoutid is a positive integer value which identifies the timer created ...
...t box after two seconds</button> <p></p> <button onclick="clearalert();">cancel alert before it happens</button> javascript var timeoutid; function delayedalert() { timeoutid = window.settimeout(window.alert, 2*1000, 'that was really slow!'); } function clearalert() { window.cleartimeout(timeoutid); } result see also cleartimeout() example. ...
...ton> javascript var timeoutid; function delayedalert() { timeoutid = window.settimeout(window.alert, 2*1000, 'that was really slow!'); } function clearalert() { window.cleartimeout(timeoutid); } result see also cleartimeout() example. polyfill if you need to pass one or more
arguments to your callback function, but need it to work in browsers which don't support sending additional
arguments using either settimeout() or setinterval() (e.g., internet explorer 9 and below), you can include this polyfill to enable the html5 standard
arguments-passing functionality. just add this code to the top of your script: /*\ |*| |*| polyfill which enables the passage of arbitrary
arguments to the |*| callback functions of javascript timers (html5 standard syntax). |*| |*| https://developer.moz...
...And 8 more matches
NSS tools : certutil
it can specifically list, generate, modify, or delete certificates, create or change the password, generate new public and private key pairs, display the contents of the key database, or delete key pairs within the key database. ...
...ntents of the key database, or delete key pairs within the key database. certificate issuance, part of the key and certificate management process, requires that keys and certificates be created in the key database. this document discusses certificate and key database management. for information on the security module database management, see the modutil manpage. options and
arguments running certutil always requires one and only one command option to specify the type of certificate operation. each option may take
arguments, anywhere from none to multiple
arguments. the command option -h will list all the command options available and their relevant
arguments. command options -a add an existing certificate to a certificate database. ...
... key database. the key database should already exist; if one is not present, this option will initialize one by default. some smart cards (for example, the litronic card) can store only one key pair. if you create a new key pair for such a card, the previous pair is overwritten. -h display a list of the options and
arguments used by the certificate database tool. -k list the key id of keys in the key database. a key id is the modulus of the rsa key or the publicvalue of the dsa key. ids are displayed in hexadecimal ("0x" is not shown). -l list all the certificates, or display information about a named certificate, in a certificat...
...And 7 more matches
certutil
it can also list, generate, modify, or delete certificates within the database, create or change the password, generate new public and private key pairs, display the contents of the key database, or delete key pairs within the key database. ...
...tabase, or delete key pairs within the key database. the key and certificate management process generally begins with creating keys in the key database, then generating and managing certificates in the certificate database. this document discusses certificate and key database management. for information security module database management, see the modutil manpages. options and
arguments running certutil always requires one (and only one) option to specify the type of certificate operation. each option may take
arguments, anywhere from none to multiple
arguments. run the command option and -h to see the
arguments available for each command option. options options specify an action and are uppercase. -a add an existing certificate to a certific...
...air within a key database. the key database should already exist; if one is not present, this option will initialize one by default. some smart cards (for example, the litronic card) can store only one key pair. if you create a new key pair for such a card, the previous pair is overwritten. -h display a list of the options and
arguments used by the certificate database tool. -k list the key id of keys in the key database. a key id is the modulus of the rsa key or the publicvalue of the dsa key. ids are displayed in hexadecimal ("0x" is not shown). -l list all the certificates, or display information about a named certificate, in a certificate database. u...
...And 7 more matches
cfx - Archive of obsolete content
t-main.js cfx run this command is used to run the add-on. called with no options it looks for a file called package.json in the current directory, loads the corresponding add-on, and runs it under the version of firefox it finds in the platform's default install path. supported options you can point cfx run at a different package.json file using the --pkgdir option, and pass
arguments to your add-on using the --static-args option. you can specify a different version of the host application using the --binary option, passing in the path to the application binary to run. the path may be specified as a full path or may be relative to the current directory. but note that the version must be 4.0b7 or later. cfx run runs the host application with a new profile. you can specify an ...
...at profile's history, bookmarks, and other add-ons. this enables you to run your add-on alongside debuggers like firebug. see "using --profiledir" for more information. -b binary, --binary=binary use the host application binary specified in binary. binary may be specified as a full path or as a path relative to the current directory. ...
...n binary. binary may be specified as a full path or as a path relative to the current directory. --binary-args=cmdargs pass extra
arguments to the binary being executed (for example, firefox). for example, to pass the -jsconsole argument to firefox, which will launch the javascript error console, try the following: cfx run --binary-args -jsconsole to pass multiple
arguments, or
arguments containing spaces, quote them: cfx run --binary-args '-url "www.mozilla.org" -jsconsole' --extra-packages=extra_packages extra packages to include, specified as a comma-separated list of package names. -g config, --use-config=config pass a set of options by referencing a named configuration. -p profiledir, --profiledir=profiledir us...
...And 6 more matches
Index - Web APIs
alues that specify alternating lengths of lines and gaps which describe the pattern. 598 canvasrenderingcontext2d.settransform() api, canvas, canvasrenderingcontext2d, method, reference the canvasrenderingcontext2d.settransform() method of the canvas 2d api resets (overrides) the current transformation to the identity matrix, and then invokes a transformation described by the
arguments of this method. this lets you scale, rotate, translate (move), and skew the context. 599 canvasrenderingcontext2d.shadowblur api, canvas, canvasrenderingcontext2d, property, reference the canvasrenderingcontext2d.shadowblur property of the canvas 2d api specifies the amount of blur applied to shadows. the default is 0 (no blur). 600 canvasrenderingcontext2d.shadowc...
...ce the canvasrenderingcontext2d.textbaseline property of the canvas 2d api specifies the current text baseline used when drawing text. 609 canvasrenderingcontext2d.transform() api, canvas, canvasrenderingcontext2d, method, reference the canvasrenderingcontext2d.transform() method of the canvas 2d api multiplies the current transformation with the matrix described by the
arguments of this method. this lets you scale, rotate, translate (move), and skew the context. 610 canvasrenderingcontext2d.translate() api, canvas, canvasrenderingcontext2d, method, reference the canvasrenderingcontext2d.translate() method of the canvas 2d api adds a translation transformation to the current matrix. 611 caretposition api, cssom view, experimental, inter...
... 1597 htmlcollection.item api, html dom, htmlcollection, property, reference, item the htmlcollection method item() returns the node located at the specified offset into the collection. 1598 htmlcontentelement api, deprecated, html dom, interface, reference, référen...
...And 6 more matches
lang/functional - Archive of obsolete content
eters fn : function the function to be deferred. returns function : the new, deferred function. remit() an alias for defer. invoke(callee, params, self) invokes callee, passing params as an argument and self as this. returns the value that is returned by callee. ...
.../lang/functional"); invoke(sum, [1,2,3,4,5], null); // 15 function sum () { return array.slice(
arguments).reduce(function (a, b) { return a + b; }); } parameters callee : function function to invoke. params : array parameters to be passed into callee. self : mixed object to be passed as the this context to callee. returns mixed : returns the return value of callee. partial(fn,
arguments...) takes a function and bind values to one or more
arguments, returning a new function of smaller arity. let { partial } = require("sdk/lang/functional"); let add = function add (x, y) { return x + y; } let addone = partial(add, 1); addone(5); // 6 addone(10); // 11 partial(add, addone(20))(2); // 23 parameters fn : function function on which partial application is to be performed. argume...
... compose(fn...) returns the composition of a list of functions, where each function consumes the return value of the function that follows. in math terms, composing the functions f(), g(), and h() produces f(g(h())). ...
...And 5 more matches
NSS Tools modutil
rtificates and the certificate database. this document discusses security module database management. for information on certificate database and key database management, see using the certificate database tool. availability this tool is known to build on solaris 2.5.1 (sunos 5.5.1) and windows nt 4.0. ...
...e database. this document discusses security module database management. for information on certificate database and key database management, see using the certificate database tool. availability this tool is known to build on solaris 2.5.1 (sunos 5.5.1) and windows nt 4.0. ...
... module database management. for information on certificate database and key database management, see using the certificate database tool. availability this tool is known to build on solaris 2.5.1 (sunos 5.5.1) and windows nt 4.0. syntax to run the security module database tool, type the command modutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. ...
...And 5 more matches
Rhino shell
-f script-filename-or-url reads script-filename-or-url content and execute it as a javascript script. -opt optlevel / -o optlevel optimizes at level optlevel, which must be -1 or an integer between 0 and 9. ...
... is invoked with the system property rhino.use_java_policy_security set to true and with a security manager installed, the shell restricts scripts permissions based on their urls according to java policy settings. this is available only if jvm implements java2 security model. predefined properties scripts executing in the shell have access to some additional properties of the top-level object.
arguments the
arguments object is an array containing the strings of all the
arguments given at the command line when the shell was invoked. environment returns the current environment object. history displays the shell command history. help() executing the help function will print usage and help messages. defineclass(classname) define an extension using the java class named with the string argume...
...nd help messages. defineclass(classname) define an extension using the java class named with the string argument classname. uses scriptableobject.defineclass() to define the extension. deserialize(filename) restore from the specified file an object previously written by a call to serialize. gc() runs the garbage collector. load([filename, ...]) load javascript source files named by string
arguments. if multiple
arguments are given, each file is read in and executed in turn. loadclass(classname) load and execute the class named by the string argument classname. the class must be a class that implements the script interface, as will any script compiled by rhino javascript compiler. print([expr ...]) evaluate and print expressions. evaluates each expression, converts the result to a string...
...And 5 more matches
Index
type of javascript values. 28 js::call jsapi reference, reference, spidermonkey js::call calls a specified function, fun, on an object, thisobj. in terms of function execution, the object is treated as this. 29 js::callargs jsapi reference, reference, référence(2), spidermonkey js::callargs is helper class encapsulating access to the callee, this value,
arguments, and argument count for a function call. 30 js::clonefunctionobject jsapi reference, reference, référence(2), spidermonkey js::clonefunctionobject creates a new function object from funobj. the new object has the same code and argument list as funobj. if scopechain is supplied, it uses scopechain as its enclosing scope. if scopechain is omitted, it creates a new function ob...
...parent may specify objects to be used as the new object's prototype and parent. if either is null, the engine tries to find reasonable defaults. 218 js_contextiterator jsapi reference, spidermonkey js_contextiterator steps through the set of contexts associated with the runtime rt. each call to js_contextiterator returns the next context in the cycle. 219 js_convert
arguments jsapi reference, obsolete, spidermonkey js_convert
arguments provides a convenient way to translate a series of js values into their corresponding js types with a single function call. it saves you from having to write separate tests and elaborate if...else statements in your function code to retrieve and translate multiple js values for use with your own functions. 220 js_con...
... 221 js_convertvalue jsapi reference, obsolete, spidermonkey js_convertvalue converts a javascript value, v, to the specified type. ...
...And 5 more matches
Components.Constructor
it eliminates the clutter of typing components.classes, components.interfaces, createinstance, and so on every time you wish to create an instance. it also gives creation of xpcom objects more javascript-like syntax. another important benefit is that...
...utation it does, so using a function returned from components.constructor() to create xpcom objects is faster than creating the object from base principles, as demonstrated below. (this benefit is also partly a result of having to travel through the layer between the javascript engine and xpcom fewer times.) the behavior of functions returned by components.constructor() varies depending upon the
arguments given to components.constructor() when called. if only one argument is given, that argument is the contract id of the xpcom component to create. the component is then returned immediately, with only the base interface nsisupports available on it; you must call nsisupports.queryinterface() on it to call methods on the object. for example: var binaryinputstream = components.constructor("@mozilla.o...
... bis = new binaryinputstream(); print(bis.tostring()); // "[xpconnect wrapped nsisupports]" try { // someinputstream is an existing nsiinputstream // throws because bis hasn't been qi'd to nsibinaryinputstream bis.setinputstream(someinputstream); } catch (e) { bis.queryinterface(components.interfaces.nsibinaryinputstream); bis.setinputstream(someinputstream); // succeeds now } if two
arguments are given, the created instance will be nsisupports.queryinterface()'d to the xpcom interface whose name is the second argument: var binaryinputstream = components.constructor("@mozilla.org/binaryinputstream;1", "nsibinaryinputstream"); var bis = new binaryinputstream(); print(bis.tostring()); // "[xpconnect wrapped nsibinaryinputstream]" // somein...
...And 5 more matches
Components.utils.exportFunction
t. the exported function does not have to be added to the less privileged code's global window object: it can be exported to any object in the target scope. exportfunction() is made available as a global in sandboxes which have the wantexporthelpers option set in the sandbox() constructor. this includes add-on sdk content scripts. to understand what happens if the functions you export accept
arguments, see exporting functions that take
arguments below. syntax components.utils.exportfunction(func, targetscope[, options]); parameters func : function the function to export. targetscope : object the object to attach the function to. this does not have to be the global window object: it could be any other object in the target window, or an object created by the caller. options : object o...
...bject optional parameter that supplies additional options. the following options are currently defined: defineas: determines the name of the function in targetscope. if this is omitted, you need to assign the return value of exportfunction() to an object in the target scope. allowcallbacks: deprecated/redundant from firefox 34. this option allows the exported function to accept callbacks as
arguments. ...
...ted, you need to assign the return value of exportfunction() to an object in the target scope. allowcallbacks: deprecated/redundant from firefox 34. this option allows the exported function to accept callbacks as
arguments. boolean, defaulting to false. this option is new in firefox 33. from firefox 34 onwards this option has no effect: the exported function is always able to accept callbacks as
arguments. allowcrossorigin
arguments: do not check that
arguments to the exported function are subsumed by the caller: this allows the caller to pass objects with a different origin into the exported function, which can then use its privileged status to make cross-origin requests with them. boolean, defaulting to false. this option is new in firefox 34. returns the placeholder function which has been c...
...And 5 more matches
Working with windows in chrome code
es the window and its contents. the second parameter is the window's name; the name can be used in links or forms as the target attribute. this is different from the user-visible window title, which is specified using xul. the third, and optional, parameter is a list of special window features the window should have. the window.opendialog function works similarly, but lets you specify optional
arguments that can be referenced from the javascript code. it also handles window features a little differently, including always assuming the dialog feature is specified. from xpcom components and modules if the window object is unavailable (for example, when opening a window from xpcom component code), you might want to use nsiwindowwatcher interface. its parameters are similar to window.open; in fact,...
...ll demonstrate them from the simplest to the most complex in the next few sections. note: if you want to pass data between privileged (chrome) and non-privileged (web page) windows, or vice-versa, read this instead. example 1: passing data to window when opening it with opendialog when you open a window using window.opendialog or nsiwindowwatcher.openwindow, you can pass an arbitrary number of
arguments to that window.
arguments are simple javascript objects, accessible through window.
arguments property in the opened window. in this example, we're using window.opendialog to open a progress dialog. we pass in the current status text as well as the maximum and current progress values. note that using nsiwindowwatcher.openwindow is a bit less trivial . todo: link to how to pass an xpcom object to ...
...s.xul: <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window onload="onload();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script><![cdata[ var gstatus, gprogressmeter; var maxprogress = 100; function onload() { gstatus = document.getelementbyid("status"); gprogressmeter = document.getelementbyid("progressmeter"); if("
arguments" in window && window.
arguments.length > 0) { maxprogress = window.
arguments[0].maxprogress; setprogress(window.
arguments[0].progress); setstatus(window.
arguments[0].status); } } function setprogress(value) { gprogressmeter.value = 100 * value / maxprogress; } function setstatus(text) { gstatus.value = "status: " + text + "..."; } ]]></script> <label id="status" value="(no st...
...And 5 more matches
Element.classList - Web APIs
see https://bugzilla.mozilla.org/show_bug.cgi?id=814014 polyfill the legacy onpropertychange event can be used to create a living classlist mockup thanks to a element.prototype.classname property that fires the specified event once it is changed. the following polyfill for both classlist and domtokenlist ensures full compliance (coverage) for all standard met...
...t.defineproperty, allowtokenlistconstruction = 0, skippropchange = 0; function domtokenlist(){ if (!allowtokenlistconstruction) throw typeerror("illegal constructor"); // internally let it through } domtokenlist.prototype.tostring = domtokenlist.prototype.tolocalestring = function(){return this.value}; domtokenlist.prototype.add = function(){ a: for(var v=0, arglen=
arguments.length,val="",ele=this[" ucl"],proto=ele[" uclp"]; v!==arglen; ++v) { val =
arguments[v] + "", checkifvalidclasslistentry("add", val); for (var i=0, len=proto.length, resstr=val; i !== len; ++i) if (this[i] === val) continue a; else resstr += " " + this[i]; this[len] = val, proto.length += 1, proto.value = resstr; } skippropchang...
..., val); for (var i=0, len=proto.length, resstr=val; i !== len; ++i) if (this[i] === val) continue a; else resstr += " " + this[i]; this[len] = val, proto.length += 1, proto.value = resstr; } skippropchange = 1, ele.classname = proto.value, skippropchange = 0; }; domtokenlist.prototype.remove = function(){ for (var v=0, arglen=
arguments.length,val="",ele=this[" ucl"],proto=ele[" uclp"]; v !== arglen; ++v) { val =
arguments[v] + "", checkifvalidclasslistentry("remove", val); for (var i=0, len=proto.length, resstr="", is=0; i !== len; ++i) if(is){ this[i-1]=this[i] }else{ if(this[i] !== val){ resstr+=this[i]+" "; }else{ is=1; } } if (!is) continue; delete this[len], p...
...And 5 more matches
Using IndexedDB - Web APIs
ere's what that looks like: var transaction = db.transaction(["customers"], "readwrite"); // note: older experimental implementations use the deprecated constant idbtransaction.read_write instead of "readwrite". // in case you want to support such an implementation, you can write: // var transaction = db.transaction(["customers"], idbtransaction.read_write); the transaction() function takes two
arguments (though one is optional) and returns a transaction object. the first argument is a list of object stores that the transaction will span. you can pass an empty array if you want the transaction to span all object stores, but don't do it because the spec says an empty array should generate an invalidaccesserror. if you don't specify anything for the second argument, you get a read-only transaction.
...s what it looks like: var objectstore = db.transaction("customers").objectstore("customers"); objectstore.opencursor().onsuccess = function(event) { var cursor = event.target.result; if (cursor) { console.log("name for ssn " + cursor.key + " is " + cursor.value.name); cursor.continue(); } else { console.log("no more entries!"); } }; the opencursor() function takes several
arguments. first, you can limit the range of items that are retrieved by using a key range object that we'll get to in a minute. second, you can specify the direction that you want to iterate. in the above example, we're iterating over all objects in ascending order. the success callback for cursors is a little special. the cursor object itself is the result of the request (above we're using the shorthand,...
...f you're going backwards) as the direction parameter. when nextunique or prevunique is used, the entry with the lowest key is always the one returned. index.openkeycursor(null, "nextunique").onsuccess = function(event) { var cursor = event.target.result; if (cursor) { // do something with the entries. cursor.continue(); } }; please see "idbcursor constants" for the valid direction
arguments. version changes while a web app is open in another tab when your web app changes in such a way that a version change is required for your database, you need to consider what happens if the user has the old version of your app open in one tab and then loads the new version of your app in another. when you call open() with a greater version than the actual version of the database, all other open...
...And 5 more matches
Synchronous and asynchronous requests - Web APIs
equest. the callback routine is called whenever the state of the request changes. example: writing a function to read an external file in some cases, you must read many external files. this is a standard function which uses the xmlhttprequest object asynchronously in order to switch the content of the read file to a specified listener. ...
...which uses the xmlhttprequest object asynchronously in order to switch the content of the read file to a specified listener. function xhrsuccess() { this.callback.apply(this, this.
arguments); } function xhrerror() { console.error(this.statustext); } function loadfile(url, callback /*, opt_arg1, opt_arg2, ... ...
...ynchronously in order to switch the content of the read file to a specified listener. function xhrsuccess() { this.callback.apply(this, this.
arguments); } function xhrerror() { console.error(this.statustext); } function loadfile(url, callback /*, opt_arg1, opt_arg2, ... ...
...And 5 more matches
tabs - Archive of obsolete content
ontent has loaded, only that the browser tab itself is fully visible to the user. properties relating to the tab's content (for example: title, favicon, and url) will not be correct at this point. if you need to access these properties, listen for the ready event: var tabs = require("sdk/tabs"); tabs.on('open', function(tab){ tab.on('ready', function(tab){ console.log(tab.url); }); });
arguments tab : listeners are passed the tab object that just opened. close this event is emitted when a tab is closed. when a window is closed this event will be emitted for each of the open tabs in that window.
arguments tab : listeners are passed the tab object that has closed. ready this event is emitted when the dom for a tab's content is ready. it is equivalent to the domcontentloaded event fo...
...osed. ready this event is emitted when the dom for a tab's content is ready. it is equivalent to the domcontentloaded event for the given content page. a single tab will emit this event every time the dom is loaded: so it will be emitted again if the tab's location changes or the content is reloaded. after this event has been emitted, all properties relating to the tab's content can be used.
arguments tab : listeners are passed the tab object that has loaded. activate this event is emitted when an inactive tab is made active.
arguments tab : listeners are passed the tab object that has become active. deactivate this event is emitted when the active tab is made inactive.
arguments tab : listeners are passed the tab object that has become inactive. tab a tab instance represents a sing...
...he tab's document has loaded and is parsed, but resources such as images and stylesheets may still be loading "complete": the tab's document and all resources are fully loaded once a tab's readystate has entered "interactive", you can retrieve properties such as the document's url. events close this event is emitted when the tab is closed. it's also emitted when the tab's window is closed.
arguments tab : listeners are passed the tab object. ready this event is emitted when the dom for the tab's content is ready. it is equivalent to the domcontentloaded event for the given content page. at this point the document itself is fully loaded and parsed, but resources such as stylesheets and images may still be loading. a single tab will emit this event every time the dom is loaded: so it will ...
...And 4 more matches
Following the Android Toasts Tutorial from a JNI Perspective
if the class is blah.foo.bar then the signature of this will be this in slash notation with an l and ; around it. so this would be lblah/foo/bar;. if there is a sub class such as blah.foo.bar.subclass then a dollar sign is used in the slash notation, so this would be lblah/foo/bar$subclass;. when declaring methods, the signatures of the types go right next to each other without any spacing. the
arguments are within the parenthesis, and the return type is immediately following. more on this later. so let us now declare the types for our toast example. we see we have three classes and two basic types (int and void). the class signature is looked up on the android documentation. for instance, we go to android reference :: context and we see: we see that the signature in dot notation is android.c...
...y from the class. if it is not static, then it cannot be used on an instance of that class. how is it determined if a method is static or not? the documentation tells us. for example, in our case we have a method maketext and show, looking that up on the android documentation page shows this: there are two columns, the first column is the return, and the second column is the method name and
arguments. we see that maketext returns static toast. this means it is a static method. we see that the return column of the show method does not contain the word static. therefore, it is a plain method. let's declare these methods in the third argument of loadclass we add a key-value pair, with the key being static_methods and methods and the value being an array. var toast = jni.loadclass(my_jenv, sig.t...
...being static_methods and methods and the value being an array. var toast = jni.loadclass(my_jenv, sig.toast.substr(1, sig.toast.length - 2), { static_methods: [ { name: 'maketext', sig: '()' } ], methods: [ { name: 'show', sig: '()' } ] }); the sig of methods is always in the format of "method format" from our types table above. the reason is that methods accept
arguments and return something. we need to declare now the
arguments and return type for each of the methods. the documentation says maketext takes three
arguments, the types are context, int, and int and returns a toast. for example, let's declare this with strings: { name: 'maketext', sig: '(landroid/content/context;ii)landroid/widget/toast;' } we see there are no separating characters between the arg...
...And 4 more matches
NSS tools : crlutil
name crlutil — list, generate, modify, or delete crls within the nss security database file(s) and list, create, modify or delete certificates entries in a particular crl. synopsis crlutil [options] [[
arguments]] status this documentation is still work in progress. please contribute to the initial review in mozilla nss bug 836477[1] description the certificate revocation list (crl) management tool, crlutil, is a command-line utility that can list, generate, modify, or delete crls within the nss security database file(s) and list, create, modify or delete certificates entries in a particular crl. the key and certificate management process generally begins with creating keys in the key database, then generating and managing certificates in the certificate database(see certuti...
...ertificates expiration or revocation. this document discusses certificate revocation list management. for information on security module database management, see using the security module database tool. for information on certificate and key database management, see using the certificate database tool. ...
...ocation. this document discusses certificate revocation list management. for information on security module database management, see using the security module database tool. for information on certificate and key database management, see using the certificate database tool. ...
...And 4 more matches
XPCShell Reference
line the command-line syntax for xpcshell is: xpcshell [-s] [-w] [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...] -c this option turns on the "compile-only" mode. (setting this option disables the "interactive" mode) -f this option specifies a script file to execute. xpcshell terminates upon script completion. you can specify multiple js files to execute by using multiple -f
arguments, and the scripts will be executed in the order encountered. furthermore, xpcshell looks for xpcshell.js in the current directory. if that file is found, it is executed before any other js files specified. -g this option specifies which gecko runtime environment directory (gredir) to use for xpcom. -i this option turns on the "interactive" mode -s this option toggles the javascript st...
... will set the interpreter to use javascript version 1.8. -w (lower case) this option turns on javascript warnings. -w (upper case) this turns off javascript warnings. the last option listed is the one that takes effect. -x this option toggles the xml option on and off. by default it is off. [scriptfile] this is the file name of the script to execute. ...
...version 1.8. -w (lower case) this option turns on javascript warnings. -w (upper case) this turns off javascript warnings. the last option listed is the one that takes effect. -x this option toggles the xml option on and off. by default it is off. [scriptfile] this is the file name of the script to execute. [scriptarg…] these are
arguments to be passed to the script. ...
...And 4 more matches
nsIProcess
ote prior to gecko 1.9.1 (firefox 3.5), this method returned the process id of the newly executing process. it no longer returns a value. void run( in boolean blocking, [array, size_is(count)] in string args, in unsigned long count ); parameters blocking if true, this method will block until the process terminates; if false, the method returns immediately. args an array of count
arguments, using the native character set, to be passed to the executable on its command line. count the number of
arguments in the args array. runasync() asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running. void runasync( [array, size_is(count)] in string args, in unsigned long count, in nsiobserver observer, o...
... observer optional an observer that will be notified when the process exits. the observer will receive this nsiprocess instance as the subject and "process-finished" or "process-failed" as the topic. ...
... observer optional an observer that will be notified when the process exits. ...
...And 4 more matches
Indexed collections - JavaScript
equivalent arrays: let arr = new array(element0, element1, ..., elementn) let arr = array(element0, element1, ..., elementn) let arr = [element0, element1, ..., elementn] element0, element1, ..., elementn is a list of values for the array's elements. when these values are specified, the array is initialized with them as the array's elements. the array's length property is set to the number of
arguments. the bracket syntax is called an "array literal" or "array initializer." it's shorter than other forms of array creation, and so is generally preferred. see array literals for details. to create an array with non-zero length, but without any items, either of the following can be used: // this... let arr = new array(arraylength) // ...results in the same array as this let arr = array(arrayleng...
...thisobject. if provided, thisobject becomes the value of the this keyword inside the body of the callback function. if not provided, as with other cases where a function is invoked outside of an explicit object context, this will refer to the global object (window) when using arrow function as callback, or undefined when using normal function as callback. the callback function is called with two
arguments, that are array's elements. the function below compares two values and returns one of three values: for instance, the following will sort by the last letter of a string: let sortfn = function(a, b) { if (a[a.length - 1] < b[b.length - 1]) return -1; if (a[a.length - 1] > b[b.length - 1]) return 1; if (a[a.length - 1] == b[b.length - 1]) return 0; } myarray.sort(sortfn) // sorts the array...
...sion and a string, the array returns properties and elements that provide information about the match. an array is the return value of regexp.exec(), string.match(), and string.split(). for information on using arrays with regular expressions, see regular expressions. ...
...And 4 more matches
Transitioning to strict mode - JavaScript
ly. it is possible to change each file individually and even to transition code to strict mode down to the function granularity. ...
... a property: var global = this; // in the top-level context, "this" always // refers to the global object function f(x) { 'use strict'; var a = 12; global.b = a + x * 35; } f(42); trying to delete a non-configurable property 'use strict'; delete object.prototype; // error! in non-strict, this would silently fail, in contradiction with the user expectation. poisoned
arguments and function properties accessing
arguments.callee,
arguments.caller, anyfunction.caller, or anyfunction.
arguments throws an error in strict mode. the only legitimate use case would be to reuse a function as in: // example taken from vanillajs: http://vanilla-js.com/ var s = document.getelementbyid('thing').style; s.opacity = 1; (function() { if ((s.opacity-=.1) < 0) s.display = 'none'; ...
...ies accessing
arguments.callee,
arguments.caller, anyfunction.caller, or anyfunction.
arguments throws an error in strict mode. the only legitimate use case would be to reuse a function as in: // example taken from vanillajs: http://vanilla-js.com/ var s = document.getelementbyid('thing').style; s.opacity = 1; (function() { if ((s.opacity-=.1) < 0) s.display = 'none'; else settimeout(
arguments.callee, 40); })(); which can be rewritten as: 'use strict'; var s = document.getelementbyid('thing').style; s.opacity = 1; (function fadeout() { // name the function if((s.opacity-=.1) < 0) s.display = 'none'; else settimeout(fadeout, 40); // use the name of the function })(); semantic differences these differences are very subtle differences. it's possible that a test suite doesn...
...And 4 more matches
ui/frame - Archive of obsolete content
e iframe instance for each browser window. so there are three cases to consider: sending messages from a frame script to the main add-on code sending messages from the main add-on code to all instances of a frame, across all browser windows sending messages from the main add-on code to a single instance of a frame, attached to a specific browser window in all cases, postmessage() takes two
arguments: the message itself and a targetorigin. the targetorigin argument can be either the uri of the document hosted by the target, or the wildcard "*". if you use the uri, then the message will only be dispatched to the window whose document matches that uri. if you know the target uri, you should use it, as this is more secure: it prevents another window from intercepting messages that were intended...
..."*". if you use the uri, then the message will only be dispatched to the window whose document matches that uri. if you know the target uri, you should use it, as this is more secure: it prevents another window from intercepting messages that were intended for someone else. from frame to add-on to send a message from a frame script to the add-on, use window.parent.postmessage(). this takes two
arguments, the message itself and a target origin. if the frame script initiates the conversation, you need to specify "*" as the origin: window.parent.postmessage("ping", "*"); if the frame script has received a message from the add-on already, it can use the origin property of the event object passed to the message hander: // listen for messages from the add-on, and send a reply window.addeventlisten...
...owser has started to load its document: for example, when the user opens a new browser window, if that window has a toolbar containing this frame. since the event is dispatched asynchronously, the document may already be loaded by the time the event is received. at this point, you should not try to send messages to scripts hosted in the frame, because the frame scripts may not have been loaded.
arguments event : this contains two properties: source, which defines a postmessage() function which you can use to send messages back to this particular frame instance. but note that at this point you should not try to send messages to scripts hosted in the frame, because the frame scripts may not have been loaded. origin, which you can use as the targetorigin argument to postmessage() if you want to...
...And 3 more matches
Dialogs and Prompts - Archive of obsolete content
if you want to access the accept ("ok") and cancel buttons from script, use this: // disable the ok and cancel btns document.documentelement.getbutton("accept").disabled = true; document.documentelement.getbutton("cancel").disabled = true; links dialog.xml — xbl bindings for <dialog> and <dialogheader> elements. passing parameter to a dialog and getting return values from it. ...
... disable the ok and cancel btns document.documentelement.getbutton("accept").disabled = true; document.documentelement.getbutton("cancel").disabled = true; links dialog.xml — xbl bindings for <dialog> and <dialogheader> elements. passing parameter to a dialog and getting return values from it. ...
...ent.documentelement.getbutton("accept").disabled = true; document.documentelement.getbutton("cancel").disabled = true; links dialog.xml — xbl bindings for <dialog> and <dialogheader> elements. passing parameter to a dialog and getting return values from it. passing
arguments and displaying a dialog the following code demonstrates how to pass custom
arguments to a dialog, process those
arguments in the dialog, and return user-modified
arguments to the caller. the code to open a dialog named mydialog.xul and pass it
arguments: var params = {inn:{name:"foo", description:"bar", enabled:true}, out:null}; window.opendialog("chrome://myext/content/mydialog.xul", "", "chrome, dialog, modal, resizable=yes", params).focus(); if (params.out) { // user clicked ok. process changed arg...
...And 3 more matches
Creating a Login Manager storage module
ull, get _logservice() { if (!this.__logservice) this.__logservice = cc["@mozilla.org/consoleservice;1"]. ...
...__logservice) this.__logservice = cc["@mozilla.org/consoleservice;1"]. ...
.../consoleservice;1"]. ...
...And 3 more matches
HTTP Cache
e cache data held in memory for faster access (more about the intermediate cache below) nsiloadcontextinfo distinguishes the scope of the storage demanded to open. mandatory argument to *storage methods of nsicachestorageservice. ...
... nsicachestorage //github.com/realityripple/uxp/blob/master/netwerk/cache2/nsicachestorage.idl obtained from call to one of the *storag...
...ntextinfo objects: c++ consumers: functions at loadcontextinfo.h exported header js consumers: resource://gre/modules/loadcontextinfo.jsm module methods two storage objects created with the same set of nsiloadcontextinfo
arguments are identical, containing the same cache entries. two storage objects created with in any way different nsiloadcontextinfo
arguments are strictly and completely distinct and cache entries in them do not overlap even when having the same uris. nsicachestorage //github.com/realityripple/uxp/blob/master/netwerk/cache2/nsicachestorage.idl obtained from call to one of the *storage methods on nsicachestorageservice. represents a distinct storage area (or scope) to put and get cache entries mapped by urls into a...
...And 3 more matches
JSAPI User Guide
1024l * 1024l); if (!rt) return 1; // create a context. jscontext *cx = js_newcontext(rt, 8192); if (!cx) return 1; js_seterrorreporter(rt, reporterror); int status = run(cx); // shut everything down. ...
...ntext. jscontext *cx = js_newcontext(rt, 8192); if (!cx) return 1; js_seterrorreporter(rt, reporterror); int status = run(cx); // shut everything down. js_destroycontext(cx); js_destroyruntime(rt); js_shutdown(); return status; } each jsnative has the same signature, regardless of what
arguments it expects to receive from javascript. the javascript
arguments to the function are given in argc and vp. argc tells how many actual
arguments the caller passed, and js_argv(cx, vp) returns an array of those
arguments. the
arguments do not have native c++ types like int and float; rather, they are jsvals, javascript values. the native function uses js_convert
arguments to convert the
arguments to c++ types and store them in local variables. the native function...
... but they are not the same thing. spidermonkey does not use c++ exceptions for anything. jsapi functions never throw c++ exceptions, and when spidermonkey calls an application callback, the callback must not throw a c++ exception. throwing and catching exceptions we have already seen one example of how to throw an exception from a jsnative function. simply call js_reporterror, with printf-style
arguments, and return false. rc = system(cmd); if (rc != 0) { /* throw a javascript exception. */ js_reporterror(cx, "command failed with exit code %d", rc); return false; } this is very much like the javascript statement throw new error("command failed with exit code " + rc);. again, note that calling js_reporterror does not cause a c++ exception to be thrown. it onl...
...And 3 more matches
JS_AddArgumentFormatter
obsolete since jsapi 18this feature is obsolete. although it may still work in some browsers, its use is discouraged since it could be removed at any time. try to avoid using it. add or remove a format string handler for js_convert
arguments, js_push
arguments, js_convert
argumentsva, and js_push
argumentsva. syntax jsbool js_addargumentformatter(jscontext *cx, const char *format, jsargumentformatter formatter); void js_removeargumentformatter(jscontext *cx, const char *format); name type description cx jscontext * the context in which to install the formatter. format const char * the format string prefix that should be handled by formatter, or whose handler should be removed. formatter jsargumentformatter the fu...
...); void js_removeargumentformatter(jscontext *cx, const char *format); name type description cx jscontext * the context in which to install the formatter. format const char * the format string prefix that should be handled by formatter, or whose handler should be removed. formatter jsargumentformatter the function to be used to convert
arguments described by the given format. this function is described in more detail below. description js_addargumentformatter establishes formatter as the conversion function for format strings beginning with format in the context cx. on success, it returns js_true. otherwise it returns js_false. (at the moment, js_addargumentformatter fails only if there is no memory available to record the registra...
... into an array of jsval values. app va_list * in-out parameter. a pointer to an argument pointer, used to retrieve pointers to c values. callback description the conversion function should return true on success, and return false after reporting an error or detecting an already-reported error. ...
...And 3 more matches
mozIStorageAggregateFunction
ined aggregate functions provided by sqlite. objects implementing this interface can be registered with mozistorageconnection.createaggregatefunction(). storage/public/mozistorageaggregatefunction.idlscriptable please add a summary to this article. last changed in gecko 1.9 (firefox 3) inherits from: nsisupports method overview void onstep(in mozistoragevaluearray afunction
arguments); nsivariant onfinal(); methods onstep() this is called for each row of results returned by the query. the implementation should store or perform some work to prepare to return a value. note this callback is executed on the thread that the statement or trigger is executing on. if you use mozistorageconnection.executeasync() or, mozistoragestatement.executeasync() this callbac...
...se mozistorageconnection.executeasync() or, mozistoragestatement.executeasync() this callback will run on a different thread from the rest of your code. likewise, if you execute sql on a different thread, this callback will be executed on that thread. this callback should be reentrant if any of the above applies to your use of the storage apis! void onstep( in mozistoragevaluearray afunction
arguments ); parameters afunction
arguments a mozistoragevaluearray holding the
arguments passed in to the function. onfinal() this is called after all results have been obtained and notified via mozistorageaggregatefunction. the implementation should finish its calculations on the data, and return a result. note this callback is executed on the thread that the statement or trigger is executing o...
...bove applies to your use of the storage apis! nsivariant onfinal() return value an nsivariant this is the return value of the function. sample code both of the following code samples assume that the variable dbconn is an opened mozistorageconnection. javascript // first, create our object that will represent our function. ...
...And 3 more matches
mozIStorageFunction
already defined functions provided by sqlite. objects implementing this interface can be registered with mozistorageconnection.createfunction(). storage/public/mozistoragefunction.idlscriptable please add a summary to this article. last changed in gecko 1.9.1.4 (firefox 3.5.4) inherits from: nsisupports method overview nsivariant onfunctioncall(in mozistoragevaluearray afunction
arguments); methods onfunctioncall() the implementation of the function. this is called by the database engine when the function registered with mozistorageconnection.createfunction() is used in an executing sql statement or trigger. note this callback is executed on the thread that the statement or trigger is executing on. if you use mozistorageconnection.executeasync() or, mozistoragestatemen...
...connection.executeasync() or, mozistoragestatement.executeasync() this callback will run on a different thread from the rest of your code. likewise, if you execute sql on a different thread, this callback will be executed on that thread. this callback should be reentrant if any of the above applies to your use of the storage apis! nsivariant onfunctioncall( in mozistoragevaluearray afunction
arguments ); parameters afunction
arguments a mozistoragevaluearray holding the
arguments passed in to the function. return value an nsivariant this is the return value of the function. sample code both of the following code samples assume that the variable dbconn is an opened mozistorageconnection. javascript starting in gecko 1.9.1.4 (firefox 3.0.15), you can directly pass your function into...
... return value an nsivariant this is the return value of the function. sample code both of the following code samples assume that the variable dbconn is an opened mozistorageconnection. javascript starting in gecko 1.9.1.4 (firefox 3.0.15), you can directly pass your function into the mozistorageconnection method mozistorageconnection, like this: dbconn.createfunction("square", 1, function(a
arguments) { let value = a
arguments.getint32(0); return value * value; }); // run some query that uses the function. let stmt = dbconn.createstatement("select square(value) from some_table"); try { while (stmt.executestep()) { // handle the results } } finally { stmt.reset(); } in earlier versions of gecko, however, you'll need to actually create an object containing the onfunctioncall...
...And 3 more matches
Declaring and Using Callbacks
c functions occasionally take function pointers as
arguments, which are generally used as callbacks. in these cases, js-ctypes allows you to pass a regular javascript function as the callback. this is very powerful, since it allows native code to transparently call into javascript. warning: callbacks must be invoked on the same thread with which they were registered. there is no concurrency logic in js-ctypes, so invoking callbacks on other threads will cause things to crash. prerequiste understanding abi functiontype declaring callbacks a callback is declared by using ctypes.functiontype. the first argument is the calling convention, the second argument is the return type, and the third is an array of
arguments the callback expects. the return type of the javascript callback must match ...
...ed by using ctypes.functiontype. the first argument is the calling convention, the second argument is the return type, and the third is an array of
arguments the callback expects. the return type of the javascript callback must match the return type declared, otherwise js-ctypes will throw an error saying "unexpected return type". examples example 1 this callback that returns bool and has two
arguments. var myfunctypedeclaration = ctypes.functiontype(ctypes.default_abi, ctypes.bool, [ctypes.int, ctypes.voidptr_t]); function myjscallback(cint, cptr) { return true; // as the return of the functiontype was ctypes.bool we must make our javascript callback return bool otherwise js-ctypes will throw error saying unexpected type return } var myccallback = myfunctypedeclaration.ptr(myjscallback)...
...pes.default_abi, ctypes.bool, [ctypes.int, ctypes.voidptr_t]); function myjscallback(cint, cptr) { return true; // as the return of the functiontype was ctypes.bool we must make our javascript callback return bool otherwise js-ctypes will throw error saying unexpected type return } var myccallback = myfunctypedeclaration.ptr(myjscallback); example 2 this callback that returns void and no
arguments. when void is the return type, the javascript callback must not return, or it should return undefined. var myfunctypedeclaration = ctypes.functiontype(ctypes.default_abi, ctypes.void_t, []); function myjscallback() { return undefined; // as the return of the functiontype was ctypes.void_t we must return undefined or dont return at all otherwise js-ctypes will throw an error saying unexpecte...
...And 3 more matches
Details of the object model - JavaScript
can use them informally to refer to objects higher or lower in the prototype chain. creating objects with simple definitions object hierarchy the following hierarchy is created using the code on the right side. individual objects = jim, sally, mark, fred, jane, etc. "instances" created from constructor var jim = new employee; // parentheses can be omitted if the // constructor takes no
arguments. // jim.name is '' // jim.dept is 'general' var sally = new manager; // sally.name is '' // sally.dept is 'general' // sally.reports is [] var mark = new workerbee; // mark.name is '' // mark.dept is 'general' // mark.projects is [] var fred = new salesperson; // fred.name is '' // fred.dept is 'sales' // fred.projects is [] // fred.quota is 100 var jane = new engineer; // jane.name is '' // ...
...the mark object also has the specialty property with the value of "none". the following figure shows the effect of adding this property to the employee prototype and then overriding it for the engineer prototype. adding properties more flexible constructors the constructor functions shown so far do not let you specify property values when you create an instance. as with java, you can provide
arguments to constructors to initialize property values for instances. the following figure shows one way to do this. specifying properties in a constructor, take 1 the following pairs of examples show the java and javascript definitions for these objects. function employee(name, dept) { this.name = name || ''; this.dept = dept || 'general'; } public class employee { public string name; pu...
...or returns the value of the second argument. therefore, this line of code tests to see if name has a useful value for the name property. if it does, it sets this.name to that value. otherwise, it sets this.name to the empty string. this chapter uses this idiom for brevity; however, it can be puzzling at first glance. note: this may not work as expected if the constructor function is called with
arguments which convert to false (like 0 (zero) and empty string (""). in this case the default value will be chosen. with these definitions, when you create an instance of an object, you can specify values for the locally defined properties. you can use the following statement to create a new engineer: var jane = new engineer('belau'); jane's properties are now: jane.name == ''; jane.dept == 'engine...
...And 3 more matches
Arrow function expressions - JavaScript
arrow function expressions are ill suited as methods, and they cannot be used as constructors. ...
...ters. any this argument is ignored. ...
...{ base: 1, add: function(a) { var f = v => v + this.base; return f(a); }, addthrucall: function(a) { var f = v => v + this.base; var b = { base: 2 }; return f.call(b, a); } }; console.log(adder.add(1)); // this would log 2 console.log(adder.addthrucall(1)); // this would log 2 still no binding of
arguments arrow functions do not have their own
arguments object. ...
...And 3 more matches
Array.prototype.map() - JavaScript
ps://github.com/mdn/interactive-examples and send us a pull request. syntax let new_array = arr.map(function callback( currentvalue[, index[, array]]) { // return element for new_array }[, thisarg]) parameters callback function that is called for every element of arr. each time callback executes, the returned value is added to new_array. the callback function accepts the following
arguments: currentvalue the current element being processed in the array. indexoptional the index of the current element being processed in the array. arrayoptional the array map was called upon. thisargoptional value to use as this when executing callback. return value a new array with each element being the result of the callback function. description map calls a provided callba...
... been deleted; or which have never been assigned a value. when not to use map() since map builds a new array, using it when you aren't using the returned array is an anti-pattern; use foreach or for-of instead. you shouldn't be using map if: you're not using the array it returns; and/or you're not returning a value from the callback. parameters in detail callback is invoked with three
arguments: the value of the element, the index of the element, and the array object being mapped. if a thisarg parameter is provided, it will be used as callback's this value. otherwise, the value undefined will be used as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. map does not mutate the array o...
...argument "length". // 3. let len be touint32(lenvalue). var len = o.length >>> 0; // 4. if iscallable(callback) is false, throw a typeerror exception. // see: http://es5.github.com/#x9.11 if (typeof callback !== 'function') { throw new typeerror(callback + ' is not a function'); } // 5. if thisarg was supplied, let t be thisarg; else let t be undefined. if (
arguments.length > 1) { t =
arguments[1]; } // 6. let a be a new array created as if by the expression new array(len) // where array is the standard built-in constructor with that name and // len is the value of len. a = new array(len); // 7. let k be 0 k = 0; // 8. repeat, while k < len while (k < len) { var kvalue, mappedvalue; // a. let pk...
...And 3 more matches
Math.hypot() - JavaScript
the math.hypot() function returns the square root of the sum of squares of its
arguments, that is: math.hypot(v1,v2,…,vn)=∑i=1nvi2=v12+v22+…+vn2\mathtt{\operatorname{math.hypot}(v_1, v_2, \dots, v_n)} = \sqrt{\sum_{i=1}^n v_i^2} = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2} the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax math.hypot([value1[, value2[, ...]]]) parameters value1, value2, ... numbers. return value the square root of the sum of squares of the given
arguments. if at least one of the
arguments cannot be converted to a number, nan is returned. description calculating the hypotenuse of a right t...
... you use hypot() instead, you get better answer: math.hypot(1e200, 1e200) = 1.4142...e+200 . this is also true with very small numbers. math.sqrt(1e-200*1e-200 + 1e-200*1e-200) = 0, but math.hypot(1e-200, 1e-200) =1.4142...e-200. because hypot() is a static method of math, you always use it as math.hypot(), rather than as a method of a math object you created (math is not a constructor). if no
arguments are given, the result is +0. if any of the
arguments is ±infinity, the result is infinity. if any of the
arguments is nan (unless another argument is ±infinity), the result is nan. if at least one of the
arguments cannot be converted to a number, the result is nan. with one argument, math.hypot() is equivalent to math.abs(). polyfill a naive approach that does not handle overflow/underflow i...
... the result is infinity. if any of the
arguments is nan (unless another argument is ±infinity), the result is nan. if at least one of the
arguments cannot be converted to a number, the result is nan. with one argument, math.hypot() is equivalent to math.abs(). ...
...And 3 more matches
Actionscript Acceptance Tests - Archive of obsolete content
ge or define classes as the file will be wrapped in a function when used in the ats. if you must use classes, define them in a sub-dir with the same name as the test. you must create a testname.as.avm_args file with the uses_swfversion directive. support files: there are a variety of support files available for non-standard actionscript tests. testname.as.asc_args this file specifies additional
arguments to pass to asc when compiling the test: # asc args for file # two modes are available: # override| all command line
arguments (except builtin.py) are ignored and replaced by these # merge| merge these args in with the current args # specifiy an arg that starts with -no will disable the arg... eg: -no-optimize merge| -as3 a dir.asc_args file can also be created with the same contents that will ap...
...and replaced by these # merge| merge these args in with the current args # specifiy an arg that starts with -no will disable the arg... eg: -no-optimize merge| -as3 a dir.asc_args file can also be created with the same contents that will apply to the entire directory. testname.as.asc_args files will take precedence over the dir.asc_args file. testname.as.avm_args this file specifies additional
arguments to pass to the shell when running the test - the user can use the special variable $dir to refer to the current directory. this example passes in another .abc file as an argument to the file being run: -- $dir/file.abc another use would be to pass a specific argument to the shell: -dtimeout this file can have multiple lines with different
arguments. when there are multiple lines, the harness w...
...there is one special keyword that can be used, uses_swfversion. ...
...And 2 more matches
OpenClose - Archive of obsolete content
the context menu. the openpopup method regardless of the type of popup, you may wish to open the popup programatically. to do this, use the popup's openpopup method. this method may be used for any type of popup, either a menupopup, a panel, or a tooltip, including ones that can be opened via other means, for instance, a popup attached via the context attribute. the openpopup method takes six
arguments which are used to specify how and where the popup should be positioned. these will be described below. the openpopup method is defined as follows: void openpopup(in domelement anchorelement, in string position, in long x, in long y, in boolean iscontextmenu, in boolean attributesoverride); first an example: somepopup.o...
...d_before' as used in the above example, indicates to place the left edge of the popup along the right edge of the the anchor element, aligned along the top edge of both. this may be confusing to understand, so see positioning a popup which describes this process in more detail and provides images which show the possible values and how a popup would be aligned for each value. the third and fourth
arguments to openpopup are x and y offsets. after the popup is positioned, you can further position the popup by specifying non-zero values for these offsets. this allows the position of the popup to be precisely controlled while still being anchored to a specific element. you can use positive values to adjust the popup to the right or downwards and negative values to adjust the popup to the left or upward...
... other menus, and the submenu is closed when the mouse is moved away. now try opening a context menu on the same bookmark and note how the other menus aren't affected by mouse movement. this difference is handled by the use of the iscontextmenu flag. finally, the last argument to the openpopup method, attributesoverride indicates whether attributes placed on the popup element itself override the
arguments supplied. this allows a popup to use specific positioning behaviour by using the position, left and top attributes instead. more details on these attributes can be found at positioning a popup. unanchored popups with openpopup if the first argument to the openpopup method is null, this creates an unanchored popup. in this case, the second argument, the position, is not used, so an empty string ...
...And 2 more matches
CommandLine - Archive of obsolete content
handling command line
arguments with xulrunner for multiple instances application it's fairly easy to retrieve application specific command line
arguments in xulrunner when it's not a single instance application. an nsicommandline object is passed as the first argument of the launched window: example var cmdline = window.
arguments[0]; cmdline = cmdline.queryinterface(components.interfaces.nsicommandline); alert(cmdline.handleflagwithparam("test", false)); see also: chrome: command line for single instance applications of course, for a single instance application (see toolkit.singletonwindowtype for more information), the last example still applies the first time your application is launched. ...
...ace(components.interfaces.nsicommandline); alert(cmdline.handleflagwithparam("test", false)); see also: chrome: command line for single instance applications of course, for a single instance application (see toolkit.singletonwindowtype for more information), the last example still applies the first time your application is launched. however, if you'd like to retrieve the latest command line
arguments (to open a file for example), a possible solution is to create your own command line handler. for the sake of simplicity, the proposed solution involves the observer service to notify observers that the updated
arguments are available. a similar and better way to implement this solution is by defining argument specific handlers with registering and unregistering functions in your command line ha...
...this approach has been used in songbird. example notice the changes since gecko 2.0 (component registration has moved into the manifest file). ...
...And 2 more matches
Task.jsm
s thrown as an exception. if you specify a generator function or the iterator returned by a generator function, then task.spawn() is implicitly called, and the yield operator works on the returned promise. this reduces the syntax overhead of calling task.spawn() explicitly when you want to recurse into other task functions. if you specify a function that is not a generator, it is called with no
arguments, and the yield operator returns the return value of the function. this comes in handy when iterating over function lists where some items have been converted to tasks and some not. if you specify anything else, the yield operator returns exactly what you specified. method overview function async(atask); promise spawn(atask); properties attribute type ...
...tructor constructs a special exception that, when thrown inside a legacy generator function, allows the associated task to be resolved with a specific value. example: task.spawn( function() { yield ... ; throw new task.result("value"); } note: if you want to exit early from a generator function, without returning a value for the task, you can just use the return statement without any
arguments. note: if you want to return a result from a non-legacy generator function, don't use this. return the value instead: task.spawn( function*() { yield ... ; return "value"; } methods async() create and return an "async function" that starts a new task. function async( atask ); async() is similar to spawn(), except that: it doesn't immediately start the task, rath...
...n*() { yield ... ; return "value"; } methods async() create and return an "async function" that starts a new task. function async( atask ); async() is similar to spawn(), except that: it doesn't immediately start the task, rather it returns an "async function" that starts the task when the function is called; it binds the task to the async function's this object and
arguments; it requires the task to be a function. async() simplifies the common pattern of implementing a method via a task, like this simple object with a greet method that has a name parameter and spawns a task to send a greeting and return its reply: let greeter = { message: "hello, name!", greet: function(name) { return task.spawn((function* () { return yield sendgreeting(this.
...And 2 more matches
Mozilla DOM Hacking Guide
ble with idl alone. a brief introduction to javascript and xpconnect. before we begin the explanation of class info, i'd like to introduce quickly the javascript engine and xpconnect. in javascript, there is no knowledge of types, like there is in c++. a function for example can be represented by a jsfunction, a jsobject, a jsval, ... this means that when we use the dom from javascript, we pass
arguments that have no type. however, since the dom is coded in c++, we expect to receive an argument of the correct type for our function. this is one of the jobs of xpconnect. xpconnect will "wrap" the argument in a wrapper that will be of the type expected by our c++ function. similarly, then return type of the c++ function will be wrapped by xpconnect so that javascript can use it safely. when, in jav...
...dom security engine. initialized in init(). static nsresult definestaticjsvals(jscontext *cx);: used to define all the static jsstring data members of nsdomclassinfo. static prbool sisinitialized: keeps track of wether class info was already initialized, because init() shouldn't be called twice. static jsval *sx_id: strings used in the global resolve methods for comparison with the passed in
arguments. they represent special words for the dom. initialized by definestaticjsvals(). static const jsclass *sobjectclass: help me! static prbool sdosecuritycheckinaddproperty;: help me! nsdomclassinfo::init() this method is to be called only once. its purpose is, well, to initialize... it does a lot of different things: fill the blanks in the sclassinfodata array, initialize the sxpconnect and sse...
... we do want to be able to access htmlspanelement to modify it. this macro allows you to do that. see bug 92071 for more information. let's now see how to specify the interfaces available from javascript for a particular dom class. #define dom_classinfo_map_entry(_if) &ns_get_iid(_if), the array of pointers interface_list is filled with the addresses of the iid's of all the interfaces passed as
arguments to the macro. in our window example, the interfaces are nsidomwindow, nsidomjswindow, nsidomeventreciever, nsidomeventtarget, nsidomviewcss, and nsidomabstractview. please see section 1.2 on interface flattening for an explanation of the use of these interfaces. the initialization for a class is finished by the dom_classinfo_map_end macro. #define dom_classinfo_map_end nsnull }; d.minterfaces = ...
...And 2 more matches
NSS Tools certutil
then generating and managing certificates in the certificate database. this document discusses certificate and key database management. for information security module database management, see using the security module database tool. availability see the release notes for the platforms this tool is available on. syntax to run the certificate database tool, type the command certutil option [
arguments ] where options and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options, or with the -h option. options and
arguments options specify an action and are uppercase. option
arguments modify an action and are lowercase. certificat...
... -s create an individual certificate and add it to a certificate database. ...
...rtificate database. use the -htokenname argument to specify the certificate database on a particular hardware or software token. -v check the validity of a certificate and its attributes. -m modify a certificate's trust attributes using the values of the -t argument. -h display a list of the options and
arguments used by the certificate database tool. -w change the password to a key database. -u list all available modules or print a single named module.
arguments -a use ascii format or allow the use of ascii format for input or output. this formatting follows rfc 1113. for certificate requests, ...
...And 2 more matches
NSS tools : modutil
modutil can add and delete pkcs #11 modules, change passwords on security databases, set defaults, list module contents, enable or disable slots, enable or disable fips 140-2 compliance, and assign default providers for cryptographic operations. ...
...ons. this tool can also create certificate, key, and module security database files. the tasks associated with security module database management are part of a process that typically also involves managing key databases and certificate databases. options running modutil always requires one (and only one) option to specify the type of module operation. each option may take
arguments, anywhere from none to multiple
arguments. options -add modulename add the named pkcs #11 module to the database. use this option with the -libfile, -ciphers, and -mechanisms
arguments. -changepw tokenname change the password on the named token. if the token has not been initialized, this option initializes the password. use this option...
...a password is equivalent to a personal identification number (pin). -chkfips verify whether the module is in the given fips mode. ...
...And 2 more matches
JIT Optimization Outcomes
outcomes describing inline cache stubs that were generated. ...
...nstructor. property accessors, function.prototype, and arrow (=>) functions cannot be called as constructors. cantinlinedisableion unable to inline function call. the interpreted callee function has been explicitly blacklisted against ion compilation. cantinlinetoomanyargs unable to inline function call. the interpreted callee function either has too many parameters or is called with too many
arguments. these thresholds are subject to change. cantinlinerecursive unable to inline function call. the interpreted callee function recurs for more than one level. the first level of recursion is inlinable. cantinlineheavyweight unable to inline function call. the interpreted callee function contains variables bindings that are closed over. for example, function f() { var x; return function () { x++...
... recurs for more than one level. the first level of recursion is inlinable. cantinlineheavyweight unable to inline function call. the interpreted callee function contains variables bindings that are closed over. for example, function f() { var x; return function () { x++; } } closes over x in f. cantinlineneedsargsobj unable to inline function call. the interpreted callee function requires an
arguments object to be created. cantinlinedebuggee unable to inline function call. the interpreted callee function is being debugged by the debugger api. cantinlineunknownprops unable to inline function call. the engine knows nothing definite about the type of the callee function object. cantinlineunreachable unable to inline function call. the call site has not been observed to have ever been execut...
...And 2 more matches
nsICommandLine
s may be the original command line of this instance or a command line provided remotely by another instance of the application. 1.0 66 introduced gecko 1.8 inherits from: nsisupports last changed in gecko 1.8 (firefox 1.5 / thunderbird 1.5 / seamonkey 1.0) components may implement the nsicommandlinehandler interface to add custom command line handling behavior. definitions
arguments any values found on the command line. switches flags. in normalized form, these are preceded by a single dash. some flags may take parameters; for example: "-url <param>" or "-install-xpi <param>". method overview long findflag(in astring aflag, in boolean acasesensitive); astring getargument(in long aindex); boolean handleflag(in astring aflag, in boolean acasesensitive); astring handl...
... these are preceded by a single dash. some flags may take parameters; for example: "-url <param>" or "-install-xpi <param>". method overview long findflag(in astring aflag, in boolean acasesensitive); astring getargument(in long aindex); boolean handleflag(in astring aflag, in boolean acasesensitive); astring handleflagwithparam(in astring aflag, in boolean acasesensitive); void remove
arguments(in long astart, in long aend); nsifile resolvefile(in astring aargument); nsiuri resolveuri(in astring aargument); attributes attribute type description length long number of
arguments in the command line. the application name is not part of the command line. read only. preventdefault boolean there may be a command-line handler which performs a default action if there was no explici...
... its position on the command line. long findflag( in astring aflag, in boolean acasesensitive ); parameters aflag the flag name to locate. do not include the initial hyphen. acasesensitive whether to do case-sensitive comparisons. return value the position of the flag in the command line, or -1 if the flag is not found.getargument() gets the value an argument from the array of command-line
arguments, given the index into the argument list. on windows, flags of the form /flag are normalized to -flag. /flag:param are normalized to -flag param. on unix/linux and mac os x, flags of the form --flag are normalized to -flag, and flags of the form --flag=param are normalized to the form -flag param. astring getargument( in long aindex ); parameters aindex the argument to retrieve. this index is ...
...And 2 more matches
MailNews fakeserver
iberal with the specs will require different handlers. writing a new fakeserver since the number of protocols we use is very small, most people shouldn't have to write an entirely new daemon and handler setup by themselves. that said, someone writing a new test may have to take into account a new handler. a handler will contain the following methods: <caption> handler methods </caption> name
arguments returns notes [command] rest of sent line server's response the name is normalized to be uppercase. onerror command, rest of sent line server's response called if handler does not define the command function. onstartup none server's response called when a connection is made. onmultiline sent line server's response or nothing called when in multi-line mode. postcommand server object non...
... will normalize all occurrences of '\n' (but not '\r') to '\r\n' for you, as well as append the '\r\n' to the response if not present. it will also properly queue all messages sent in pipelining mode and will present lines without any eol characters. in addition, it uses utf-8 as the transmission medium. the server presents the following api to the handler: <caption> server api </caption> name
arguments returns description closesocket none nothing closes the socket and stops the test. setmultiline the new value of multiline nothing the value is a boolean, with true invoking multiline mode. it is off by default. extending a handler to provide different mechanisms is a process not defined here; please check the documentation of the corresponding handler for instructions. using fakeserver in...
...} currently, fakeserver provides no means to keep a persistent connection past a test, requiring connections to be closed, possibly forcibly. alternatively, one can wait for the timeout, which occurs after 3 minutes, so not closing connections would make the tests take unbearably long. ...
...And 2 more matches
CSSStyleSheet.insertRule() - Web APIs
ray(rule[1][0])) { rule = rule[1]; j = 0; } for (var pl = rule.length; j < pl; j++) { var prop = rule[j]; propstr += prop[0] + ': ' + prop[1] + (prop[2] ? ...
...op[2] ? ...
...ow polyfill will correct the input of the
arguments of insertrule() to standardize them in internet explorer 5–8. it supplements insertrule() with a function that separates the selector from the rules before sending the
arguments to the default native insertrule(). ...
...And 2 more matches
Functions - JavaScript
ue other than the default, a function must have a return statement that specifies the value to return. a function without a return statement will return a default value. in the case of a constructor called with the new keyword, the default value is the value of its this parameter. for all other functions, the default return value is undefined. the parameters of a function call are the function's
arguments.
arguments are passed to functions by value. if the function changes the value of an argument, this change is not reflected globally or in the calling function. however, object references are values, too, and they are special: if the function changes the referred object's properties, that change is visible outside the function, as shown in the following example: /* declare the function 'myfunc' ...
...unction. param the name of an argument to be passed to the function. statements the statements comprising the body of the function. the arrow function expression (=>) an arrow function expression has a shorter syntax and lexically binds its this value (see arrow functions for details): ([param[, param]]) => { statements } param => expression param the name of an argument. zero
arguments need to be indicated with (). for only one argument, the parentheses are not required. (like foo => 1) statements or expression multiple statements need to be enclosed in brackets. a single expression requires no brackets. the expression is also the implicit return value of the function. the function constructor note: using the function constructor to create functions is not recommended si...
...r as a function (without using the new operator) has the same effect as invoking it as a constructor. function parameters default parameters default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed. for more details, see default parameters. ...
...And 2 more matches
Array.prototype.reduce() - JavaScript
the reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. the reducer function takes four
arguments: accumulator (acc) current value (cur) current index (idx) source array (src) your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array, and ultimately becomes the final, single resulting value. syntax arr.reduce(callback( accumulator, currentvalue, [, index[, array]] )[, initialvalue]) parameters callback ...
...signed to the accumulator, whose value is remembered across each iteration throughout the array, and ultimately becomes the final, single resulting value. syntax arr.reduce(callback( accumulator, currentvalue, [, index[, array]] )[, initialvalue]) parameters callback a function to execute on each element in the array (except for the first, if no initialvalue is supplied). it takes four
arguments: accumulator the accumulator accumulates callback's return values. it is the accumulated value previously returned in the last invocation of the callback—or initialvalue, if it was supplied (see below). currentvalue the current element being processed in the array. index optional the index of the current element being processed in the array. starts from index 0 if an initialvalue...
...initialvalue is supplied, the first element in the array will be used as the initial accumulator value and skipped as currentvalue. calling reduce() on an empty array without an initialvalue will throw a typeerror. return value the single value that results from the reduction. description the reduce() method executes the callback once for each assigned value present in the array, taking four
arguments: accumulator currentvalue currentindex array the first time the callback is called, accumulator and currentvalue can be one of two values. if initialvalue is provided in the call to reduce(), then accumulator will be equal to initialvalue, and currentvalue will be equal to the first value in the array. if no initialvalue is provided, then accumulator will be equal to the first value in th...
...And 2 more matches
Promise.prototype.catch() - JavaScript
or an error, and you might lose valuable information like stack traces. ...
...ight lose valuable information like stack traces. ...
...demonstration of the internal call: // overriding original promise.prototype.then/catch just to add some logs (function(promise){ var originalthen = promise.prototype.then; var originalcatch = promise.prototype.catch; promise.prototype.then = function(){ console.log('> > > > > > called .then on %o with
arguments: %o', this,
arguments); return originalthen.apply(this,
arguments); }; promise.prototype.catch = function(){ console.error('> > > > > > called .catch on %o with
arguments: %o', this,
arguments); return originalcatch.apply(this,
arguments); }; })(this.promise); // calling catch on an already resolved promise promise.resolve().catch(function xxx(){}); // logs: // > > > > > > called .catch on promise{} with
arguments:
arguments{1} ...
...And 2 more matches
handler.construct() - JavaScript
initialize the proxy must itself have a [[construct]] internal method (i.e. new target must be valid). the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax const p = new proxy(target, { construct: function(target,
argumentslist, newtarget) { } }); parameters the following parameters are passed to the construct() method. this is bound to the handler. target the target object.
argumentslist the list of
arguments for the constructor. newtarget the constructor that was originally called, p above. return value the construct method must return an object. description the handler.construct() method is a tr...
...rap for the new operator. interceptions this trap can intercept these operations: new proxy(...args) reflect.construct() invariants if the following invariants are violated, the proxy will throw a typeerror: the result must be an object. examples trapping the new operator the following code traps the new operator. ...
...ntercept these operations: new proxy(...args) reflect.construct() invariants if the following invariants are violated, the proxy will throw a typeerror: the result must be an object. examples trapping the new operator the following code traps the new operator. ...
...And 2 more matches
String.prototype.substring() - JavaScript
the specified part of the given string. description substring() extracts characters from indexstart up to but not including indexend. in particular: if indexend is omitted, substring() extracts characters to the end of the string. if indexstart is equal to indexend, substring() returns an empty string. if indexstart is greater than indexend, then the effect of substring() is as if the two
arguments were swapped; see example below. any argument value that is less than 0 or greater than stringname.length is treated as if it were 0 and stringname.length, respectively. any argument value that is nan is treated as if it were 0. examples using substring() the following example uses substring() to display characters from the string 'mozilla': let anystring = 'mozilla' // displays 'm' conso...
... anystring.substring(anystring.length - 4) console.log(anystring4) // displays 'zilla' the last 5 characters let anystring = 'mozilla' let anystring5 = anystring.substring(anystring.length - 5) console.log(anystring5) the difference between substring() and substr() there's a subtle difference between the substring() and substr() methods, so you should be careful not to get them confused. the
arguments of substring() represent the starting and ending indexes, while the
arguments of substr() represent the starting index and the number of characters to include in the returned string. furthermore, substr() is considered a legacy feature in ecmascript and could be removed from future versions, so it is best to avoid using it if possible. let text = 'mozilla' console.log(text.substring(2,5)) // =...
... and could be removed from future versions, so it is best to avoid using it if possible. ...
...And 2 more matches
Spread syntax (...) - JavaScript
the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
...y like spread syntax. in a way, rest syntax is the opposite of spread syntax. spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element. see rest parameters. examples spread in function calls replace apply() it is common to use function.prototype.apply() in cases where you want to use the elements of an array as
arguments to a function. function myfunction(x, y, z) { } const args = [0, 1, 2]; myfunction.apply(null, args); with spread syntax the above can be written as: function myfunction(x, y, z) { } const args = [0, 1, 2]; myfunction(...args); any argument in the argument list can use spread syntax, and the spread syntax can be used multiple times. function myfunction(v, w, x, y, z) { } const args = [0, 1];...
...meters without spread syntax, you would have to do it indirectly through partial application: function applyandnew(constructor, args) { function partial () { return constructor.apply(this, args); }; if (typeof constructor.prototype === "object") { partial.prototype = object.create(constructor.prototype); } return partial; } function myconstructor () { console.log("
arguments.length: " +
arguments.length); console.log(
arguments); this.prop1="val1"; this.prop2="val2"; }; const my
arguments = ["hi", "how", "are", "you", "mr", null]; const myconstructorwith
arguments = applyandnew(myconstructor, my
arguments); console.log(new myconstructorwith
arguments); // (internal log of myconstructor):
arguments.length: 6 // (internal log of myconstructor): ...
...And 2 more matches
places/bookmarks - Archive of obsolete content
ookmarkitems : bookmark|group|separator|array a bookmark item (bookmark, group, separator), or an array of bookmark items to be saved. options : object optional options: name type resolve function a resolution function that is invoked during an attempt to save a bookmark item that is not derived from the latest state from the platform. invoked with two
arguments, mine and platform, where mine is the item that is being saved, and platform is the current state of the item on the item. the object returned from this function is what is saved on the platform. by default, all changes on an outdated bookmark item overwrite the platform's bookmark item. returns placesemitter : returns a placesemitter. remove(items) a helper function that takes in a...
...e for the new group specified implicitly // as the parent of the two items }); the data event is also called for search requests, with each result being passed individually into its own data event. let { search } = require("sdk/places/bookmarks"); search({ query: "firefox" }).on("data", function (item) { // each bookmark item that matches the query will // be called in this function });
arguments bookmark|group|separator : for the save function, this is the saved, latest snapshot of the bookmark item. for search, this is a snapshot of a bookmark returned from the search query. bookmark|group|separator|object : only in save data events. the initial instance of the item that was used for the save request. error the error event is emitted whenever a bookmark item's save could not be comp...
...rk|group|separator : for the save function, this is the saved, latest snapshot of the bookmark item. for search, this is a snapshot of a bookmark returned from the search query. bookmark|group|separator|object : only in save data events. the initial instance of the item that was used for the save request. error the error event is emitted whenever a bookmark item's save could not be completed. ...
...henever a bookmark item's save could not be completed.
arguments string : a string indicating the error that occurred. bookmark|group|separator|object : only in save error events. the initial instance of the item that was used for the save request. end the end event is called when all bookmark items and dependencies have been saved, or an aggregate of all items returned from a search query.
arguments array : the array is an ordered list of the input bookmark items, replaced with their updated, latest snapshot instances (the first argument in the data handler), or in the case of an error, the initial instance of the item that was used for the save request (the second argument in the data or error handler). see also using xpcom without chrome - bookmark observer ...
ui/toolbar - Archive of obsolete content
tems: [frame] }); toolbar.on("show", showing); toolbar.on("hide", hiding); function showing(e) { console.log("showing: " + e.title); } function hiding(e) { console.log("hiding: " + e.title); } parameters event : string the name of the event to listen to. toolbar supports the following events: attach, detach, show, and hide. listener : function the listener function. this may be passed
arguments, depending on the particular event. once(event, listener) assign a listener to the first occurrence only of an event emitted by the toolbar. toolbar supports the following events: attach, detach, show, and hide. the listener is automatically removed after the first time the event is emitted. var { toolbar } = require("sdk/ui/toolbar"); var { frame } = require("sdk/ui/frame"); var frame = new ...
...: [frame] }); toolbar.once("show", showing); toolbar.once("hide", hiding); function showing(e) { console.log("showing: " + e.title); } function hiding(e) { console.log("hiding: " + e.title); } parameters event : string the name of the event to listen to. toolbar supports the following events: attach, detach, show, and hide. listener : function the listener function. this may be passed
arguments, depending on the particular event. removelistener(event, listener) removes an event listener. for example, this code is equivalent to once(): var { toolbar } = require("sdk/ui/toolbar"); var { frame } = require("sdk/ui/frame"); var frame = new frame({ url: "./frame.html" }); var toolbar = toolbar({ title: "my toolbar", items: [frame] }); toolbar.on("show", showing); toolbar.on("hide"...
... hide this event is emitted when the user hides the toolbar, either using the "close" button or using the "toolbars" menu. the listener is passed the toolbar instance that was hidden: var { toolbar } = require("sdk/ui/toolbar"); var { frame } = require("sdk/ui/frame"); var frame = new frame({ url: "./frame.html" }); var toolbar = toolbar({ title: "my...
... ...
console - Archive of obsolete content
add-on using the extension auto-installer, then the add-on is installed in firefox, meaning that messages will appear in the browser console. but see the discussion of logging levels: by default, messages logged using log(), info(), trace(), or warn() won't be logged in these situations. ...
...sole methods except exception() and trace() accept one or more javascript objects as
arguments and log them to the console. depending on the console's underlying implementation and user interface, you may be able to examine the properties of non-primitive objects that are logged. console.debug(...) deprecated, you should use console.log() instead. console.error(object[, object, ...]) logs the
arguments to the console, preceded by "error:" and the name of your add-on: console.error("this is an error message"); error: my-addon: this is an error message console.exception(exception) logs the given exception instance as an error, outputting information about the exception's stack traceback if one is available. try { dothing(); } catch (e) { console.exception(e); } function userexceptio...
... { console.exception(e); } function userexception(message) { this.message = message; this.name = "userexception"; } function dothing() { throw new userexception("thing could not be done!"); } error: my-addon: an exception occurred. userexception: thing could not be done! console.info(object[, object, ...]) a synonym for console.log(). console.log(object[, object, ...]) logs the
arguments to the console, preceded by "info:" and the name of your add-on: console.log("this is an informational message"); info: my-addon: this is an informational message console.time(name) starts a timer with a name specified as an input parameter. up to 10,000 simultaneous timers can run on a given page. console.timeend(name) stops the specified timer and logs the elapsed time in seconds since i...
... informational message console.time(name) starts a timer with a name specified as an input parameter. up to 10,000 simultaneous timers can run on a given page. console.timeend(name) stops the specified timer and logs the elapsed time in seconds since its start. see timers. console.trace() logs a stack trace at the point the function is called. console.warn(object[, object, ...]) logs the
arguments to the console, preceded by "warn:" and the name of your add-on: console.warn("this is a warning message"); warn: my-addon: this is a warning message logging levels logging's useful, of course, especially during development. but the more logging there is, the more noise you see in the console output. especially when debug logging shows up in a production environment, the noise can make it h...
Appendix F: Monitoring DOM changes - Archive of obsolete content
ions is by wrapping the functions that trigger those changes. ...
...er those changes. ...
...this scheme is highly flexible and can be made to work under most circumstances. css animation events this technique, which works on firefox 5+, has some particular advantages. ...
... ...
Index - Archive of obsolete content
n sdk access data that is bundled with the add-on, and add-on metadata. 58 simple-prefs add-on sdk store preferences across application restarts. 59 simple-storage add-on sdk, add-ons, reference lets an add-on store data so that it's retained across firefox restarts. 60 system add-on sdk query the add-on's environment and access
arguments passed to it. 61 tabs add-on sdk open, manipulate, and access tabs, and receive tab events. 62 timers add-on sdk set one-off and periodic timers. 63 ui add-on sdk, add-ons, extensions, reference provides access to button, toolbar, and sidebar ui objects. 64 url add-on sdk construct, validate, and parse urls. ...
...request for each key pair that is generated. the first three parameters will be applied to every request. the "escrowauthoritycert" parameter will only be used for requests that pertain to a key that is being escrowed. after the "escrowauthoritycert" parameter, the method takes some javascript code that is invoked when the crmf request is ready. finally, there are 1 or more sets of key generation
arguments. each key generation will be associated with its own request. all the requests will have the same dn. 496 importusercertificates nss the importusercertificates() method is used to import newly issued certificates for the user. the private key for the certificates must already reside in the user's personal private key database. 497 popchallengeresponse nss ...
...an nsicommandline object is passed as the first argument of the launched window: 1957 components xul, xulrunner adding components to xulrunner is simple once you understand how xulrunner registers and saves the components. 1958 creating xulrunner apps with the mozilla build system build documentation, de...
... target object, but has been removed in ecmascript 2016 and is deprecated in browsers. 2075 string.prototype.quote() javascript, method, obsolete, prototype, reference, string the non-standard quote() method returns a copy of the string, replacing various special characters in the string with their escape sequences and wrapping the result in double-quotes ("). 2076
arguments.caller functions, javascript, obsolete, property,
arguments the obsolete
arguments.caller property used to provide the function that invoked the currently executing function. this property has been removed and no longer works. 2077 for each...in deprecated, e4x, javascript, language feature, obsolete, statement the for each...in statement iterates a specified variab...
execute - Archive of obsolete content
tes the executable from its temporary location once it has finished. the optional blocking argument, when set to true, specifies that the installation should wait for this executable to finish before processing the next queued install command. if you do not set this flag and launch an executable that is not a part of the installation, you will raise an error when you restart the browser. passing
arguments to the executable the args parameter, when present, passes a string to the executable as command-line parameters. the following line, for example, passes the "-c" command-line parameter to the executable: err = file.execute(myfile, "-c", true); when you want to pass more than one parameter to the executable itself, however, you must format the args string in a particular way so that the paramet...
... command-line parameter to the executable: err = file.execute(myfile, "-c", true); when you want to pass more than one parameter to the executable itself, however, you must format the args string in a particular way so that the parameters can be broken up and passed separately as required. in general, you should use single quotes for the args string and double quotes to delimit the command-line
arguments within args. the following parsing rules apply: double quotes are treated as quotes; single quotes are ignored by the executable but legal in the execute() method. the outer quotes that frame the args string itself are stripped off when the string is passed to the executable. quotes that are escaped, or "backslashed," are passed through the executable intact. all other backslashed cases a...
... are treated as quotes; single quotes are ignored by the executable but legal in the execute() method. the outer quotes that frame the args string itself are stripped off when the string is passed to the executable. quotes that are escaped, or "backslashed," are passed through the executable intact. all other backslashed cases are ignored. ...
...able. quotes that are escaped, or "backslashed," are passed through the executable intact. all other backslashed cases are ignored. this means that in order to pass three command-line
arguments (-c, -d, and -s) to the executable, you should format the args string as follows: err = file.execute(myfile, '"-c""-d""-s"', true); //technically, given the rules above, you could also pass the same //
arguments with the following line, but the result is much less //readable: err = file.execute(myfile, "\"-c\"\"-d\"\"-s\"", true); also see the note about binaries on the macintosh platform in addfile. ...
MacFAQ - Archive of obsolete content
will automatically enable this behavior if you add class="chromeclass-toolbar" to your <toolbar> element. commandline support commandline handlers work great on the mac if it's a cold start. here's how to implement command-line trapping when the app is already running, without getting into appleevents or c++ code. this is implemented in a pseudo "hidden window" technique and parsing the window
arguments instead of command-line handlers and some of the toolkit singleton window code. taking advantage of the core code "openurl" from "nscommandlineservicemac.cpp", you'll see that it looks for "browser.chromeurl" before defaulting to navigator.xul, and this is called when an xulrunner app is already running, so: create a default preference of "browser.chromeurl" that points to your new "hiddenwind...
... to navigator.xul, and this is called when an xulrunner app is already running, so: create a default preference of "browser.chromeurl" that points to your new "hiddenwindow" as such: "chrome://myxul/content/hiddenwindow.xul" next take the code below and drop it in, to create the hiddenwindow.xul (note: the debug function and nsicommandline try/catch can be removed, all you need is the window.
arguments[0]) <?xml version="1.0"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="myxul_hidden" windowtype="myxul:hiddenwindow" title="" width="0" height="0" persist="screenx screeny width height sizemode" > <!-- load the mozilla helpers --> <script type="application/javascript" src="chrome://global/content/nsusersettings.js" /> <script><...
...spreferences.copyunicharpref("toolkit.singletonwindowtype"); var windowmediator = components.classes["@mozilla.org/appshell/window-mediator;1"] .getservice(components.interfaces.nsiwindowmediator); var win = windowmediator.getmostrecentwindow(singletonwindowtype); if (win) { window.close(); win.focus(); } } if (window.
arguments && window.
arguments[0]){ try { var cmdline = window.
arguments[0] .queryinterface(components.interfaces.nsicommandline); for (var i = 0; i < cmdline.length; ++i) { debug(cmdline.getargument(i)) } } catch(ex) { debug(window.
arguments[0]) // do something with window.
arguments[0] //nspreferences.setunichar...
...y { var cmdline = window.
arguments[0] .queryinterface(components.interfaces.nsicommandline); for (var i = 0; i < cmdline.length; ++i) { debug(cmdline.getargument(i)) } } catch(ex) { debug(window.
arguments[0]) // do something with window.
arguments[0] //nspreferences.setunicharpref("myxul.cmdlinevalue", window.
arguments[0]) } window.addeventlistener("load", checkotherwindows , false); } ]]></script> </window> ...
mach
mochitests in devtools/client/webconsole/test enable tab completion to enable tab completion in bash, run the following command. you can add the command to your .profile so it will run automatically when you start the shell: source /path/to/mozilla-central/python/mach/bash-completion.sh this will enable tab completion of mach command names, and in the future it may complete flags and other
arguments too. note: mach tab completion will not work when running mach in a source directory older than firefox 24. for zsh, you can call the built-in bashcompinit function before sourcing: autoload bashcompinit bashcompinit source /path/to/mozilla-central/python/mach/bash-completion.sh frequently asked questions why should i not use mach? a real faq for a change! mach is not the best software ev...
... python code corresponds to mach commands. the decorators are: @commandprovider this is a class decorator that tells mach that this class contains methods that implement mach commands. without this decorator, mach will not know about any commands defined within, even if they have decorators. @command this is a method decorator that tells mach that this method implements a mach command. the
arguments to the decorator are those that can be passed to the argparse.argumentparser constructor by way of sub-commands. @commandargument this is a method decorator that tells mach about an argument to a mach command. the
arguments to the decorator are passed to argparse.argumentparser.add_argument(). the class and method names can be whatever you want. they are irrelevant to mach. an instance of th...
...hat tells mach about an argument to a mach command. the
arguments to the decorator are passed to argparse.argumentparser.add_argument(). the class and method names can be whatever you want. they are irrelevant to mach. an instance of the @commandprovider class is instantiated by the mach driver if a command in it is called for execution. the __init__ method of the class must take either 1 or 2
arguments (including self). if your class inherits from object, no explicit __init__ implementation is required (the default takes 1 argument). if your class's __init__ takes 2
arguments, the second argument will be an instance of mach.base.commandcontext. this object holds state from the mach driver, including the current directory, a handle on the logging manager, the settings object, and information abo...
...inherits from object, no explicit __init__ implementation is required (the default takes 1 argument). if your class's __init__ takes 2
arguments, the second argument will be an instance of mach.base.commandcontext. this object holds state from the mach driver, including the current directory, a handle on the logging manager, the settings object, and information about available mach commands. the
arguments registered with @commandargument are passed to your method as keyword
arguments using the **kwargs calling convention. so, you should define default values for all of your method's
arguments. the return value from the @command method should be the integer exit code from the process. if not defined or none, 0 will be used. registering mach command providers once you've written a python module p...
CustomizableUI.jsm
get stringbundle, and can't be told to use add-on-provided strings. it's mainly here as convenience for custom builtin widgets that build their own dom but use the same stringbundle as the other builtin widgets. parameters awidget the object whose property we should use to fetch a localizable string aprop the property on the object to use for the fetching aformatargs (optional) any extra
arguments to use for a formatted string adef (optional) the default to return if we don't find the string in the stringbundle return value the localized string, or adef if the string isn't in the bundle. if adef is not provided, and if aprop exists on awidget, we'll return that, otherwise we'll return the empty string hidepanelfornode() given a node, walk up to the first panel in its ancestor chain...
... non-style sheet method the style sheet method (below) is one way to add an icon. the other way is to watch for when your widget is dropped into an area, and give an appropriate icon. this way is simpler because you don't have to maintain a style sheet. ...
...eet method the style sheet method (below) is one way to add an icon. the other way is to watch for when your widget is dropped into an area, and give an appropriate icon. this way is simpler because you don't have to maintain a style sheet. ...
...con = 'chrome://branding/content/icon16.png'; } var myinstances = customizableui.getwidget('noida').instances; for (var i=0; i<myinstances.length; i++) { myinstances[i].node.setattribute('image', useicon); } }, onwidgetdestroyed: function(awidgetid) { console.log('a widget destroyed so removing listener,
arguments:',
arguments); if (awidgetid != 'noida') { return } console.log('my widget destoryed'); customizableui.removelistener(mywidgetlistener); } } customizableui.addlistener(mywidgetlistener); customizableui.createwidget({ id: 'noida', defaultarea: customizableui.area_navbar, label: 'my widget', ...
Sqlite.jsm
e.sqlite", sharedmemorycache: false }); try { sqlite.shutdown.addblocker("my connection closing", async () => await conn.close()); } catch (e) { // it's too late to block shutdown, just close the connection. await conn.close(); throw e; } clone(readonly) this function returns a clone of the current connection-promise. these functions receive the following
arguments: readonly (optional) if true the clone will be read-only, default is false. if the original connection is already read-only, the clone will be, regardless of this option. if the original connection is using the shared cache, this parameter will be ignored and the clone will be as privileged as the original connection. transactioninprogress this boolean property indicates whether a transa...
...atements on the connection. these are arguably the most important apis in this type. executecached(sql, params, onrow) execute(sql, params, onrow) these similar functions are used to execute a single sql statement on the connection. as you might have guessed by the name, there are 2 flavors: cached and non-cached. other than that, they behave identically. these functions receive the following
arguments: sql (required) string sql statement to execute. the trailing semicolon is not required. params (optional) parameters to bind to this statement. this can be an array or an object. see notes below. onrow (optional) function that is called when a row has been received. the return value is a promise that is resolved when the statement has finished execution. when a statement is executed v...
...strongly encouraged to use bound parameters instead of dynamically creating sql statements for security reasons. bound parameters aren't prone to sql injection like manual sql statement construction (e.g., concatenating a raw value into the executed sql statement). note: callers are encouraged to pass objects rather than arrays for bound parameters because they prevent foot guns. with positional
arguments, it is simple to modify the parameter count or positions without fixing all users of the statement. objects/named parameters are a little safer because changes in the order of parameters in the statement won't change how values are bound to those parameters. when onrow is not defined, the full results of the operation are buffered before the caller is notified of statement completion. for ins...
...xecutetransaction(func, type) this function is used to execute a database transaction. a transaction is a series of related statements treated as one functional unit. if the transaction succeeds, all the statements contained within it are committed as one unit. if the transaction fails, the database is rolled back to its state before the transaction started. this function receives the following
arguments: func the function defining the transaction body. type the type of transaction to perform. this must be one of the transaction_* constants on the opened connection instance. valid values are transaction_deferred, transaction_immediate, transaction_exclusive. see the sqlite documentation for their meaning. the default is transaction_deferred. the passed function is a task.jsm compatible ge...
NSS tools : modutil
please contribute to the initial review in mozilla nss bug 836477[1] description the security module database tool, modutil, is a command-line utility for managing pkcs #11 module information both within secmod.db files and within hardware tokens. ...
...ographic operations. this tool can also create certificate, key, and module security database files. the tasks associated with security module database management are part of a process that typically also involves managing key databases and certificate databases. options running modutil always requires one (and only one) option to specify the type of module operation. each option may take
arguments, anywhere from none to multiple
arguments. options -add modulename add the named pkcs #11 module to the database. use this option with the -libfile, -ciphers, and -mechanisms
arguments. -changepw tokenname change the password on the named token. if the token has not been initialized, this option initializes the password. use this option with the -pwfile and -newpwfile
arguments. a passwo...
...sable modutil's interactive prompts so it can be run from a script. use this option only after manually testing each planned operation to check for warnings and to ensure that bypassing the prompts will cause no security lapses or loss of database integrity. -jar jar-file add a new pkcs #11 module to the database using the named jar file. use this command with the -installdir and -tempdir
arguments. the jar file uses the nss pkcs #11 jar format to identify all the files to be installed, the module's name, the mechanism flags, and the cipher flags, as well as any files to be installed on the target machine, including the pkcs #11 module library file and other files such as documentation. this is covered in the jar installation file section in the man page, which details the special scr...
...mation about a particular module and its slots and tokens. -rawadd add the module spec string to the secmod.db database. -rawlist display the module specs for a specified module or for all loadable modules. -undefault modulename specify the security mechanisms for which the named module will not be a default provider. the security mechanisms are specified with the -mechanisms argument.
arguments module give the security module to access. modulespec give the security module spec to load into the security database. -ciphers cipher-enable-list enable specific ciphers in a module that is being added to the database. the cipher-enable-list is a colon-delimited list of cipher names. enclose this list in quotation marks if it contains spaces. -dbdir [sql:]directory specify the databa...
NSS Tools crlutil
nagement. for information on security module database management, see using the security module database tool. for information on certificate and key database management, see using the certificate database tool. availability see the release notes for the platforms this tool is available on. syntax to run the certificate revocation list management tool, type the command crlutil option [
arguments] where options and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options, or with the -h option. options and
arguments options specify an action and are uppercase. option
arguments modify an action and are lowercase. certifi...
... -d delete certificate revocation list from cert database. ...
... erase all crls of specified type from the cert database -l list existing crl located in cert database file. -m modify existing crl which can be located in cert db or in arbitrary file. if located in file it should be encoded in asn.1 encode format.
arguments -b bypass ca signature checks. -p dbprefix specify the prefix used on the nss security database files (for example, my_cert8.db and my_key3.db). this option is provided as a special case. changing the names of the certificate and key databases is not recommended.
... where: crlnumber: identifies the name of an extension non-critical: should be set to 0 since this is non-critical extension date: invalidity date of a cert. date should be represented in generalizedtime format (yyyymmddhhmmssz). usage the certificate revocation list management tool's capabilities are grouped as follows, using these combinations of options and
arguments. options and
arguments in square brackets are optional, those without square brackets are required. -g|-m -c crl-gen-file -n nickname [-i crl] [-u url] [-d keydir] [-p dbprefix] [-l alg] [-a] [-b] -l [-n crl-name] [-d krydir] crlutil -d -n nickname [-d keydir] [-p dbprefix] crlutil -e [-d keydir] [-p dbprefix] crlutil -i -i crl [-t crltype] [-u url] [-d keydir] [-p ...
NSS tools : crlutil
name crlutil — list, generate, modify, or delete crls within the nss security database file(s) and list, create, modify or delete certificates entries in a particular crl. synopsis crlutil [options]
arguments description the certificate revocation list (crl) management tool, crlutil, is a command-line utility that can list, generate, modify, or delete crls within the nss security database file(s) and list, create, modify or delete certificates entries in a particular crl. the key and certificate management process generally begins with creating keys in the key database, then generating and managing certificates in the certificate database(see certutil tool) and continues with certificates expiration or revocation. this document discusses certi...
...piration or revocation. this document discusses certificate revocation list management. for information on security module database management, see using the security module database tool. for information on certificate and key database management, see using the certificate database tool. to run the certificate revocation list management tool, type the command crlutil option [
arguments] where options and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options, or with the -h option. options and
arguments options options specify an action. option
arguments modify an action. the options and a...
...ert database. -i import a crl to the cert database -e erase all crls of specified type from the cert database -l list existing crl located in cert database file. -m modify existing crl which can be located in cert db or in arbitrary file. if located in file it should be encoded in asn.1 encode format. -g
arguments option
arguments modify an action and are lowercase. -b bypass ca signature checks. -p dbprefix specify the prefix used on the nss security database files (for example, my_cert8.db and my_key3.db). this option is provided as a special case. changing the names of the certificate and key databases is not recommended. -a ...
...n-critical date where: crlnumber: identifies the name of an extension non-critical: should be set to 0 since this is non-critical extension date: invalidity date of a cert. date should be represented in generalizedtime format (yyyymmddhhmmssz). usage the certificate revocation list management tool's capabilities are grouped as follows, using these combinations of options and
arguments. options and
arguments in square brackets are optional, those without square brackets are required. see "implemented extensions" for more information regarding extensions and their parameters. * creating or modifying a crl: crlutil -g|-m -c crl-gen-file -n nickname [-i crl] [-u url] [-d keydir] [-p dbprefix] [-l alg] [-a] [-b] * listing all crls or a named crl: c...
Functions
e we'd rather avoid actually creating the scope chain at all, if possible. general closures force the interpreter to verify the whole scope chain. so we optimize this when we can. these optimizations depend on being sure that we will never have to walk the scope chain, so with and eval inhibit them all. null closures. if we can prove at compile time that a function does not refer to any locals or
arguments of enclosing functions, it is a null closure. since it will never need to walk the scope chain, its parent is the global object. this is the best case. barring with and eval, all outermost functions are null closures. null closures with upvars. a nested function is algol-like if it is only ever defined and called, and it isn't accessed in any other way (and it is not a generator-function). such a...
... best case. barring with and eval, all outermost functions are null closures. null closures with upvars. a nested function is algol-like if it is only ever defined and called, and it isn't accessed in any other way (and it is not a generator-function). such a function is guaranteed never to be called again after the enclosing function exits. an algol-like function may read the local variables and
arguments of its immediate enclosing function from the stack, as if by magic. (jscontext::display caches the enclosing function's stack frame.) if that function is also algol-like, its child can read locals and variables from the next enclosing function, and so on. the compiler detects these cases and makes such functions null closures too. flat closures. suppose a function reads some variables from enclos...
...nction is also algol-like, its child can read locals and variables from the next enclosing function, and so on. the compiler detects these cases and makes such functions null closures too. flat closures. suppose a function reads some variables from enclosing functions but is not algol-like. if the function does not assign to any closed-on vars/args, and it only reads closed-on local variables and
arguments that never change value after the function is created, then the function can be implemented as a flat closure. when a flat closure is created, all the closed-on values are copied from the stack into reserved slots of the function object. to evaluate a name, instead of walking the scope chain, we just take the value from the reserved slot. the function object's parent is the global object. flat cl...
...08 name lookups in order of speed, fastest to slowest. arg and local instructions. if a name definitely refers to an argument or local variable of the immediately enclosing function, it can be accessed using jsop_{get,set,call}{arg,local} instructions. some of these can even be fused with other operations into combo instructions like jsop_getargprop, jsop_forlocal, and jsop_inclocal. because
arguments and locals can't be deleted, this optimization is available to all functions, and eval does not interfere with it. but a with block can: function f(s) { eval(s); print(s); // s can be loaded with getarg with (obj) { print(s); // no getarg here; s might refer to obj.s } } upvar instructions. jsop_{get,call}upvar (in algol-like functions only, i think?) todo ...
JSAPI Cookbook
*/ js::rootedvalue constructor_val(cx); if (!js_getproperty(cx, js_getglobalobject(cx), "person", &constructor_val)) return ...
...*/ js::rootedvalue constructor_val(cx); if (!js_getproperty(cx, js_getglobalobject(cx), "person", &constructor_val)) return false; if (!constructor_val.isobject()) { js_reporterror(cx, "person is not a constructor"); ret...
... step 1 - get the value of |person| and check that it is an object. */ js::rootedvalue constructor_val(cx); if (!js_getproperty(cx, js_getglobalobject(cx), "person", &constructor_val)) return false; if (!constructor_val.isobject()) { js_reporterror(cx, "person is not a constructor"); return false; } js::rootedobject constructor(cx, &constructor_val.toobject()); /* step 2 - set up the
arguments. */ js::rootedstring name_str(cx, js_newstringcopyz(cx, "dave")); if (!name_str) return false; js::autovaluearray<2> args(cx); args[0].setstring(name_str); args[1].setint32(24); /* step 3 - call |new person(...args)|, passing the
arguments. */ js::rootedobject obj(cx, js_new(cx, constructor, args)); if (!obj) return false; calling a global js function // javascript var r = foo(); //...
.../ js_setpendingexception(cx, exc); return false; when js_reporterror creates a new error object, it sets the filename and linenumber properties to the line of javascript code currently at the top of the stack. this is usually the line of code that called your native function, so it's usually what you want. ...
JS::CallArgs
this article covers features introduced in spidermonkey 17 helper class encapsulating access to the callee, this value,
arguments, and argument count for a function call. syntax js::callargs js::callargsfromvp(unsigned argc, js::value *vp); name type description args unsigned number of argument. (2nd argument of jsnative) vp js::value * a pointer to the argument value array. (3nd argument of jsnative) methods methods of js::callargs method description bool requireatleast(jscontext *cx, const char *fnname, unsigned required) returns true if there are at least required
arguments passed in. if false, it reports an error message on the context. methods inherited from js::callargsbase method d...
... js::mutablehandlevalue operator[](unsigned i) const returns the i-th zero-indexed argument. ...
...a debug build of spidermonkey, these methods will assert to aid debugging.) if the method you're implementing succeeds by returning true, you *must* set this. (spidermonkey doesn't currently assert this, but it will do so eventually.) you don't need to use or change this if your method fails. description js::callargs is helper class encapsulating access to the callee, this value,
arguments, and argument count for a function call. the intent of js::callargs is that they be used to encapsulate access to the un-abstracted unsigned argc, value *vp
arguments to a function. new code should use callargs instead of js_callee etc. whenever possible. the eventual plan is to change jsnative to take const callargs& directly, for automatic assertion of correct use and to make calling function...
...edders should start internally switching away from using argc and vp directly, except to create a callargs. then, when an eventual release making that change occurs, porting efforts will require changing methods' signatures but won't require invasive changes to the methods' implementations, potentially under time pressure. js::callargs encapsulates access to the callee, this, the function call's
arguments, and eventual return value for a function call. the principal way to create a callargs is like so, using js::callargsfromvp: static bool functionreturningargctimesarg0(jscontext *cx, unsigned argc, js::value *vp) { js::callargs args = js::callargsfromvp(argc, vp); // guard against no
arguments or a non-numeric arg0. if (args.length() == 0 || !args[0].isnumber()) { args.rval(...
JS_ConstructObject
the preferred alternative is to save a copy of the constructor function for the class, then to call it using js_new. ...
...ut note that this reimplementation is not guaranteed to continue working across spidermonkey releases. create a new object of the specified class, with the specified prototype and parent, then invokes a constructor function to initialize the new object. syntax jsobject * js_constructobject(jscontext *cx, jsclass *clasp, jsobject *proto, jsobject *parent); jsobject * js_constructobjectwith
arguments(jscontext *cx, jsclass *clasp, jsobject *proto, jsobject *parent, unsigned int argc, jsval *argv); name type description cx jscontext * the context in which to create the new object. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. clasp jsclass * pointer to the class to use for the new object. if thi...
...this jscontext. clasp jsclass * pointer to the class to use for the new object. if this is null, an ordinary javascript object is created. proto jsobject * the object to serve as the new object's prototype, or null. parent jsobject * the object to serve as the new object's parent, or null. argc unsigned int (only in js_constructobjectwith
arguments) the number of
arguments to pass to the constructor. argv jsval * (only in js_constructobjectwith
arguments) the array of
arguments to pass to the constructor. this may be null if argc is zero. otherwise, the first argc elements of this array must be populated with valid jsval values. the caller does not need to ensure that the array elements are rooted. description js_const...
...nd parent, then invokes a constructor function to initialize the new object. cx is a pointer to a context associated with the runtime in which to create the new object. clasp is a pointer to the class of object to create. proto and parent may specify objects to be used as the new object's prototype and parent. if either is null, the engine tries to find reasonable defaults. js_constructobjectwith
arguments is the same but additionally passes zero or more
arguments to the constructor. neither of these functions is quite like the javascript new keyword. for details on how we find the appropriate constructor and default prototype, see js_newobject: choosing a default prototype. roughly speaking, we use parent or cx to find a global object, and then find clasp's constructor in that global object. i...
Mozilla internal string guide
iendly means that the zero terminator for c compatibility is written after the new content of the string has been written, so the result is a forward-only linear write access pattern instead of a non-linear back-and-forth sequence resulting from using setlength() followed by beginwriting(). low-level means that writing via a raw pointer is possible as with beginwriting(). bulkwrite() takes four
arguments: the new capacity (which may be rounded up), the number of code units at the beginning of the string to preserve (typically the old logical length), a boolean indicating whether reallocating a smaller buffer is ok if the requested capacity would fit in a buffer that's smaller than current one, and a reference to an nsresult for indicating failure on oom. (don't access the return value if the nsre...
...e latter is not the logical length of the string but the writable length of the buffer. the buffer exposed via these methods includes the prefix that you may have requested to be preserved. it's up to you to skip past it so as to not overwrite it. if there's a need to request a different capacity before you are ready to call finish(), you can call restartbulkwrite() on the handle. ...
... the string but the writable length of the buffer. the buffer exposed via these methods includes the prefix that you may have requested to be preserved. it's up to you to skip past it so as to not overwrite it. if there's a need to request a different capacity before you are ready to call finish(), you can call restartbulkwrite() on the handle. it takes three
arguments that match the first three
arguments of bulkwrite(). ...
...rent capacity before you are ready to call finish(), you can call restartbulkwrite() on the handle. it takes three
arguments that match the first three
arguments of bulkwrite(). it returns mozilla::result<mozilla::ok, nsresult> to indicate success or oom. calling restartbulkwrite() invalidates previously-obtained span, raw pointer or length. once you are done writing, call finish(). it takes two
arguments: the new logical length of the string (which must not exceed the capacity retuned by the length() method of the handle) and a boolean indicating whether it's ok to attempt to reallocate a smaller buffer in case a smaller mozjemalloc bucket could accommodate the new logical length. helper classes and functions converting cocoa strings use mozilla::copycocoastringtoxpcomstring() in mozilla/macst...
Index
roviding a single interface that can be reused anytime a simple implementation of nsifactory is needed. here is the interface, and a description of its use.</t> 10 how to pass an xpcom object to a new window needsexample, needshelp if you want to be able to call functions within an xpcom object from a xul window's code, you can do so if you pass the xpcom object as one of the
arguments to the window creation method. 11 how to build a binary xpcom component using visual studio add-ons, extensions, xpcom this is a simple tutorial for building xpcom objects in c++ using visual studio. xpcom is mozilla’s cross platform component object model, similar to microsoft’s com technology. xpcom components can be implemented in c, c++, and javascript, and can be use...
...only text object can support the copy capability so this interface is not limited to editable objects. the substrings used with this interface are specified as follows: if startoffset is less than endoffset, the substring starts with the character at startoffset and ends with the character just before endoffset. if endoffset is lower than startoffset, the result is the same as a call with the two
arguments exchanged. the whole text can be defined by passing the indices zero and iaccessibletext.ncharacters(). if both indices have the same value, an empty string is defined. refer to the @ref _specialoffsets "special offsets for use in the iaccessibletext and iaccessibleeditabletext methods" for information about a special offset constant that can be used in iaccessibleeditabletext methods. 166...
...inhost interfaces, interfaces:scriptable, needscontent, reference, référence(2), xpcom, xpcom interface reference to create temp file with content len header in, it will use by http post. 830 nsiprefbranch2 interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference add a preference change observer. on preference changes, the following
arguments will be passed to nsiobserver.observe(): 831 nsipreflocalizedstring interfaces, interfaces:scriptable, preferences, xpcom, xpcom interface reference used to set the contents of this object. 832 nsiprefservice interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference call to get a preferences "branch" which accesses user pref...
...rence this method is called when a client connection is accepted. 902 nsiservicemanager interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference this method returns a reference to a particular xpcom service given the classid of the service. unlike createinstance, this will always return the same object each time it is called with the same
arguments. 903 getservicebycontractid no summary! 904 isserviceinstantiated no summary! 905 isserviceinstantiatedbycontractid no summary! 906 nsisessionstartup interfaces, interfaces:scriptable, xpcom interface reference, sessionstorage implemented by: @mozilla.org/browser/sessionstartup;1. to use this service, use: ...
nsIXmlRpcClient
null if the last call didn't return an xml-rpc fault. result readonly nsisupports the most recent xml-rpc call re...
...n info void setauthentication ( in string username, in string password ) ; parameters username password setencoding() set character encoding. the default charset if this function is not called is "utf-8" void setauthentication ( in string encoding ) ; parameters encoding encoding charset to be used asynccall() call remote method methodname asynchronously with given
arguments. ...
...entication ( in string username, in string password ) ; parameters username password setencoding() set character encoding. the default charset if this function is not called is "utf-8" void setauthentication ( in string encoding ) ; parameters encoding encoding charset to be used asynccall() call remote method methodname asynchronously with given
arguments. ...
...portsarray struct: nsidictionary faults (server side errors) are indicated by returning ns_error_failure. via nsixpconnect::getpendingexception()->data a nsixmlrpcfault object can be retreieved with more information on the fault. parameters listener a nsixmlrpcclientlistener that will get notified of xml-rpc events ctxt a context to be passed on to the listener methodname remote method to call
arguments array of
arguments to pass to the remote method count void asynccall ( in nsixmlrpcclientlistener listener, in nsisupports ctxt, in string methodname, [array, size_is(count)] in nsisupports
arguments, in pruint32 count ); createtype() convenience: return the correct nsisupportsprimitive for a given xml-rpc type, or nsisupportsarray or nsidictionary. 'base64' isn'...
Debugger.Object - Firefox Developer Tools
...
...ted in different processes. if the referent is not a promise, throw a typeerror exception. promisedependentpromises if the referent is a promise, this is an array of debugger.objects referring to the promises directly depending on the referent promise. these are: return values of then() calls on the promise. return values of promise.all() if the referent promise was passed in as one of the
arguments. return values of promise.race() if the referent promise was passed in as one of the
arguments. once a promise is settled, it will generally notify its dependent promises and forget about them, so this is most useful on pending promises. note that the array only contains the promises that directly depend on the referent promise. it does not contain promises that depend on promises that depend...
...a debuggee value, or { asconstructor: true } to invoke the referent as a constructor, in which case spidermonkey provides an appropriate this value itself. eachargument must be a debuggee value. all extant handler methods, breakpoints, and so on remain active during the call. if the referent is not callable, throw a typeerror. this function follows the invocation function conventions. ...
...spidermonkey provides an appropriate this value itself. eachargument must be a debuggee value. all extant handler methods, breakpoints, and so on remain active during the call. if the referent is not callable, throw a typeerror. this function follows the invocation function conventions. apply(this,
arguments) if the referent is callable, call it with the giventhis value and the argument values in
arguments, and return a completion value describing how the call completed.this should be a debuggee value, or { asconstructor: true } to invokefunction as a constructor, in which case spidermonkey provides an appropriate this value itself.
arguments must either be an array (in the debugger) of debuggee values, or null or undefined, which are treated as an empty array. all extant handler methods, breakpoint...
Window.openDialog() - Web APIs
window.opendialog() is an extension to window.open(). it behaves the same, except that it can optionally take one or more parameters past windowfeatures, and windowfeatures itself is treated a little differently. the optional parameters, if present, are bundled up in a javascript array object and added to the newly created window as a property named window.
arguments. they may be referenced in the javascript of the window at any time, including during the execution of a load handler. these parameters may be used, then, to pass
arguments to and from the dialog window. the call to opendialog() returns immediately. if you want the call to block until the user has closed the dialog, supply modal as a windowfeatures parameter. note that this also means the user won't be able to interact with...
...ser won't be able to interact with the opener window until he closes the modal dialog. syntax newwindow = opendialog(url, name, features, arg1, arg2, ...) newwindow the opened window url the url to be loaded in the newly opened window. name the window name (optional). see window.open() description for detailed information. features see window.open() for details. arg1, arg2, ... the
arguments to be passed to the new window (optional). example var win = opendialog("http://example.tld/zzz.xul", "dlg", "", "pizza", 6.98); notes new features all - initially activates (or deactivates ("all=no")) all chrome (except the behavior flags chrome, dialog and modal). these can be overridden (so "menubar=no,all" turns on all chrome except the menubar.) this feature is explicitly ignored by w...
...n specific instructions, but is instead allowed to select the chrome that best fits a dialog on that operating system. passing extra parameters to the dialog to pass extra parameters into the dialog, you can simply supply them after the windowfeatures parameter: opendialog("http://example.tld/zzz.xul", "dlg", "", "pizza", 6.98); the extra parameters will then get packed into a property named
arguments of type array, and this property gets added to the newly opened dialog window. to access these extra parameters from within dialog code, use the following scheme: var food = window.
arguments[0]; var price = window.
arguments[1]; note that you can access this property from within anywhere in the dialog code. (another example). returning values from the dialog since window.close() erases all ...
...tion. var retvals = { address: null, delivery: null }; opendialog("http://example.tld/zzz.xul", "dlg", "modal", "pizza", 6.98, retvals); if you set the properties of the retvals object in the dialog code as described below, you can now access them via the retvals array after the opendialog() call returns. inside the dialog code, you can set the properties as follows: var retvals = window.
arguments[2]; retvals.address = enteredaddress; retvals.delivery = "immediate"; specification this is not part of any specification. browser compatibility the compatibility table in this page is generated from structured data. if you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. desktopmobilechromeedgefirefoxinternet explore...
Numbers and dates - JavaScript
e math object's pi property has the value of pi (3.141...), which you would use in an application as math.pi similarly, standard mathematical functions are methods of math. these include trigonometric, logarithmic, exponential, and other functions. for example, if you want to use the trigonometric function sine, you would write math.sin(1.56) note that all trigonometric methods of math take
arguments in radians. the following table summarizes the math object's methods. methods of math method description abs() absolute value sin(), cos(), tan() standard trigonometric functions; with the argument in radians. asin(), acos(), atan(), atan2() inverse trigonometric functions; return values in radians. sinh(), cosh(), tanh() hyperbol...
... inverse hyperbolic functions; return values in hyperbolic angle. pow(), exp(), expm1(), log10(), log1p(), log2() exponential and logarithmic functions. floor(), ceil() returns the largest/smallest integer less/greater than or equal to an argument. min(), max() returns the minimum or maximum (respectively) value of a comma separated list of numbers as
arguments. random() returns a random number between 0 and 1. round(), fround(), trunc(), rounding and truncation functions. sqrt(), cbrt(), hypot() square root, cube root, square root of the sum of square
arguments. sign() the sign of a number, indicating whether the number is positive, negative or zero. clz32(), imul() number of leading zero ...
... unlike many other objects, you never create a math object of your own. you always use the built-in math object. date object javascript does not have a date data type. ...
...then calls to the gethours, getminutes, and getseconds methods assign the value of the current hour, minute, and second to hour, minute, and second. the next four statements build a string value based on the time. the first statement creates a variable temp, assigning it a value using a conditional expression; if hour is greater than 12,...
Array.prototype.reduceRight() - JavaScript
ub repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. see also array.prototype.reduce() for left-to-right. syntax arr.reduceright(callback(accumulator, currentvalue[, index[, array]])[, initialvalue]) parameters callback function to execute on each value in the array, taking four
arguments: accumulator the value previously returned in the last invocation of the callback, or initialvalue, if supplied. (see below.) currentvalue the current element being processed in the array. indexoptional the index of the current element being processed in the array. arrayoptional the array reduceright() was called upon. initialvalueoptional value to use as accumulator to th...
...e callback. if no initial value is supplied, the last element in the array will be used and skipped. calling reduce or reduceright on an empty array without an initial value creates a typeerror. return value the value that results from the reduction. description reduceright executes the callback function once for each element present in the array, excluding holes in the array, receiving four
arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring. the call to the reduceright callback would look something like this: array.reduceright(function(accumulator, currentvalue, index, array) { // ... }); the first time the function is called, the accumulator and currentvalue can be...
...f position) and no initialvalue was provided, or if initialvalue is provided but the array is empty, the solo value would be returned without calling callback. ...
....reduceright = function(callback /*, initialvalue*/) { 'use strict'; if (null === this || 'undefined' === typeof this) { throw new typeerror('array.prototype.reduce called on null or undefined'); } if ('function' !== typeof callback) { throw new typeerror(callback + ' is not a function'); } var t = object(this), len = t.length >>> 0, k = len - 1, value; if (
arguments.length >= 2) { value =
arguments[1]; } else { while (k >= 0 && !(k in t)) { k--; } if (k < 0) { throw new typeerror('reduce of empty array with no initial value'); } value = t[k--]; } for (; k >= 0; k--) { if (k in t) { value = callback(value, t[k], k, t); } } return value; }; } examples sum up all va...
Reflect.construct() - JavaScript
tor, but as a function. it is equivalent to calling new target(...args). it gives also the added option to specify a different prototype. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax reflect.construct(target,
argumentslist[, newtarget]) parameters target the target function to call.
argumentslist an array-like object specifying the
arguments with which target should be called. newtarget optional the constructor whose prototype should be used. see also the new.target operator. if newtarget is not present, its value defaults to target. return value a new instance of target (or newtarget, if present),...
...unction to call.
argumentslist an array-like object specifying the
arguments with which target should be called. newtarget optional the constructor whose prototype should be used. see also the new.target operator. if newtarget is not present, its value defaults to target. return value a new instance of target (or newtarget, if present), initialized by target as a constructor with the given
argumentslist. exceptions a typeerror, if target or newtarget are not constructors. description reflect.construct() allows you to invoke a constructor with a variable number of
arguments. (this would also be possible by using the spread syntax combined with the new operator.) let obj = new foo(...args) let obj = reflect.construct(foo, args) reflect.construct() vs object.create() prior to the introd...
...when using object.create() and function.prototype.apply(), the new.target operator will point to undefined within the function used as the constructor, since the ne...
...when using object.create() and function.prototype.apply(), the new.target operator will point to undefined within the function used as the constructor, since the new keyword is not being used to create the object. when invoki...
widget - Archive of obsolete content
e port.emit function receive events from the content script using the port.on function see the guide to communicating using port for details. events attach this event is emitted when a browser window is opened and a new widgetview object is created. if the widget has a content script, this event is fired only when the content script is applied according to the contentscriptwhen attribute.
arguments widgetview : the related widgetview object. click this event is emitted when the widget is clicked.
arguments widgetview : listeners are passed a single argument which is the widgetview that triggered the click event. message if you listen to this event you can receive message events from content scripts associated with this widget. when a content script posts a message using self.postmess...
...the message can be any json-serializable value. mouseover this event is emitted when the user moves the mouse over the widget. mouseout this event is emitted when the user moves the mouse away from the widget. ...
... if the window is closed, firefox exits, or the add-on is disabled. click this event is emitted when the widget view is clicked. message if you listen to this event you can receive message events from content scripts associated with this widget view. when a content script posts a message using self.postmessage(), the message is delivered to the add-on code in the widget view's message event.
arguments value : listeners are passed a single argument which is the message posted from the content script. the message can be any json-serializable value. mouseover this event is emitted when the user moves the mouse over the widget view. mouseout this event is emitted when the user moves the mouse away from the widget view. ...
core/promise - Archive of obsolete content
it aware of promises. module exports promised function to do exactly that: const { promised } = require('sdk/core/promise'); function sum(x, y) { return x + y }; var asyncsum = promised(sum); var c = sum(a, b); var casync = asyncsum(aasync(), basync()); promised takes normal function and composes new promise-aware version of it. the composed function may take both normal values and promises as
arguments and returns promise. the returned promise will resolve to value that would have been returned by an original function if it were called with fulfillment values of given
arguments. this technique is so powerful that it can replace most of the promise utility functions provided by other promise libraries. for example grouping promises to observe single resolution of all of them is as simple as thi...
...ou to discover them. doing things concurrently so far we have being playing with promises that do things sequentially, but there are many cases where one would need to do things concurrently. in the following example we implement functions that take multiple promises and return one that resolves to first one being fulfilled: function race() { let { promise, resolve } = defer(); array.slice(
arguments).foreach(function(promise) { promise.then(resolve); }); return promise; } var asyncaorb = race(readasync(urla), readasync(urlb)); note: that this implementation forgives failures and would fail if all promises fail to resolve. there are cases when promise may or may not be fulfilled in a reasonable time. in such cases it's useful to put a timer on such tasks: function timeout(promise,...
.... in such cases it's usually easier to wrap value into promise than branch on value type: function or(a, b) { var second = resolve(b).then(function(bvalue) { return !!bvalue }); return resolve(a).then(function(avalue) { return !!avalue || second; }, function() { return second; }) } note: we could not use promised function here, as they reject returned promise if any of the given
arguments is rejected. if you need to customize your promises even further you may pass resolve a second optional prototype argument that will have same effect as with defer. treat errors as promises now that we can create all kinds of eventual values, it's useful to have a way to create eventual errors. module exports reject to do exactly that. it takes anything as an argument and returns a promise tha...
util/object - Archive of obsolete content
if two or more argument objects have properties with the same name, the property is overwritten with precedence from right to left, implying that properties of the object on the left are overwritten by a same named property of an object on the right. properties are merged with descriptors onto the source object. any argument given with "falsy" values (null, undefined) in case of objects are skipped. ...
...50 b.bar // 6 b.location // "sf" // merge also translates property descriptors var c = { "type": "addon" }; var d = {}; object.defineproperty(d, "name", { value: "jetpacks", configurable: false }); merge(c, d); var props = object.getownpropertydescriptor(c, "name"); console.log(props.configurable); // true parameters source : object the object that other properties are merged into.
arguments : object n amount of additional objects that are merged into source object. returns object : the source object. extend(
arguments) returns an object that inherits from the first argument and contains all of the properties from all following
arguments, with precedence from right to left. extend(source1, source2, source3) is the equivalent of merge(object.create(source1), source2, source3). l...
...alent of merge(object.create(source1), source2, source3). let { extend } = require("sdk/util/object"); var a = { alpha: "a" }; var b = { beta: "b" }; var g = { gamma: "g", alpha: null }; var x = extend(a, b, g); console.log(a); // { alpha: "a" } console.log(b); // { beta: "b" } console.log(g); // { gamma: "g", alpha: null } console.log(x); // { alpha: null, beta: "b", gamma: "g" } parameters
arguments : object n
arguments that get merged into a new object. returns object : the new, merged object. ...
Install.js - Archive of obsolete content
extlocalenames: null, // e.g. ['en-us', 'en-gb'] extskinnames: null, // e.g. ...
...// e.g. ['en-us', 'en-gb'] extskinnames: null, // e.g. ...
...name + '/'; install.registerchrome(install.skin | installtype, jarpath, regpath); } // perform install var err = install.performinstall(); if (err == install.success || err == install.reboot_needed) { if (!this.silentinstall && this.extpostinstallmessage) { install.alert(this.extpostinstallmessage); } } else { this.handleerror(err); return; } }, parse
arguments: function() { // can't use string handling in install, so use if statement instead var args = install.
arguments; if (args == 'p=0') { this.profileinstall = false; this.silentinstall = true; } else if (args == 'p=1') { this.profileinstall = true; this.silentinstall = true; } }, handleerror: function(err) { if (!this.silentinstall) { install.alert('error: co...
Drag and Drop JavaScript Wrapper - Archive of obsolete content
you would include in the xul file using the script tag. the observer is an object which may have a number of properties, each set to a function which handles a particular aspect of drag and drop. five functions may be defined. you only have to define the ones that you need. ondragstart(event, transferdata, action) define this function to have something happen when a drag starts. it takes three
arguments, the event object as was originally passed to the event handler, the data to drag and the type of drag action. this function should add the data to drag to the transferdata object. ondragover(event, flavor, session) this function should be defined when you want something to happen when an element is dragged over. the first argument is the event object, the second is the flavor of the data and th...
...dragged over. the first argument is the event object, the second is the flavor of the data and the third is a drag session object which provides more details about the drag that is occurring. you should define this function for elements that allow dragged data to be dropped on them. ondragexit(event, session) this function should be defined when something should happen on a drag exit. it has two
arguments, the event object and the drag session. ondrop(event, dropdata, session) this function should be defined when you want something to happen when an object is dropped. the first argument is the event object and the second is the data being dragged. the third argument is the drag session. getsupportedflavours() this function should return a list of flavors that the object being dragged over can ac...
...ag session. ondrop(event, dropdata, session) this function should be defined when you want something to happen when an object is dropped. the first argument is the event object and the second is the data being dragged. the third argument is the drag session. getsupportedflavours() this function should return a list of flavors that the object being dragged over can accept. this function takes no
arguments. this function is necessary so that the wrapper can determine the best flavour to pass to the other functions. for an observer that is observing an element that can start a drag, you should define at least the ondragstart function. for elements that can have objects dropped on them, you should define ondragover, ondrop and getsupportedflavours (and, if desired, ondragexit). the type of data bein...
Java in Firefox Extensions - Archive of obsolete content
the following is a somewhat simplified snippet from xquseme: var reflect = java.lang.reflect; // build an array of the class types which are expected by our constructor (in this ...
...approach is as follows: var myclass = loader.loadclass('com.example.myclass'); // use the same loader from above var myobj = myclass.newinstance(); var binval = myobj.mymethod(arg1, arg2); // pass whatever
arguments you need (they'll be auto-converted to java form, taking into account the liveconnect conversion rules) for more complex cases, in which you need to call a specific constructor with
arguments, you will need reflection. the following is a somewhat simplified snippet from xquseme: var reflect = java.lang.reflect; // build an array of the class types which are expected by our constructor (in this case, java.io.file and a class from another jar we loaded, com.sleepycat.db.environmentconfig) var paramtypes = reflect.array.newinstance(java.lang.class, 2); // 2nd argument should indicate the...
...a.lang.class, 2); // 2nd argument should indicate the number of items in following array paramtypes[0] = java.io.file; var envconfigclass = loader.loadclass('com.sleepycat.db.environmentconfig'); paramtypes[1] = envconfigclass; // get the constructor var constructor = envclass.getconstructor(paramtypes); // now that we have the constructor with the right parameter types, we can build the specific
arguments we wish to pass to it var arglist = reflect.array.newinstance(java.lang.object, 2); // 2nd argument should indicate the number of items in the following array var mydir = new java.io.file(dirurl); // a file url arglist[0] = mydir; var envconfig = envconfigclass.newinstance(); arglist[1] = envconfig; // call our constructor with our
arguments var env = constructor.newinstance(arglist); be aware t...
Reading from Files - Archive of obsolete content
tream. naturally, if the file does not exist, an error will occur. you may wish to use nsifile.exists() to check if the file exists before opening it. in fact, it is a good idea to enclose file reading and writing operations within a try-catch block to capture any errors that might occur during the process. see file errors for a list of errors that might occur. ...
...you can also specify to read from a binary file by using the flag 'binary' instead of 'text'. ...
...you can also specify to read from a binary file by using the flag 'binary' instead of 'text'. the difference is that text streams process the bytes being read into characters in a particular character encoding whereas binary streams always read bytes. first, let's look at reading form text files. ...
Creating Dialogs - Archive of obsolete content
log, and is related to open(). this function differs from open() in several ways. it displays a dialog instead of a window, which implies that it is asking something of the user. it also has subtle differences in the way it works and appears to the user. these differences will vary depending on the platform the application is running on. in addition, the opendialog() function can take additional
arguments beyond the first three. these
arguments are passed to the new dialog and placed in an array stored in the new window's
arguments property. you can pass as many
arguments as you wish. this is a convenient way to supply default values to the fields in the dialog. var somefile=document.getelementbyid('enterfile').value; window.opendialog("chrome://findfile/content/showdetails.xul","showmore", ...
...ent.getelementbyid('enterfile').value; window.opendialog("chrome://findfile/content/showdetails.xul","showmore", "chrome",somefile); in this example the dialog showdetails.xul is displayed. it's passed one argument, somefile, which was taken from the value of an element with the id enterfile. in a script used by the dialog, we can then refer to the argument using the window's
arguments property. for example: var fl = window.
arguments[0]; document.getelementbyid('thefile').value = fl; this is an effective way to pass values to the new window. you can pass values back from the opened window to the original window in one of two ways. first, you could use the window.opener property which holds the window that opened the dialog. second, you could pass a function or object as one...
... note: opendialog() requires universalbrowserwrite privilege. this means it will not work on remote sites; for those, use window.open() instead. the dialog element the dialog element should be used in place of the window element when creating a dialog. ...
Install Scripts - Archive of obsolete content
identifier of a known directory and get subdirectories of it. thus, if your application needed to install some system libraries, you don't need to know the name of those directories. the directory identifiers are listed on this page. for the chrome directory, the directory identifier is 'chrome'. the getfolder() function can be used to get one of these special directories. this function takes two
arguments, the first is the identifier and the second is a subdirectory. for example: finddir = getfolder("chrome","findfile"); setpackagefolder(finddir); here, we get findfile folder in the chrome folder and pass it directly to the setpackagefolder() function. the second argument to getfolder() is the subdirectory which we are going to install into, which doesn't have to exist. you can leave this argumen...
...dfile ( dir ); example: adddirectory("findfile"); the example above will specify that the findfile directory from the installer archive should be installed. we can call these functions multiple times to install other files. next, we'll want to register the find files in the chrome system so that it can be used with a chrome url. this can be done with the registerchrome() function. it takes two
arguments, the first is the type of chrome to register (content, skin or locale). the second is the directory containing the contents.rdf file to register. because the find files dialog contains content, a skin file and a locale file, registerchrome() will need to be called three times. registerchrome(install.content | install.delayed_chrome, getfolder(finddir, "content")); registerchrome(install.skin | in...
...flag is used to indicate that the chrome should be installed the next time mozilla is run. installation completion the adddirectory() and addfile() functions don't copy any files. they only state which files should be installed. similarly, registerchrome() only states that chrome should be registered. to complete the process and begin copying files, call the performinstall() function. it takes no
arguments. the final script for installing the find files component is shown below: source initinstall("find files","/xulplanet/find files","0.5.0.0"); finddir = getfolder("chrome","findfile"); setpackagefolder(finddir); adddirectory("findfile"); registerchrome(install.content | install.delayed_chrome, getfolder(finddir, "content")); registerchrome(install.skin | install.delayed_chrome, getfolder(f...
Tree Box Objects - Archive of obsolete content
s already visible. cell coordinates some of the most interesting functions of the tree box object are several functions which may be used to get the parts of the tree at specific coordinates and vice versa. the getcellat() function may be used to get the cell at specific pixel location the getrowat() function may be used to get a row at a specific location. the getrowat() function takes two
arguments, the x and y coordinates to use. tree.boxobject.getrowat( 50, 100 ); this example will return the index of the row with a horizontal position of 50 and a vertical position of 100. naturally, it doesn't really matter what the value of the x coordinate is since rows always take up the entire horizontal space of the tree. one important thing to note is that the coordinates are measured from the...
...an out parameter is used since the function needs to return more that one value. you will see a number of interfaces that use out parameters in the xulplanet object reference (fixme: deadlink). these are indicated by the word 'out' before the argument. for these, you will need to supply an empty object and the function will fill in the 'value'...
...the twisty. the final value that may be returned is 'image' if there is an image in the tree cell and the coordinate corresponds to a location where the image is. of course, in many cases you may not care what part of the cell the coordinate is on and just want the row and column. to go in reverse and get the coordinates of a specific cell, use the getcoordsforcellitem() function. it takes seven
arguments, as described below. var x = {}, y = {}, width = {}, height = {}; if (typeof tree.columns != "undefined") column = tree.columns[column]; tree.boxobject.getcoordsforcellitem( row, column, part, x, y, width, height ); the row, column, and part
arguments are similar to those returned from the getcellat() function. again, the column should be either a string or a column object depending on which v...
menupopup - Archive of obsolete content
popup is oriented depends on the direction of the anchor. position possible values for position are: before_start, before_end, after_start, after_end, start_before, start_after, end_before, end_after, overlap, and after_pointer. check positioning of the popup guide for a precise description of the effect of the different values. x, y for an anchored popup, the x and y
arguments may be used to offset the popup from its anchored position by some number, measured in css pixels. an unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. in this case, the position and attributesoverride
arguments are ignored. iscontextmenu the iscontextmenu argument should be true for context menus and f...
...p appears, either at a specific screen position, or relative to some element in the window. if either x or y are set to values, the popup will appear at the screen coordinate (x,y). if x and y are -1, the popup will be positioned relative to the element specified as the first argument. this is what you might do to show a popup below a button, for example. in this latter case, the anchor and align
arguments may be used to further control where the popup appears relative to the element. the anchor argument corresponds to the popupanchor attribute on the element. the align argument corresponds to the popupalign attribute on the element. the anchor and align
arguments are ignored if either x or y are not -1. to have a popup appear relative to another element yet still offset by some number of pixel...
... the popuptype should be one of the strings popup, context, or tooltip. each type of popup is intended to be displayed only temporarily; they are not expected to be displayed permanently. ...
tooltip - Archive of obsolete content
popup is oriented depends on the direction of the anchor. position possible values for position are: before_start, before_end, after_start, after_end, start_before, start_after, end_before, end_after, overlap, and after_pointer. check positioning of the popup guide for a precise description of the effect of the different values. x, y for an anchored popup, the x and y
arguments may be used to offset the popup from its anchored position by some number, measured in css pixels. an unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. in this case, the position and attributesoverride
arguments are ignored. iscontextmenu the iscontextmenu argument should be true for context menus and f...
...p appears, either at a specific screen position, or relative to some element in the window. if either x or y are set to values, the popup will appear at the screen coordinate (x,y). if x and y are -1, the popup will be positioned relative to the element specified as the first argument. this is what you might do to show a popup below a button, for example. in this latter case, the anchor and align
arguments may be used to further control where the popup appears relative to the element. the anchor argument corresponds to the popupanchor attribute on the element. the align argument corresponds to the popupalign attribute on the element. the anchor and align
arguments are ignored if either x or y are not -1. to have a popup appear relative to another element yet still offset by some number of pixel...
... the popuptype should be one of the strings popup, context, or tooltip. each type of popup is intended to be displayed only temporarily; they are not expected to be displayed permanently. ...
E4X for templating - Archive of obsolete content
lization e4x works nicely with a simple utility for localizing strings of a properties file: // localization function $s(msg, args){ //get localized message var strs = cc['@mozilla.org/intl/stringbundle;1'].getservice(ci.nsistringbundleservice). ...
...ly serialized inline (and then perhaps converted to the dom) as needed: var list = <>{_if(elems.length(), function () <> <markup/> <markup/> </>)}</>.toxmlstring(); iterating functions such as the following foreach (which can work with arrays, objects, or e4x objects) are quite convenient in iterating over complex structures such as e4x would not normally allow. ...
... else { lev = arr; h = max; arr = min; max = number.positive_infinity; min = 1; } if (h.length === 1) { for (k in arr) { if (it < min) { ++it; continue; } if (it > max) { break; } ret+=h(arr[k], it, lev); // need to get it or lev via
arguments[] since our length detection implies no explicit additional params; otherwise define with more than one param (see below) ++it; } } else { for (k in arr) { if (it < min) { ++it; continue; } if (it > max) { break; } ret+=h(k, arr[k], it, lev); ...
Index - MDN Web Docs Glossary: Definitions of Web-related terms
cification, glossary, fragmentainer a fragmentainer is defined in the css fragmentation specification as follows: 161 function codingscripting, glossary, iife, immediately invoked function expressions (iife), intro, javascript a function is a code snippet that can be called by other code or by itself, or a variable that refers to the function. when a function is called,
arguments are passed to the function as input, and the function can optionally return a value. a function in javascript is also an object. 162 fuzz testing firefox, fuzzing, mozilla, qa, security, testing fuzzing is a technique for testing software using automated tools to provide invalid or unexpected input to a program or function in a program, then checking the results to see if the...
...he user is likely to visit before the user requests the content. page prediction improves performance by enabling almost instant loading of predicted content. however, page prediction may also download content a user does not seek. 315 parameter codingscripting, glossary, javascript a parameter is a named variable passed into a function. parameter variables are used to import
arguments into functions. 316 parent object codingscripting, glossary, needscontent the object to which a given property or method belongs. 317 parse browser, css, codingscripting, glossary, html, javascript, web performance parsing means analyzing and converting a program into an internal format that a runtime environment can actually run, for example the javascri...
...cation that must be followed are often marked as normative. 527 privileged code privileged privileged code - javascript code of your extension. for example, code in content scripts. 528 undefined codingscripting, glossary, javascript, needscontent undefined is a primitive value automatically assigned to variables that have just been declared, or to formal
arguments for which there are no actual
arguments. ...
Parameter - MDN Web Docs Glossary: Definitions of Web-related terms
two kinds of parameters: input parameters the most common kind; they pass values into functions. depending on programming language, input parameters can be passed several ways (e.g., call-by-value, call-by-address, call-by-reference). ...
... two kinds of parameters: input parameters the most common kind; they pass values into functions. depending on programming language, input parameters can be passed several ways (e.g., call-by-value, call-by-address, call-by-reference). ...
... two kinds of parameters: input parameters the most common kind; they pass values into functions. depending on programming language, input parameters can be passed several ways (e.g., call-by-value, call-by-address, call-by-reference). ...
JavaScript basics - Learn web development
dly writing the same code. you have already seen some uses of functions previously. for example: let myvariable = document.queryselector('h1'); alert('hello!'); these functions, document.queryselector and alert, are built into the browser. if you see something which looks like a variable name, but it's followed by parentheses— () —it is likely a function. functions often take
arguments: bits of data they need to do their job.
arguments go inside the parentheses, separated by commas if there is more than one argument. for example, the alert() function makes a pop-up box appear inside the browser window, but we need to give it a string as an argument to tell the function what message to display. you can also define your own functions. in the next example, we create a simple fun...
...for example: multiply(4, 7); multiply(20, 20); multiply(0.5, 3); note: the return statement tells the browser to return the result variable out of the function so it is available to use. ...
...de the browser window, but we need to give it a string as an argument to tell the function what message to display. you can also define your own functions. in the next example, we create a simple function which takes two numbers as
arguments and multiplies them: function multiply(num1,num2) { let result = num1 * num2; return result; } try running this in the console; then test with several
arguments. for example: multiply(4, 7); multiply(20, 20); multiply(0.5, 3); note: the return statement tells the browser to return the result variable out of the function so it is available to use. this is necessary because variables defined inside functions are only available inside those functions. this is called variable scoping. (read more about variable scoping.) events real interactivity on a w...
Inheritance in JavaScript - Learn web development
this.subject = subject; } but this is just redefining the properties anew, not inheriting them from person(), so it defeats the point of what we are trying to do. it also takes more lines of code. inheriting from a constructor with no parameters note that if the constructor you are inheriting from doesn't take its property values from parameters, you don't need to specify them as additional
arguments in call(). so, for example, if you had something really simple like this: function brick() { this.width = 10; this.height = 20; } you could inherit the width and height properties by doing this (as well as the other steps described below, of course): function blueglassbrick() { brick.call(this); this.opacity = 0.5; this.color = 'blue'; } note that we've only specified this inside c...
...tor we have to use the super() operator, like so: class teacher extends person { constructor(subject, grade) { super(); // now 'this' is initialized by calling the parent constructor. this.subject = subject; this.grade = grade; } } there is no point having a sub-class if it doesn't inherit properties from the parent class. it is good then, that the super() operator also accepts
arguments for the parent constructor. looking back to our person constructor, we can see it has the following block of code in its constructor method: constructor(first, last, age, gender, interests) { this.name = { first, last }; this.age = age; this.gender = gender; this.interests = interests; } since the super() operator is actually the parent class constructor, passing it ...
...t constructor. ...
Command line options
e options by comma (,), for example: "to=foo@nowhere.net,subject=cool page" . comma separators must not follow or precede spaces ( ). to assign multiple values to a field, enclose the values in single quotes ('), for example: "to='foo@nowhere.net,foo@foo.de',subject=cool page" . using command line options command line options follow the command to start the application. if the option contains
arguments, enter the argument after the option. some options have abbreviations, for example, "-editor" can be abbreviated as "-edit" (available abbreviations are described in the text below). in some cases, option
arguments must be enclosed in quotation marks (this is noted in the option descriptions below). multiple command line options can be specified. in general, the syntax is as follows: application...
...tall-global-extension /path/to/extension installs the extension into the application directory. the parameter is the path to the extension. you must have administrative privileges. -install-global-theme /path/to/theme same as above, but for themes. you must have administrative privileges. note: since firefox 2.0.0.7, use of the -install-global-extension and -install-global-theme command line
arguments have been restricted to only allow installing add-ons that are on local disks or mapped drives. installing from a network share directly will no longer succeed. -safe-mode launches the application with all extensions disabled, for that launch only (extensions are not loaded, but are not permanently disabled in the extension manager data source). remote control -remote remote_command this...
...l when launching the application (bug 384384). -requestpending tells the application that there will be a windows dde request to open the same url specified on the command line. this should not be specified unless the caller provides all of the functionality provided by the os shell when launching the application (bug 354005). -silent don't open default windows. useful with those command-line
arguments that open their own windows but don't already prevent default windows from opening. firefox, thunderbird3.x and seamonkey2.x only. -v or -version print application version. note that on windows this only works with a redirection such as |more (bug 355889). this option is available only in a command console. x11 options these options are only available for an application build for and running ...
Creating Sandboxed HTTP Connections
.getservice(components.interfaces.nsiioservice); // create an nsiuri var uri = ioservice.newuri(myurlstring, null, null); once the nsiuri has been created, a nsichannel can be generated from it using nsiioservice's newchannelfromuri method: // get a channel for that nsiuri var channel = ioservice.newchannelfromuri(uri); to initiate the connection, the asyncopen method is called. it takes two
arguments: a listener and a context that is passed to the listener's methods. channel.asyncopen(listener, null); http notifications the above mentioned listener is a nsistreamlistener, which gets notified about events such as http redirects and data availability. onstartrequest - gets called when a new request is initiated. ondataavailable - new data is available. since this is a stream, it could...
...artrequest - gets called when a new request is initiated. ondataavailable - new data is available. since this is a stream, it could be called multiple times (depending on the size of the returned data, networking conditions, etc). onstoprequest - the request has finished. onchannelredirect - when a redirect happens, a new nsichannel is created, and both the old and new ones are passed in as
arguments. since nsistreamlistener does not cover cookies, the current channel being used will need to be stored as a global, since another listener will be used for cookie notifications (covered in the next section). it is usually best to use a javascript wrapper that implements all the required methods and calls the specified callback function when the connection has completed. below is an example: //...
...the observer argument. use false. in order to avoid memory leaks, the observer needs to be removed at one point. the removeobserver method takes in the listener object and the topic and removes it from the notification list. as with the above stream listener, an nsiobserver implementing object is needed, which only needs to implement one method, observe. the observe method gets passed in three
arguments, which for the two cookie topics are: asubject: the channel (nsichannel) that caused this notification to happen. atopic: the notification topic. adata: null for the two topics. since the observers get notified for the registered topic for any connection, the listener needs to make sure that the notification is for the http connection our code created. since the channel that causes the ...
Debugging on Mac OS X
p. browse to the .app file that you want to debug (firefox.app, nightlydebug.app etc). the .app file is typically found inside the dist folder in your build directory. if you are debugging firefox, thunderbird, or some other application that supports multiple profiles, using a separate profile for debugging purposes is recommended. see "having a profile for debugging purposes" below. select the "
arguments" tab in the scheme editor, and click the '+' below the "
arguments passed on launch" field. add "-p profilename", where profilename is the name of a profile you created previously. repeat that to also add the argument "-no-remote". also in the "
arguments" panel, you may want to add an environment variable moz_debug_child_process set to the value 1 to help with debugging e10s. select "build" from...
...urposes it is recommended to create a separate profile to debug with, whatever your task, so that you don't lose precious data like bookmarks, saved passwords, etc. so that you're not bothered with the profile manager every time you start to debug, expand the "executables" branch of the "groups & files" list and double click on the executable you added for mozilla. click the plus icon under the "
arguments" list and type "-p <profile name>" (e.g. "-p mozilladebug"). close the window when you're done. running a debug session make sure breakpoints are active (which implies running under the debugger) by opening the product menu and selecting "debug / activate breakpoints" (also shown by the "breakpoints" button in the top right section of the main window). then click the "run" button or select "run...
...scheme a more descriptive name than "copy of scheme" select "run" on the left-hand side of the settings window, then select the "info" tab. set the executable by clicking on the "executable" drop-down, and selecting the plugin-container.app that is inside the app bundle of the copy of firefox you want to debug. on the same tab, under "launch" select "wait for executable to be launched" on the "
arguments" tab, remove all
arguments passed on launch. now you're ready to start debugging: from the "product" menu, ensure the scheme you created above is selected under "scheme" click the "run" button. the information area at the top of the window will show "waiting for plugin-container to launch" from a command line, run your build of firefox. when that launches a child process (for example, when...
PromiseWorker.jsm
o send a message to a worker from the main thread, one normally uses postmessage(). for promiseworker objects, however, you can't do that. instead, use the post() method, as seen below. post syntax promise = myworker.post(afunctionname, aargs, aclosure, atransferlist); parameters afunctionname the name of the function to be called as it appears in the worker file. ...
...ver, you can't do that. instead, use the post() method, as seen below. post syntax promise = myworker.post(afunctionname, aargs, aclosure, atransferlist); parameters afunctionname the name of the function to be called as it appears in the worker file. aargs an array of
arguments to pass to the function named afunctionname in the worker file. if the worker function does not have any
arguments and the empty array should be passed here. if any of the
arguments is a promise, it is resolved before posting the message. if any of the
arguments needs to be transferred instead of copied, this may be specified by making the argument an instance of basepromiseworker.meta or by using the atransferlist argument. by convention, the last argument may be an object options with some of the followin...
...er if the you know what to transfer at the callsite. basepromiseworker.meta above code can also be done with the meta object. each special data argument that you want to transfer, you can wrap in a basepromiseworker.meta object. the above example can be rewritten like this: myworker.post('func', [new basepromiseworker.meta(buffer, {transfers: [buffer]})]); this is convenient if the function's
arguments are generated by some other functions or passed from somewhere else. post callsite doesn't have to know which object should be transferred. for example: myworker.post('func', [foo(), bar(), baz()]) foo now has the power to determine if the argument should be transferred by returning a meta instance. so it can transfer an object without modifying the caller. here is a simple demo showing how t...
NSS Tools pk12util
-o p12file -n certname [-c keycipher] [-c certcipher] [-m | --key_len keylen] [-n | --cert_key_len certkeylen] [common-options] or pk12util -l p12file [-h tokenname] [-r] [common-options] where [common-options] = [-d dir] [-p dbprefix] [-k slotpasswordfile | -k slotpassword] [-w p12filepasswordfile | -w p12filepassword] syntax to run the pkcs #12 tool, type ther command pk12util option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. three of the options, -i, -o, and -l, should be considered commands of the pk12util invocation. each command takes several options. options may take zero or more
arguments. to see a usage string, issue the pkcs12util command without any options. options and
arguments options specify ...
...
arguments are combinations of the options and
arguments listed in the following section. three of the options, -i, -o, and -l, should be considered commands of the pk12util invocation. each command takes several options. options may take zero or more
arguments. to see a usage string, issue the pkcs12util command without any options. options and
arguments options specify an action. option
arguments modify an action. the options and
arguments for the pk12util command are defined as follows: options -i p12file import a certificate and private key from from the p12file into the database. -o p12file export certificate and private key, specified by the -n option, from the database to the p12 file. -l p12file list certificate and private key from from the p12file file. ...
... -d dir specify the database directory into which to import to or export from certificates and keys. if not specified the directory defaults to $home/.netscape (when $home exists in the environment), or to ./.netscape (when $home does not exist in the environment). ...
Hacking Tips
se the help function to get the list of all primitive functions of the shell with their description. note that some functions have been moved under an 'os' object, and help(os) will give brief help on just the members of that "namespace". getting the bytecode of a function (from js shell) the shell has a small function named dis to dump the bytecode of a function with its source notes. without
arguments, it will dump the bytecode of its caller. js> function f () { return 1; } js> dis(f); flags: loc op ----- -- main: 00000: one 00001: return 00002: stop source notes: ofs line pc delta desc args ---- ---- ----- ------ -------- ------ 0: 1 0 [ 0] newline 1: 2 0 [ 0] colspan 2 3: 2 2 [ 2] colspan 9 getting the bytecode of a function (from gd...
...if you want to know at which lir the code is failing at, the js::ion::codegenerator::generatebody function can be intrumented to dump the lir id before each instruction. for (; iter != current->end(); iter++) { ionspew(ionspew_codegen, "instruction %s", iter->opname()); […] masm.store16(imm32(iter->id()), address(stackpointer, -8)); // added if (!iter->acc...
...dding spew for compilations & bailouts & invalidations (from gdb) if you are in rr, and forgot to record with the spew enabled with ionflags or because this is an optimized build, then you can add similar spew with extra breakpoints within gdb. gdb has the ability to set breakpoints with commands, but a simpler / friendlier version is to use dprintf, with a location, and followed by printf-like
arguments. (gdb) dprintf js::jit::ionbuilder::ionbuilder, "compiling %s:%d:%d-%d\n", info->script_->scriptsource()->filename_.mtuple.mfirsta, info->script_->lineno_, info->script_->sourcestart_, info->script_->sourceend_ dprintf 1 at 0x7fb4f6a104eb: file /home/nicolas/mozilla/contrib-push/js/src/jit/ionbuilder.cpp, line 159. (gdb) cond 1 inliningdepth == 0 (gdb) dprintf js::jit::bailoutiontobaseline, "bai...
JSAPI reference
val_is_boolean obsolete since jsapi 32 jsval_is_number obsolete since jsapi 32 jsval_is_int obsolete since jsapi 32 jsval_is_double obsolete since jsapi 32 jsval_is_string obsolete since jsapi 32 jsval_is_object obsolete since jsapi 15 jsval_is_primitive obsolete since jsapi 32 jsval_is_gcthing obsolete since jsapi 32 high-level type-conversion routines for packing and unpacking function
arguments. ...
...since jsapi 32 jsval_is_number obsolete since jsapi 32 jsval_is_int obsolete since jsapi 32 jsval_is_double obsolete since jsapi 32 jsval_is_string obsolete since jsapi 32 jsval_is_object obsolete since jsapi 15 jsval_is_primitive obsolete since jsapi 32 jsval_is_gcthing obsolete since jsapi 32 high-level type-conversion routines for packing and unpacking function
arguments. js_convert
arguments obsolete since jsapi 38 js_convert
argumentsva obsolete since jsapi 38 js_push
arguments obsolete since javascript 1.8.5 js_push
argumentsva obsolete since javascript 1.8.5 js_pop
arguments obsolete since javascript 1.8.5 js_addargumentformatter obsolete since jsapi 18 js_removeargumentformatter obsolete since jsapi 18 the following functions convert js values to various types. they can be ...
...olete since jsapi 13 objects typedef jsobject js_defineobject js_newobject js_newplainobject added in spidermonkey 38 js_newobjectforconstructor added in spidermonkey 1.8.5 js_newglobalobject added in spidermonkey 1.8 js_newobjectwithgivenproto js_new added in spidermonkey 1.8 js_isglobalobject added in jsapi 24 js_constructobject obsolete since jsapi 16 js_constructobjectwith
arguments obsolete since jsapi 16 js_getclass js_getobjectprototype added in jsapi 17 js_getfunctionprototype added in spidermonkey 17 js_getarrayprototype added in spidermonkey 24 js_getconstructor js_getglobalforobject js_getinstanceprivate js_getprototype js_setprototype js_getprivate js_setprivate js_freezeobject added in spidermonkey 1.8.5 js_deepfreezeobject added in spidermonkey 1.8.
mozIStorageConnection
d overview void asyncclose([optional] in mozistoragecompletioncallback acallback); void begintransaction(); void begintransactionas(in print32 transactiontype); mozistoragestatement clone([optional] in boolean areadonly); void close(); void committransaction(); void createaggregatefunction(in autf8string afunctionname, in long anum
arguments, in mozistorageaggregatefunction afunction); mozistorageasyncstatement createasyncstatement(in autf8string asqlstatement); void createfunction(in autf8string afunctionname, in long anum
arguments, in mozistoragefunction afunction); mozistoragestatement createstatement(in autf8string asqlstatement); void createtable(in string atablename, in string atableschema)...
...n(); parameters none. createaggregatefunction() this method creates a new aggregate function that can be used in sql. see mozistorageaggregatefunction for sample code and more details. if you use your connection on multiple threads, your function needs to be threadsafe, or it should only be called on one thread. void createaggregatefunction( in autf8string afunctionname, in long anum
arguments, in mozistorageaggregatefunction afunction ); parameters afunctionname the name of the aggregate function to create, as seen in sql. anum
arguments the number of
arguments the function takes. pass -1 for variable-argument functions. afunction the instance of mozistorageaggregatefunction that implements the function. createasyncstatement() creates a mozistorageasyncstatement for th...
... mozistorageasyncstatement to be used to execute the specified statement. createfunction() creates a new function that can be used in sql. see mozistoragefunction for sample code and more details. if you use your connection on multiple threads, your function needs to be threadsafe, or it should only be called on one thread. void createfunction( in autf8string afunctionname, in long anum
arguments, in mozistoragefunction afunction ); parameters afunctionname the name of function to create, as seen in sql. anum
arguments the number of
arguments the function takes. pass -1 for variable-argument functions. afunction the instance of mozistoragefunction that implements the function. createstatement() creates a mozistoragestatement for the given sql expression. the expression may...
nsIWindowWatcher
nsiauthprompt getnewauthprompter(in nsidomwindow aparent); nsiprompt getnewprompter(in nsidomwindow aparent); nsidomwindow getwindowbyname(in wstring atargetname, in nsidomwindow acurrentwindow); nsisimpleenumerator getwindowenumerator(); nsidomwindow openwindow(in nsidomwindow aparent, in string aurl, in string aname, in string afeatures, in nsisupports a
arguments); void registernotification(in nsiobserver aobserver); void setwindowcreator(in nsiwindowcreator creator); void unregisternotification(in nsiobserver aobserver); attributes attribute type description activewindow nsidomwindow the watcher serves as a global storage facility for the current active (front most non-floating-palette-type...
...search for a given window named aname. note: this method will try to set the default charset for the new window to the default charset of aparent. this is not guaranteed, however. note: this method may dispatch a "toplevel-window-ready" notification via nsiobserverservice if the window did not already exist. note: supported nsisupportsprimitive objects will be reflected into window.
arguments as the base type, however id, void and 64-bit primitive types are not currently supported and will reflect into window.
arguments as null. nsidomwindow openwindow( in nsidomwindow aparent, in string aurl, in string aname, in string afeatures, in nsisupports a
arguments ); parameters aparent the parent window, if any. null if no parent. if it is impossible to get to an nsiwebbrows...
... in it (if aurl is not null) and return it. afeatures window features. see window interface's open() method loads the specified resource into the browsing context (window, <iframe> or tab) with the specified name. if the name doesn't exist, then a new window is opened and the specified resource is loaded into its browsing context.">window.open for details. can be null. list of feature options a
arguments extra argument(s) to be attached to the new window as the window.
arguments property. an nsisupportsarray will be unwound into multiple
arguments (but not recursively!). can be null, in which case the window.
arguments property will not be set on the new window. as of gecko 1.9 alpha 1, can also be an nsiarray instead. return value an nsidomwindow for the opened window. example for example, i...
DevTools API - Firefox Developer Tools
stroyed")); }, handleclick: function(event) { console.log("clicked", event.originaltarget); }, }; eventemitter eventemitter is an interface many developer tool classes and objects implement and use to notify others about changes in their internal state. when an event is emitted on the eventemitter, the listeners will be called with the event name as the first argument and the extra
arguments are spread as the remaining parameters. note: some components use add-on sdk event module instead of the devtools eventemitter. unfortunately, their api's are a bit different and it's not always evident which one a certain component is using. the main differences between the two modules are that the first parameter for add-on sdk events is the first payload argument instead of the event name an...
...ferences between the two modules are that the first parameter for add-on sdk events is the first payload argument instead of the event name and the once method does not return a promise. the work for unifying the event paradigms is ongoing in bug 952653. methods the following methods are available on objects that have been decorated with the eventemitter interface. emit(eventname, ...extra
arguments) emits an event with the given name to this object. parameters: eventname {string} - the name of the event. extra
arguments {...any} - extra
arguments that are passed to the listeners. on(eventname, listener) adds a listener for the given event. off(eventname, listener) removes the previously added listener from the event. once(eventname, listener) adds a listener for the...
...stener) adds a listener for the given event. off(eventname, listener) removes the previously added listener from the event. once(eventname, listener) adds a listener for the event that is removed after it has been emitted once. return value: a promise that is fulfilled with the first extra argument for the event when then event is emitted. if the event contains multiple payload
arguments, the rest are discarded and can only be received by providing the listener function to this method. examples here's a few examples using the gdevtools object. let oninit = (eventname, toolbox, netmonitor) => console.log("netmonitor initialized!"); // attach a listener. gdevtools.on("netmonitor-init", oninit); // remove a listener. gdevtools.off("netmonitor-init", oninit); // attach a one t...
ChildNode.after() - Web APIs
argitem : document.createtextnode(string(argitem))); }); this.parentnode.insertbefore(docfrag, this.nextsibling); } }); }); })([element.prototype, characterdata.prototype, documentt...
...ring(argitem))); }); this.parentnode.insertbefore(docfrag, this.nextsibling); } }); }); })([element.prototype, characterdata.prototype, documenttype.prototype]); another polyfill // from: https://github.com/fabiovergani/js-polyfill_element.prototype.after/blob/master/after.js (function(x){ var o=x.prototype,p='after'; if(!o[p]){ o[p]=function(){ var e, m=
arguments, l=m.length, i=0, t=this, p=t.parentnode, n=node, s=string, d=document; if(p!==null){ while(i<l){ e=m[i]; if(e instanceof n){ t=t.nextsibling; if(t!==null){ p.insertbefore(e,t); }else{ p.appendchild(e); }; }else{ p.appendchild(d.createtextnode(s(e))); }; ...
... living standard ...
ChildNode.replaceWith() - Web APIs
hod is not scoped into the with statement. see symbol.unscopables for more information. ...
...ion. ...
... in internet explorer 10+ and higher with the following code: function replacewithpolyfill() { 'use-strict'; // for safari, and ie > 10 var parent = this.parentnode, i =
arguments.length, currentnode; if (!parent) return; if (!i) // if there are no
arguments parent.removechild(this); while (i--) { // i-- decrements i and returns the value of i before the decrement currentnode =
arguments[i]; if (typeof currentnode !== 'object'){ currentnode = this.ownerdocument.createtextnode(currentnode); } else if (currentnode.parentnode){ currentnode.parentnode.removechild(currentnode); } // the value of "i" below is after the decrement if (!i) // if currentnode is the first argument (currentnode ===
arguments[0]) parent.replacechild(currentnode, this); ...
console - Web APIs
ractive listing of the properties of a specified javascript object. this listing lets you use disclosure triangles to examine the contents of child objects. console.dirxml() displays an xml/html element representation of the specified object if possible or the javascript object view if it is not possible. console.error() outputs an error message. you may use string substitution and additional
arguments with this method. console.exception() an alias for error(). console.group() creates a new inline group, indenting all following output by another level. to move back out a level, call groupend(). console.groupcollapsed() creates a new inline group, indenting all following output by another level. however, unlike group() this starts with the inline group collapsed requiring the use of a ...
...() creates a new inline group, indenting all following output by another level. however, unlike group() this starts with the inline group collapsed requiring the use of a disclosure button to expand it. to move back out a level, call groupend(). console.groupend() exits the current inline group. console.info() informative logging of information. you may use string substitution and additional
arguments with this method. console.log() for general output of logging information. you may use string substitution and additional
arguments with this method. console.profile() starts the browser's built-in profiler (for example, the firefox performance tool). you can specify an optional name for the profile. console.profileend() stops the profiler. you can see the resulting profile in the brows...
...ven page. console.timeend() stops the specified timer and logs the elapsed time in seconds since it started. console.timelog() logs the value of the specified timer to the console. console.timestamp() adds a marker to the browser's timeline or waterfall tool. console.trace() outputs a stack trace. console.warn() outputs a warning message. you may use string substitution and additional
arguments with this method. examples outputting text to the console the most frequently-used feature of the console is logging of text and other data. there are four categories of output you can generate, using the console.log(), console.info(), console.warn(), and console.error() methods respectively. each of these results in output styled differently in the log, and you can use the filtering controls...
GlobalEventHandlers.onerror - Web APIs
is fired at the element that initiated the load, and the onerror() handler on the element is invoked. these error events do not bubble up to window, but (at least in firefox) can be handled with a window.addeventlistener configured with usecapture set to true. installing a global error event handler is useful for automated collection of error reports. syntax for historical reasons, different
arguments are passed to window.onerror and element.onerror handlers (as well as on error-type window.addeventlistener handlers). window.onerror window.onerror = function(message, source, lineno, colno, error) { ... }; function parameters: message: error message (string). available as event (sic!) in html onerror="" handler. source: url of the script where the error was raised (string) lineno: line...
... specifications specification status comment html living standardthe definition of 'onerror' in that specification. living standard ...
... columnno, 'error object: ' + json.stringify(error) ].join(' - '); alert(message); } return false; }; when using the inline html markup (<body onerror="alert('an error occurred')">), the html specification requires
arguments passed to onerror to be named event, source, lineno, colno, error. in browsers that have not implemented this requirement, they can still be obtained via
arguments[0] through
arguments[2]. specifications specification status comment html living standardthe definition of 'onerror' in that specification. living standard ...
Drag Operations - Web APIs
s data to be provided in more specific types, often custom types, yet still provide fallback data for drop targets that do not support more specific types. it is usually the case that the least specific type will be normal text data using the type text/plain. this data will be a simple textual representation. to set a drag data item within the datatransfer, use the setdata() method. it takes two
arguments: the type of data and the data value. for example: event.datatransfer.setdata("text/plain", "text to drag"); in this case, the data value is "text to drag" and is of the format text/plain. you can provide data in multiple formats. to do this, call the setdata() method multiple times with different formats. you should call it with formats in order from most specific to least specific. const d...
...mage when a drag occurs, a translucent image is generated from the drag target (the element the "dragstart" event is fired at), and follows the user's pointer during the drag. this image is created automatically, so you do not need to create it yourself. however, you can use setdragimage() to specify a custom drag feedback image. ...
... it is also possible to use images and canvases that are not in a document. ...
Migrating from webkitAudioContext - Web APIs
; // some time later... console.log(context.activesourcecount); could be rewritten like that: // array to track the playing source nodes: var sources = []; // when starting the source, put it at the end of the array, // and set a handler to make sure it gets removed when the // audiobuffersourcenode reaches its end. ...
...aying source nodes: var sources = []; // when starting the source, put it at the end of the array, // and set a handler to make sure it gets removed when the // audiobuffersourcenode reaches its end. // first argument is the audiobuffersourcenode to start, other
arguments are // the argument to the |start()| method of the audiobuffersourcenode. ...
...e source, put it at the end of the array, // and set a handler to make sure it gets removed when the // audiobuffersourcenode reaches its end. // first argument is the audiobuffersourcenode to start, other
arguments are // the argument to the |start()| method of the audiobuffersourcenode. function startsource() { var src =
arguments[0]; var startargs = array.prototype.slice.call(
arguments, 1); src.onended = function() { sources.splice(sources.indexof(src), 1); } sources.push(src); src.start.apply(src, startargs); } function activesources() { return sources.length; } var src0 = context.createbuffersource(); var src0 = context.createbuffersource(); // set buffers and other parameters... startsource(src0, 0); startsource(src1, 0); // some t...
<basic-shape> - CSS: Cascading Style Sheets
ning downwards. all the lengths expressed in percentages are resolved from the used dimensions of the reference box. shape functions the following shapes are supported. all <basic-shape> values use functional notation and are defined here using the value definition syntax. inset() inset( <shape-arg>{1,4} [round <border-radius>]? ) defines an inset rectangle. when all of the first four
arguments are supplied they represent the top, right, bottom and left offsets from the reference box inward that define the positions of the edges of the inset rectangle. these
arguments follow the syntax of the margin shorthand, that let you set all four insets with one, two or four values. the optional <border-radius> argument(s) define rounded corners for the inset rectangle using the border-radius sh...
...e <shape-radius> argument represents r, the radius of the circle. negative values are invalid. a percentage value here is resolved from the used width and height of the reference box as sqrt(width^2+height^2)/sqrt(2). the <position> argument defines the center of the circle. this defaults to center if omitted. ellipse() ellipse( [<shape-radius>{2}]? [at <position>]? ) the <shape-radius>
arguments represent rx and ry, the x-axis and y-axis radii of the ellipse, in that order. negative values for either radius are invalid. percentage values here are resolved against the used width (for the rx value) and the used height (for the ry value) of the reference box. the position argument defines the center of the ellipse. this defaults to center if omitted. polygon() polygon( [<fill-rule>,...
...t in the list represents xi and yi - the x and y axis coordinates of the ith vertex of the polygon. path() path( [<fill-rule>,]? <string>) the optional <fill-rule> represents the filling rule used to determine the interior of the path. possible values are nonzero and evenodd. default value when omitted is nonzero. the required <string> is an svg path string encompassed in quotes the
arguments not defined above are defined as follows: <shape-arg> = <length> | <percentage> <shape-radius> = <length> | <percentage> | closest-side | farthest-side defines a radius for a circle or ellipse. if omitted it defaults to closest-side. closest-side uses the length from the center of the shape to the closest side of the reference box. for circles, this is the closest side in any dimension. for el...
JavaScript error reference - JavaScript
are deprecatedsyntaxerror: "use strict" not allowed in function with non-simple parameterssyntaxerror: "x" is a reserved identifiersyntaxerror: json.parse: bad parsingsyntaxerror: malformed formal parametersyntaxerror: unexpected t...
... of formal parameter "x"syntaxerror: return not in functionsyntaxerror: test for equality (==) mistyped as assignment (=)?syntaxerror: unterminated string literaltypeerror: "x" has no propertiestypeerror: "x" is (not) "y"typeerror: "x" is not a constructortypeerror: "x" is not a functiontypeerror: "x" is not a non-null objecttypeerror: "x" is read-onlytypeerror: 'x' is not iterabletypeerror: more
arguments neededtypeerror: reduce of empty array with no initial valuetypeerror: x.prototype.y called on incompatible typetypeerror: can't access dead objecttypeerror: can't access property "x" of "y"typeerror: can't assign to property "x" on "y": not an objecttypeerror: can't define property "x": "obj" is not extensibletypeerror: can't delete non-configurable array elementtypeerror: can't redefine non-con...
...erty "x" on "y": not an objecttypeerror: can't define property "x": "obj" is not extensibletypeerror: can't delete non-configurable array elementtypeerror: can't redefine non-configurable property "x"typeerror: cannot use "in" operator to search for "x" in "y"typeerror: cyclic object valuetypeerror: invalid "instanceof" operand "x"typeerror: invalid array.prototype.sort argumenttypeerror: invalid
argumentstypeerror: invalid assignment to const "x"typeerror: property "x" is non-configurable and can't be deletedtypeerror: setting getter-only property "x"typeerror: variable "x" redeclares argumenturierror: malformed uri sequencewarning: 08/09 is not a legal ecma-262 octal constantwarning: -file- is being assigned a //# sourcemappingurl, but already has onewarning: date.prototype.tolocaleformat is depr...
Array.prototype.every() - JavaScript
n. it returns a boolean value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax arr.every(callback(element[, index[, array]])[, thisarg]) parameters callback a function to test for each element, taking three
arguments: element the current element being processed in the array. index optional the index of the current element being processed in the array. array optional the array every was called upon. thisarg optional a value to use as this when executing callback. return value true if the callback function returns a truthy value for every array element. otherwise, false. description the...
...d immediately returns false. otherwise, if callback returns a truthy value for all elements, every returns true. caution: calling this method on an empty array will return true for any condition! callback is invoked only for array indexes which have assigned values. it is not invoked for indexes which have been deleted, or which have never been assigned values. callback is invoked with three
arguments: the value of the element, the index of the element, and the array object being traversed. if a thisarg parameter is provided to every, it will be used as callback's this value. otherwise, the value undefined will be used as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. every does not mut...
...gument "length". // 3. let len be touint32(lenvalue). var len = o.length >>> 0; // 4. if iscallable(callbackfn) is false, throw a typeerror exception. if (typeof callbackfn !== 'function' && object.prototype.tostring.call(callbackfn) !== '[object function]') { throw new typeerror(); } // 5. if thisarg was supplied, let t be thisarg; else let t be undefined. if (
arguments.length > 1) { t = thisarg; } // 6. let k be 0. k = 0; // 7. repeat, while k < len while (k < len) { var kvalue; // a. let pk be tostring(k). // this is implicit for lhs operands of the in operator // b. let kpresent be the result of calling the hasproperty internal // method of o with argument pk. // this step can be combine...
Array.prototype.findIndex() - JavaScript
/mdn/interactive-examples and send us a pull request. see also the find() method, which returns the value of an array element, instead of its index. syntax arr.findindex(callback( element[, index[, array]] )[, thisarg]) parameters callback a function to execute on each value in the array until the function returns true, indicating that the satisfying element was found. it takes three
arguments: element the current element being processed in the array. index optional the index of the current element being processed in the array. array optional the array findindex() was called upon. thisarg optional optional object to use as this when executing callback. return value the index of the first element in the array that passes the test. otherwise, -1. description the...
...y until it finds the one where callback returns a truthy value. if such an element is found, findindex() immediately returns the element's index. if callback never returns a truthy value (or the array's length is 0), findindex() returns -1. edge case alert: unlike other array methods such as array.some(), callback is run even for indexes with unassigned values. callback is invoked with three
arguments: the value of the element the index of the element the array object being traversed if a thisarg parameter is passed to findindex(), it will be used as the this inside each invocation of the callback. if it is not provided, then undefined is used. the range of elements processed by findindex() is set before the first invocation of callback. callback will not process the elements appended ...
...r o = object(this); // 2. let len be ? tolength(? get(o, "length")). var len = o.length >>> 0; // 3. if iscallable(predicate) is false, throw a typeerror exception. if (typeof predicate !== 'function') { throw new typeerror('predicate must be a function'); } // 4. if thisarg was supplied, let t be thisarg; else let t be undefined. var thisarg =
arguments[1]; // 5. let k be 0. var k = 0; // 6. repeat, while k < len while (k < len) { // a. let pk be ! tostring(k). // b. let kvalue be ? get(o, pk). // c. let testresult be toboolean(? call(predicate, t, « kvalue, k, o »)). // d. if testresult is true, return k. var kvalue = o[k]; if (predicate.call(thisarg, kvalue, k, o)) { ...
Array.from() - JavaScript
scallable(items[symboliterator]); // 3. returnifabrupt(items). if (arraylikeoriterator == null && !isiterator) { throw new typeerror( 'array.from requires an array-like object or iterator - not null or undefined' ); } // 4. if mapfn is undefined, then let mapping be false. var mapfn =
arguments.length > 1 ?
arguments[1] : void undefined; var t; if (typeof mapfn !== 'undefined') { // 5. else // 5. a if iscallable(mapfn) is false, throw a typeerror exception. if (!iscallable(mapfn)) { throw new typeerror( 'array.from: when provided, the second argument must be a function' ...
... // 5. a if iscallable(mapfn) is false, throw a typeerror exception. if (!iscallable(mapfn)) { throw new typeerror( 'array.from: when provided, the second argument must be a function' ); } // 5. b. if thisarg was supplied, let t be thisarg; else let t be undefined. if (
arguments.length > 2) { t =
arguments[2]; } } // 10. let lenvalue be get(items, "length"). // 11. let len be tolength(lenvalue). var len = tolength(items.length); // 13. if isconstructor(c) is true, then // 13. a. let a be the result of calling the [[construct]] internal method // of c ...
...] array from a set const set = new set(['foo', 'bar', 'baz', 'foo']); array.from(set); // [ "foo", "bar", "baz" ] array from a map const map = new map([[1, 2], [2, 4], [4, 8]]); array.from(map); // [[1, 2], [2, 4], [4, 8]] const mapper = new map([['1', 'a'], ['2', 'b']]); array.from(mapper.values()); // ['a', 'b']; array.from(mapper.keys()); // ['1', '2']; array from an array-like object (
arguments) function f() { return array.from(
arguments); } f(1, 2, 3); // [ 1, 2, 3 ] using arrow functions and array.from() // using an arrow function as the map function to // manipulate the elements array.from([1, 2, 3], x => x + x); // [2, 4, 6] // generate a sequence of numbers // since the array is initialized with `undefined` on each position, // the value of `v` below will be `undefined` ar...
Date.prototype.toLocaleDateString() - JavaScript
the tolocaledatestring() method returns a string with a language sensitive representation of the date portion of this date. the new locales and options
arguments let applications specify the language whose formatting conventions should be used and allow to customize the behavior of the function. in older implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. the source for this interactive example is stored in a github repository. ...
...d and the form of the string returned are entirely implementation dependent. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax dateobj.tolocaledatestring([locales [, options]]) parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. see the intl.datetimeformat() constructor for details on these parameters and how to use them. the default value...
...ce when formatting large numbers of dates, it is better to create an intl.datetimeformat object and use the function provided by its format property. examples using tolocaledatestring() in basic use without specifying a locale, a formatted string in the default locale and with default options is returned. var date = new date(date.utc(2012, 11, 12, 3, 0, 0)); // tolocaledatestring() without
arguments depends on the implementation, // the default locale, and the default time zone console.log(date.tolocaledatestring()); // → "12/11/2012" if run in en-us locale with time zone america/los_angeles checking for support for locales and options
arguments the locales and options
arguments are not supported in all browsers yet. to check whether an implementation supports them already, you can use ...
Date.prototype.toLocaleString() - JavaScript
the tolocalestring() method returns a string with a language sensitive representation of this date. the new locales and options
arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function. in older implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation-dependent. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
...e used and the form of the string returned are entirely implementation-dependent. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax dateobj.tolocalestring([locales[, options]]) parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. see the intl.datetimeformat() constructor for details on these parameters and how to use them. the default value...
...erformance when formatting large numbers of dates, it is better to create an intl.datetimeformat object and use the function provided by its format property. examples using tolocalestring() in basic use without specifying a locale, a formatted string in the default locale and with default options is returned. let date = new date(date.utc(2012, 11, 12, 3, 0, 0)); // tolocalestring() without
arguments depends on the // implementation, the default locale, and the default time zone console.log(date.tolocalestring()); // → "12/11/2012, 7:00:00 pm" if run in en-us locale with time zone america/los_angeles checking for support for locales and options
arguments the locales and options
arguments are not supported in all browsers yet. to check whether an implementation supports them already, you ...
Date.prototype.toLocaleTimeString() - JavaScript
the tolocaletimestring() method returns a string with a language sensitive representation of the time portion of this date. the new locales and options
arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function. in older implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. the source for this interactive example is stored in a github repository. ...
...ed and the form of the string returned are entirely implementation dependent. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax dateobj.tolocaletimestring([locales[, options]]) parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. see the intl.datetimeformat() constructor for details on these parameters and how to use them. the default value...
...nce when formatting large numbers of dates, it is better to create an intl.datetimeformat object and use the function provided by its format property. examples using tolocaletimestring() in basic use without specifying a locale, a formatted string in the default locale and with default options is returned. var date = new date(date.utc(2012, 11, 12, 3, 0, 0)); // tolocaletimestring() without
arguments depends on the implementation, // the default locale, and the default time zone console.log(date.tolocaletimestring()); // → "7:00:00 pm" if run in en-us locale with time zone america/los_angeles checking for support for locales and options
arguments the locales and options
arguments are not supported in all browsers yet. to check whether an implementation supports them already, you can use ...
Function.prototype.call() - JavaScript
the call() method calls a function with a given this value and
arguments provided individually. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax func.call([thisarg[, arg1, arg2, ...argn]]) parameters thisarg optional the value to use as this when calling func. caution: in certain cases, thisarg may not be the actual value seen by the method. if the method is a function in non-strict mode, null and undefined will be replaced with the global object, and primitive values will be converted to objects. arg1, arg2, ...argn optional
arguments for the function. return value the result of calling the ...
...nc. caution: in certain cases, thisarg may not be the actual value seen by the method. if the method is a function in non-strict mode, null and undefined will be replaced with the global object, and primitive values will be converted to objects. arg1, arg2, ...argn optional
arguments for the function. return value the result of calling the function with the specified this value and
arguments. description the call() allows for a function/method belonging to one object to be assigned and called for a different object. call() provides a new value of this to the function/method. with call(), you can write a method once and then inherit it in another object, without having to rewrite the method for the new object. note: while the syntax of this function is almost identical to that of...
...ent object. call() provides a new value of this to the function/method. with call(), you can write a method once and then inherit it in another object, without having to rewrite the method for the new object. note: while the syntax of this function is almost identical to that of apply(), the fundamental difference is that call() accepts an argument list, while apply() accepts a single array of
arguments. examples using call to chain constructors for an object you can use call to chain constructors for an object (similar to java). in the following example, the constructor for the product object is defined with two parameters: name and price. two other functions, food and toy, invoke product, passing this, name, and price. product initializes the properties name and price, both specialized f...
Function - JavaScript
nstructor === function, which returns true. constructor function() creates a new function object. calling the constructor directly can create functions dynamically but suffers from security and similar (but far less significant) performance issues to eval. however, unlike eval, the function constructor creates functions that execute in the global scope only. instance properties function.
arguments an array corresponding to the
arguments passed to a function. this is deprecated as a property of function. use the
arguments object (available within the function) instead. function.caller specifies the function that invoked the currently executing function. this property is deprecated, and is only functional for some non-strict functions. function.displayname the display name of the func...
... to a function. this is deprecated as a property of function. use the
arguments object (available within the function) instead. function.caller specifies the function that invoked the currently executing function. this property is deprecated, and is only functional for some non-strict functions. function.displayname the display name of the function. function.length specifies the number of
arguments expected by the function. function.name the name of the function. instance methods function.prototype.apply(thisarg [, argsarray]) calls a function and sets its this to the provided thisarg.
arguments can be passed as an array object. function.prototype.bind(thisarg[, arg1[, arg2[, ...argn]]]) creates a new function which, when called, has its this set to the provided thisarg. optionall...
...on. function.name the name of the function. instance methods function.prototype.apply(thisarg [, argsarray]) calls a function and sets its this to the provided thisarg.
arguments can be passed as an array object. function.prototype.bind(thisarg[, arg1[, arg2[, ...argn]]]) creates a new function which, when called, has its this set to the provided thisarg. optionally, a given sequence of
arguments will be prepended to
arguments provided the newly-bound function is called. function.prototype.call(thisarg[, arg1, arg2, ...argn]) calls a function and sets its this to the provided value.
arguments can be passed as they are. function.prototype.tostring() returns a string representing the source code of the function. overrides the object.prototype.tostring method. examples difference bet...
Number.prototype.toLocaleString() - JavaScript
method returns a string with a language-sensitive representation of this number. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax numobj.tolocalestring([locales [, options]]) parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. see the intl.numberformat() constructor for details on these parameters and how to use them. return value a s...
...te a numberformat object and use the function provided by its numberformat.format property. examples using tolocalestring in basic use without specifying a locale, a formatted string in the default locale and with default options is returned. var number = 3500; console.log(number.tolocalestring()); // displays "3,500" if in u.s. english locale checking for support for locales and options
arguments the locales and options
arguments are not supported in all browsers yet. to check for support in es5.1 and later implementations, the requirement that illegal language tags are rejected with a rangeerror exception can be used: function tolocalestringsupportslocales() { var number = 0; try { number.tolocalestring('i'); } catch (e) { return e.name === 'rangeerror'; } return fals...
...tations, the requirement that illegal language tags are rejected with a rangeerror exception can be used: function tolocalestringsupportslocales() { var number = 0; try { number.tolocalestring('i'); } catch (e) { return e.name === 'rangeerror'; } return false; } prior to es5.1, implementations were not required to throw a range error exception if tolocalestring is called with
arguments. a check that works in all hosts, including those supporting ecma-262 prior to ed 5.1, is to test for the features specified in ecma-402 that are required to support regional options for number.prototype.tolocalestring directly: function tolocalestringsupportsoptions() { return !!(typeof intl == 'object' && intl && typeof intl.numberformat == 'function'); } this tests for a global intl obje...
Object.setPrototypeOf() - JavaScript
2", "@arg_name_3", "..."], "@function_body") *** object.appendchain(@object [, "@arg_name_1, @arg_name_2, @arg_name_3, ..."], "@function_body") * * appends the first non-native prototype of a chain to the native function.prototype object, then appends a * new function(["@arg"(s)], "@function_body") to that chain. * returns the function. ...
...arg_name_1, @arg_name_2, @arg_name_3, ..."], "@function_body") * * appends the first non-native prototype of a chain to the native function.prototype object, then appends a * new function(["@arg"(s)], "@function_body") to that chain. * returns the function. ...
...return = o2nd = olast = ochain instanceof this ? ...
String.prototype.localeCompare() - JavaScript
mpare() method returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. the new locales and options
arguments let applications specify the language whose sort order should be used and customize the behavior of the function. in older implementations, which ignore the locales and options
arguments, the locale and sort order used are entirely implementation-dependent. syntax referencestr.localecompare(comparestring[, locales[, options]]) parameters comparestring the string against which the reference...
...rt order should be used and customize the behavior of the function. in older implementations, which ignore the locales and options
arguments, the locale and sort order used are entirely implementation-dependent. syntax referencestr.localecompare(comparestring[, locales[, options]]) parameters comparestring the string against which the referencestr is compared. locales and options these
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation-dependent. see the intl.collator() constructor for details on these parameters and how to use them. return value a nega...
... neutral value of zero 'a'.localecompare('a'); // 0 sort an array localecompare() enables case-insensitive sorting for an array. let items = ['réservé', 'premier', 'cliché', 'communiqué', 'café', 'adieu']; items.sort( (a, b) => a.localecompare(b, 'fr', {ignorepunctuation: true})); // ['adieu', 'café', 'cliché', 'communiqué', 'premier', 'réservé'] check browser support for extended
arguments the locales and options
arguments are not supported in all browsers yet. to check whether an implementation supports them, use the "i" argument (a requirement that illegal language tags are rejected) and look for a rangeerror exception: function localecomparesupportslocales() { try { 'foo'.localecompare('bar', 'i'); } catch (e) { return e.name === 'rangeerror'; } return false; ...
String.prototype.replace() - JavaScript
ill be replaced. newsubstr (replacement) the string that replaces the substring specified by the specified regexp or substr parameter. a number of special replacement patterns are supported; see the "specifying a string as a parameter" section below. function (replacement) a function to be invoked to create the new substring to be used to replace the matches to the given regexp or substr. the
arguments supplied to this function are described in the "specifying a function as a parameter" section below. return value a new string, with some or all matches of a pattern replaced by a replacement. description this method does not change the calling string object. it simply returns a new string. to perform a global search and replace, include the g switch in the regular expression. specifying a...
...ter. in this case, the function will be invoked after the match has been performed. the function's result (return value) will be used as the replacement string. (note: the above-mentioned special replacement patterns do not apply in this case.) note that the function will be invoked multiple times for each full match to be replaced if the regular expression in the first parameter is global. the
arguments to the function are as follows: possible name supplied value match the matched substring. (corresponds to $& above.) p1, p2, ... the nth string found by a parenthesized capture group (including named capturing groups), provided the first argument to replace() was a regexp object. (corresponds to $1, $2, etc. above.) for example, if /(\a+)(\b+)/, was given,...
...amined. (for example, if the whole string was 'abcd', and the matched substring was 'bc', then this argument will be 1.) string the whole string being examined. groups in browser versions supporting named capturing groups, will be an object whose keys are the used group names, and whose values are the matched portions (undefined if not matched). ...
String.prototype.replaceAll() - JavaScript
ular expression. newsubstr (replacement) the string that replaces the substring specified by the specified regexp or substr parameter. a number of special replacement patterns are supported; see the "specifying a string as a parameter" section below. function (replacement) a function to be invoked to create the new substring to be used to replace the matches to the given regexp or substr. the
arguments supplied to this function are described in the "specifying a function as a parameter" section below. return value a new string, with all matches of a pattern replaced by a replacement. description this method does not change the calling string object. it simply returns a new string. specifying a string as a parameter the replacement string can include the following special replacement patt...
...ter. in this case, the function will be invoked after the match has been performed. the function's result (return value) will be used as the replacement string. (note: the above-mentioned special replacement patterns do not apply in this case.) note that the function will be invoked multiple times for each full match to be replaced if the regular expression in the first parameter is global. the
arguments to the function are as follows: possible name supplied value match the matched substring. (corresponds to $& above.) p1, p2, ... the nth string found by a parenthesized capture group, provided the first argument to replace() was a regexp object. (corresponds to $1, $2, etc. above.) for example, if /(\a+)(\b+)/, was given, p1 is the match for \a+, and p2 fo...
...ponds to $1, $2, etc. above.) for example, if /(\a+)(\b+)/, was given, p1 is the match for \a+, and p2 for \b+. offset the offset of the matched substring within the whole string being examined. (for example, if the whole string was 'abcd', and the matched substring was 'bc', then this argument will be 1.) string the whole string being examined. (the exact number of
arguments depends on whether the first argument is a regexp object—and, if so, how many parenthesized submatches it specifies.) examples using replaceall 'aabbcc'.replaceall('b', '.'); // 'aa..cc' non-global regex throws when using a regular expression search value, it must be global. this won't work: 'aabbcc'.replaceall(/b/, '.'); typeerror: replaceall must be called with a global regexp this wi...
this - JavaScript
values null and undefine...
...values null and undefined become the global object. primitives like 7 or 'foo' will be converted to an object using the related constructor, so the primitive number 7 is converted to an object as...
...7, azerty, azerty arrow functions in arrow functions, this retains the value of the enclosing lexical context's this. in global code, it will be set to the global object: var globalobject = this; var foo = (() => this); console.log(foo() === globalobject); // true note: if this arg is passed to call, bind, or apply on invocation of an arrow function it will be ignored. you can still prepend
arguments to the call, but the first argument (thisarg) should be set to null. // call as a method of an object var obj = {func: foo}; console.log(obj.func() === globalobject); // true // attempt to set this using call console.log(foo.call(obj) === globalobject); // true // attempt to set this using bind foo = foo.bind(obj); console.log(foo() === globalobject); // true no matter what, foo's this is se...
Interacting with page scripts - Archive of obsolete content
create objects in page script scope finally, a content script can use the createobjectin() function to create an object in the page script's scope. it...
...byid("test"); test.addeventlistener("click", function() { alert(window.greetme("page script")); }, false); </script> </body> </html> exportfunction() works by structured cloning the
arguments and return value of the function from one scope to the other. since structured cloning doesn't work for functions, this means that you can't export functions that take functions as
arguments (such as callbacks) or functions that return functions. create objects in page script scope finally, a content script can use the createobjectin() function to create an object in the page script's scope. it can then clone objects or export functions as members of that new object. for example, in the example above the content script could be written like so: // content-script.js var salutation...
context-menu - Archive of obsolete content
tion. contentscriptfile the url of a content script or the array of such urls associated with the menu item during creation. events message if you listen to this event you can receive message events from content scripts associated with this menu item. when a content script posts a message using self.postmessage(), the message is delivered to the add-on code in the menu item's message event.
arguments value : listeners are passed a single argument which is the message posted from the content script. the message can be any json-serializable value. menu a labeled menu item that expands into a submenu. methods additem(item) appends a menu item to the end of the menu. if the item is already contained in another menu or in the top-level context menu, it's automatically removed first. if the i...
... creation. contentscriptfile the url of a content script or the array of such urls associated with the menu during creation. events message if you listen to this event you can receive message events from content scripts associated with this menu item. when a content script posts a message using self.postmessage(), the message is delivered to the add-on code in the menu item's message event.
arguments value : listeners are passed a single argument which is the message posted from the content script. the message can be any json-serializable value. separator a menu separator. separators can be contained only in menus, not in the top-level context menu. methods destroy() permanently removes the separator from its parent menu and frees its resources. the separator must not be used afterward.
timers - Archive of obsolete content
parameters callback : function function to be called. ms : integer interval in milliseconds after which the function will be called. returns integer : an id that can later be used to undo this scheduling, if callback hasn't yet been called. ...
... called (if it hasn't yet been called). parameters id : integer an id returned from settimeout(). example var { settimeout, cleartimeout } = require("sdk/timers"); var id = settimeout(function() { // do something in 1 sec }, 1000); // to stop/cancel this timeout cleartimeout(id); setinterval(callback, ms) schedules callback to be called repeatedly every ms milliseconds. any additional
arguments are passed straight through to the callback. parameters callback : function function to be called. ms : integer interval in milliseconds at which the function will be called. returns integer : an id that can later be used to unschedule the callback. example var { setinterval } = require("sdk/timers"); setinterval(function() { // do something every 1 sec }, 1000) clearinterval(id) g...
windows - Archive of obsolete content
vate' event windows.on('activate', function(window) { console.log("a window was activated."); }); // add a listener to the 'deactivate' event windows.on('deactivate', function(window) { console.log("a window was deactivated."); }); open event emitted when a new window is open. this does not mean that the content has loaded, only that the browser window itself is fully visible to the user. ...
...y that the browser window itself is fully visible to the user.
arguments window : listeners are passed the window object that triggered the event. close event emitted when a window is closed. you can't always rely on receiving the close event for every open window. in particular, if the user quits the browser then it's possible that your add-on will be unloaded before all windows are closed.
arguments window : listeners are passed the window object that triggered the event. activate event emitted when an inactive window is made active.
arguments window : listeners are passed the window object that has become active. deactivate event emitted when the active window is made inactive.
arguments window : listeners are passed the window object that has become inactive. browserwindow a bro...
/loader - Archive of obsolete content
this function is helpful for combining default and passed properties: override({ a: 1, b: 1 }, { b: 2, c: 2 }) // => { a: 1, b: 2, c: 2 } descriptor() this utility function takes an object and as an argument and returns property descriptor map for its own propertie...
...:///modules/' ] ]; resolveuri('./main', mapping); // => resource://my-addon/main.js resolveuri('devtools/gcli', mapping); // => resource:///modules/devtools/gcli.js resolveuri('sdk/core/promise', mapping); // => resource://gre/modules/commonjs/sdk/core/promise.js override() this function is used to create a fresh object that contains own properties of two
arguments it takes. if
arguments have properties with conflicting names the property from the second argument overrides that from the first. this function is helpful for combining default and passed properties: override({ a: 1, b: 1 }, { b: 2, c: 2 }) // => { a: 1, b: 2, c: 2 } descriptor() this utility function takes an object and as an argument and returns property descriptor map for its own properties. it is useful when wo...
event/core - Archive of obsolete content
he listener function that processes the event. once(target, type, listener) registers an event listener that is called only once: the next time an event of the specified type is emitted on the given event target. parameters target : object event target object. type : string the type of event. listener : function the listener function that processes the event. emit(target, type, message,
arguments) execute each of the listeners in order with the supplied
arguments. all the exceptions that are thrown by listeners during the emit are caught and can be handled by listeners of 'error' event. thrown exceptions are passed as an argument to an 'error' event listener. if no 'error' listener is registered exception will be logged into an error console. parameters target : object event target ob...
...it are caught and can be handled by listeners of 'error' event. thrown exceptions are passed as an argument to an 'error' event listener. if no 'error' listener is registered exception will be logged into an error console. parameters target : object event target object. type : string the type of event. message : object|number|string|boolean first argument that will be passed to listeners.
arguments : object|number|string|boolean more
arguments that will be passed to listeners. off(target, type, listener) removes an event listener for the given event type on the given event target. if no listener is passed removes all listeners of the given type. if type is not passed removes all the listeners of the given event target. parameters target : object event target object. type : string th...
places/history - Archive of obsolete content
n the module, but returned from the search functions. the placesemitter inherits from event/target, and emits data, error, and end. data events are emitted for every individual search result found, whereas end events are emitted as an aggregate of an entire search, passing in an array of all results into the handler. events data the data event is emitted for every item returned from a search. ...
...eas end events are emitted as an aggregate of an entire search, passing in an array of all results into the handler. events data the data event is emitted for every item returned from a search.
arguments object : this is an object representing a history entry. contains url, time, accesscount and title of the entry. error the error event is emitted whenever a search could not be completed.
arguments string : a string indicating the error that occurred. end the end event is called when all search results have returned.
arguments array : the value passed into the handler is an array of all entries found in the history search. each entry is an object containing the properties url, time, accesscount and title. ...
test/utils - Archive of obsolete content
oveallbookmarksasync(function () { done(); }); }); require('sdk/test').run(exports); globals functions before(exports, beforefn) runs beforefn before each test in the file. may be asynchronous if beforefn accepts a third argument, which is a callback. parameters exports : object a test file's exports object beforefn : function the function to be called before each test. it has two
arguments, or three if it is asynchronous: the first argument is the test's name as a string. the second argument is the assert object for the test. the third, optional, argument is a callback. if the callback is defined, then the beforefn is considered asynchronous, and the callback must be invoked before the test runs. after(exports, afterfn) runs afterfn after each test in the file. may be async...
...back is defined, then the beforefn is considered asynchronous, and the callback must be invoked before the test runs. after(exports, afterfn) runs afterfn after each test in the file. may be asynchronous if afterfn accepts a third argument, which is a callback. parameters exports : object a test file's exports object afterfn : function the function to be called after each test. it has two
arguments, or three if it is asynchronous: the first argument is the test's name as a string. the second argument is the assert object for the test. the third, optional, argument is a callback. if the callback is defined, then the afterfn is considered asynchronous, and the callback must be invoked before the next test runs. waituntil(predicate, interval) waituntil returns a promise that resolves u...
ui/button/toggle - Archive of obsolete content
fox 36. value to attach to the button as a badge. may be a number or a string. the badge can contain as many characters (or digits) as you like, but only the first four will be displayed. badgecolor new in firefox 36. color for the badge, specified as a css <color> value. events click this event is emitted when a user clicks the button or your add-on calls the button's click() method.
arguments state : the button's state. this includes all the button's properties. change this event is emitted when a user clicks the button or your add-on calls the button's click() method. this event is emitted at the same time as click and its listener receives the same argument. the only purpose of the extra event is that change is a more natural event name for a toggle button, as it matches the chan...
...n's properties. change this event is emitted when a user clicks the button or your add-on calls the button's click() method. this event is emitted at the same time as click and its listener receives the same argument. the only purpose of the extra event is that change is a more natural event name for a toggle button, as it matches the change event emitted by elements like <select> and <input>.
arguments state : the button's state. this includes all the button's properties. ...
util/list - Archive of obsolete content
e, therefore it provides custom enumeration behavior that is similar to array (enumerates only on the elements of the list). list is a base trait and is meant to be part of a composition, since all of its api is private except for the length property. ...
...ist). list is a base trait and is meant to be part of a composition, since all of its api is private except for the length property. examples: var { list } = require("sdk/util/list"); var mylist = list.compose({ add: function add(item1, item2, /*item3...*/) { array.slice(
arguments).foreach(this._add.bind(this)); }, remove: function remove(item1, item2, /*item3...*/) { array.slice(
arguments).foreach(this._remove.bind(this)); } }); mylist('foo', 'bar', 'baz').length == 3; // true new mylist('new', 'keyword').length == 2; // true mylist.apply(null, [1, 2, 3]).length == 3; // true let list = mylist(); list.length == 0; // true list.add(1, 2, 3) == 3; // true properties length number of elements in this list. ...
window/utils - Archive of obsolete content
see the window.open features documentation for more details. optional, defaults to an empty map: {}. var { open } = require('sdk/window/utils'); var window = open('data:text/html,hello window', { name: 'jetpack window', features: { width: 200, height: 50, popup: true } }); args object extra argument(s) to be attached to the new window as the window.
arguments property. returns nsidomwindow opendialog(options) opens a top level window and returns its nsidomwindow representation. this is the same as open, but you can supply more features. it wraps window.opendialog. parameters options : object options for the function, with the following properties: name type url string uri of the document to be loaded...
...d to the window. defaults to "_blank". features string map of features to set for the window, defined like: { width: 10, height: 15, chrome: true }. for the set of features you can set, see the window.opendialog documentation. optional, defaults to: 'chrome,all,dialog=no'. args object extra argument(s) to be attached to the new window as the window.
arguments property. returns nsidomwindow windows() returns an array of all currently opened windows. note that these windows may still be loading. in order to see private windows in this list, your add-on must have opted into private browsing and you must include the includeprivate key in the list of options: var allwindows = window_utils.windows(null, {includeprivate:true}); parameters type...
jpm - Archive of obsolete content
new instance of firefox with the add-on installed: jpm run jpm run accepts the following options: -b --binary binary use the version of firefox specified in binary. binary may be specified as a full path or as a path relative to the current directory. jpm run -b /path/to/firefox/nightly see selecting a browser version. --binary-args cmdargs pass extra
arguments to firefox. for example, to pass the -jsconsole argument to firefox and launch the browser console, try the following: jpm run --binary-args -jsconsole to pass multiple
arguments, or
arguments containing spaces, quote them: jpm run --binary-args '-url mzl.la -jsconsole' --debug run the add-on debugger attached to the add-on. -o --overload path ...
...tion for the assert module for more details on this. jpm test accepts the following options: -b --binary binary use the version of firefox specified in binary. binary may be specified as a full path or as a path relative to the current directory. jpm test -b /path/to/firefox/nightly see selecting a browser version. --binary-args cmdargs pass extra
arguments to firefox. for example, to pass the -jsconsole argument to firefox, which will launch the browser console, try the following: jpm test --binary-args -jsconsole to pass multiple
arguments, or
arguments containing spaces, quote them: jpm test --binary-args '-url mzl.la -jsconsole' --debug run the add-on debugger attached to the add-on. -f --filter file[...
Canvas code snippets - Archive of obsolete content
]; var props = ['canvas', 'fillstyle', 'font', 'globalalpha', 'globalcompositeoperation', 'linecap', 'linejoin', 'linewidth', 'miterlimit', 'shadowoffsetx', 'shadowoffsety', 'shadowblur', 'shadowcolor', 'strokestyle', 'textalign', 'textbaseline']; for (let m of methods) { let method = m; canvas2dcontext.prototype[method] = function() { this.ctx[method].apply(this.ctx,
arguments); return this; }; } for (let m of gettermethods) { let method = m; canvas2dcontext.prototype[method] = function() { return this.ctx[method].apply(this.ctx,
arguments); }; } for (let p of props) { let prop = p; canvas2dcontext.prototype[prop] = function(value) { if (value === undefined) return this.ctx[prop]; this.ctx[prop] = value;...
... saving a canvas image to a file the following function accepts a canvas object and a destination file path string. the canvas is converted to a png fi...
Chapter 6: Firefox extensions and XUL applications - Archive of obsolete content
od. open test_calc.js and update it with the method in listing 4. implement in calc.js next we need to add the executable code. this will work much as it did for addition. update calc.js with the method in listing 5. run test if we run the test at this point, we’ll get a red bar. what’s the matter? the screen will display “expected -1, got 1”. somehow, using pop() got the order of the
arguments mixed up. so let’s update the _letfunc function as shown in listing 6. if we run the test again, we should get a green bar, showing that it ran correctly. benefits of testing implementing the tests described here confirms that the methods work correctly, and builds confidence in your implementations. multiplication and division are implemented the same way, but what will you do if an invali...
...m i looking for? if you just start poking through the source code at random, you may not find much of anything. so let’s figure out where to start looking. let’s say we’ve found the contents of listing 7 in the source. we can guess from the name that this has something to do with handling files, but we’ve still got the following questions: what does nsilocalfile.initwithpath do? what
arguments does it take? how is nsilocalfile.initwithpath actually implemented? let’s examine these questions one at a time. what does this do? what
arguments does it take? first we’ll search for the component’s definition. type interface nsilocalfile (with a trailing space) in the search field and go. nearly all components inherit from nsisupports (fixme: why 'nearly' ?), so adding a trailing s...
Appendix E: DOM Building and Insertion (HTML & XUL) - Archive of obsolete content
ameparts[1]], shortname: reelemnameparts[2] }; } // note that 'elemnameorarray' is: either the full element name (eg. [html:]div) or an array of elements in json notation function tag(elemnameorarray, elemattr) { // array of elements? parse each one... ...
...(key.replace(/^on/, ""), val, false); } else { // note that the default namespace for xml attributes is, and should be, blank (ie. ...
JXON - Archive of obsolete content
} /* uncomment the following code if you want to enable the .appendjxon() method for *all* the "element" objects! ...
...loadobjtree(document, this, oobjtree); return this; }; */ this.build = function (oxmlparent, nverbosity /* optional */, bfreeze /* optional */, bnesteattributes /* optional */) { const nverbmask =
arguments.length > 1 && typeof nverbosity === "number" ? nverbosity & 3 : /* put here the default verbosity level: */ 1; return createobjtree(oxmlparent, nverbmask, bfreeze || false,
arguments.length > 3 ? bnesteattributes : nverbmask === 3); }; this.unbuild = function (oobjtree, snamespaceuri /* optional */, squalifiedname /* optional */, odocumenttype /* optional */) { const onewdoc = document.implementation.createdocument(snamespaceuri || null, squalifiedname || "", odocumenttype || null); loadobjtree(onewdoc, onewdoc, oobjtree); return onewdoc; }; const sv...
Dehydra Function Reference - Archive of obsolete content
ecording every included file into the _includedarray in the current namespace. include example include("map.js") // includes map.js into toplevel var map = {} include("map.js", map) // includes map.js into the map object require({version:, strict:, werror:, gczeal:}) require is used to set runtime execution flags. it also returns the current values of these flags. require supports optional named
arguments via javascript object where each parameter is a property. if a property is not specified then it will not be passed to the runtime. version integer: this sets js version similar to version() in js 1.7. strict boolean: controls js strict mode werror boolean: turns js warnings into errors gczeal int: this is a write-only parameter to set turn on frequent garbage collection. it is a mainly useful f...
...lude_path exposes the search path used by include(). the default value is the following directories: the directory of the dehydra script being processed the libs directory next to the gcc_dehydra.so plugin user script may add additional directories sys.aux_base_name exposes the base filename part of the file being compiled sys.frontend exposes the compiler frontend (e.g. "gnu c" or "gnu c++")
arguments this.
arguments is a javascript array containing command-line
arguments passed to a script. -fplugin-arg="foo.js a b c" would run foo.js with ["a", "b", "c"]
arguments array. this page was auto-generated because a user created a sub-page to this page. ...
Dehydra Object Reference - Archive of obsolete content
f this function or variable. .isstatic boolean flag .isreturn boolean flag the variable is being returned. .isdecl boolean flag the variable is being declared (local variables only). .assign array of variable objects this variable is the lhs of an assignment. the value is an array of values that were assigned. .isfcall boolean flag the variable is being used as a function call. .
arguments array of variable objects
arguments used to make a function call. .parameters array of variable objects a function definition's parameter names and types .memberof aggregate type object indicates the aggregate type(class/struct) in the type system that this variable is a member of. .fieldof variable object provides the object being dereferenced, in the ast system. applicable when access...
...tions and methods in the type system: property type description .type type object the function return type. .parameters array of type objects the parameter types for the function. .isexplicit boolean flag true for constructors declared using the c++ explicit keyword template objects property type description .name string the name of the template, for example "nscomptr". .
arguments array an array where
arguments are either strings representing c++ constants or type objects. location objects location objects are passed to builtin functions such as warning() and error() to specify the location of the message. they convert to a string of the form "file:line:column". they have the following properties: property type .file string .line integer .column integer (op...
Running Tamarin acceptance tests - Archive of obsolete content
with -h/--help) --nohtml : will suppress the creation of an html output file --rebuildtests : will only rebuild test .abc's, will not attempt to run them. ...
...on of an html output file --rebuildtests : will only rebuild test .abc's, will not attempt to run them. can also be using in conjunction with --threads -f --forcerebuild force rebuild all test files -q --quiet : will print a period (.) for each test run regardless of results, then print the test run summary when finished --ascargs= : additional
arguments to pass to asc.jar --vmargs= : additional
arguments to pass to avmshell --random : run tests in random order --timeout : max time for testrun --verify : run a verify pass instead of running abcs --verifyonly : run a -dverifyonly pass: only checks test exitcode (only works with debugger vms) testing the android shell the instructions above apply to running tests on an android device as well, but with a few differences. you should set environment ...
Running Tamarin performance tests - Archive of obsolete content
rebuild of test files --vmargs args to pass to vm --timeout max time to run all tests --testtimeout max time to let a test run, in sec (default -1 = never timeout) --html also create an html output file --notimecheck do not recompile .abc if timestamp is older than .as --java location of java executable (default=java) --javaargs
arguments to pass to java --random run tests in random order --seed explicitly specify random seed for --random -s --avm2 second avmplus command to use --avmname nickname for avm to use as column header --avm2name nickname for avm2 to use as column header --detail display results in 'old-style' format --raw output all raw test val...
... socket server -r --runtime name of the runtime vm used, including switch info eg. ttvmi (tamarin-tracing interp) -m --memory logs the high water memory mark --aotsdk location of the aot sdk used to compile tests to standalone executables. --aotout where the resulting binaries should be put (defaults to the location of the as file). --aotargs any extra
arguments to pass to compile.py. --vmversion specify vmversion e.g. 502, use this if cannot be calculated from executable --vm2version specify version of avm2 --vmargs2 args to pass to avm2, if not specified --vmargs will be used --nooptimize do not optimize files when compiling --perfm parse the perfm results from avm --csv= also output to csv file,...
Venkman Introduction - Archive of obsolete content
and length column are blank for file names. if a function has a breakpoint in it, a small red dot will show up in the function icon, as well as the parent's file icon. the local variables view the local variables view is on the left portion of the window, at the bottom. when the debugger is stopped, the local variables view displays values for the current function. the scope object holds all
arguments and local variables, and the this object holds the value of the this keyword. e enumerable property r read only property p permanent (cannot be deleted) a alias to another property a argument to a function v declared with var figure 8. property flags properties of both scope and this objects are listed alphabetica...
...rts the dhtml fishcam window. alternately, you can select animator-0.03.js from the loaded scripts view, locate the pause function at line 119, and click in the left margin. setting breakpoints in this manner is equivalent to using the /break command in the console. in either case, a red breakpoint icon appears in the source code view. type /break in the debugger. if you don't provide
arguments to the /break command, all breakpoints are listed in the interactive session view. on the fishcam page, press the "pause" link. you should hit the breakpoint you just set in step 3. in the interactive session, context becomes animator-0.03.js and the scope is the pause function. there will also be "stopped for breakpoint" in red in the interactive session, along with the file name, li...
Moving, Copying and Deleting Files - Archive of obsolete content
le-related error codes. there are several methods of the nsifile object which may be used to move and copy files on disk. nsifile.copyto() is used to copy a file, while nsifile.moveto() is used to move files. nsifile.remove() may be used to delete a file. copying a file nsifile.copyto() is used to copy files or directories, and should be called on the source file to copy. this method takes two
arguments, the first is the destination directory in which to copy the file to, and the second argument is the new name of the file, if you wish to rename it in its new location. if you do not want to rename the file, and use the same name as the source file, use a null string for the second argument. var file = io.newfile("home", "source.txt"); var destination = io.newfile("desktop", ""); file.copyto(des...
...hin a try-catch block in order to capture any errors that might occur. for a list of possible file related errors, see file errors. moving a file to move a file, nsifile.moveto() may be used which functions similarly to nsifile.copyto(). the following example moves a file 'myfile.txt' in the user's home directory into the temporary directory. as with nsifile.copyto(), nsifile.moveto() takes two
arguments, the destination directory and the new filename. if you do not want to rename the file and keep its existing name, use a null string for the second argument. var file = io.newfile("home", "myfile.txt"); var destination = io.newfile("temporary", ""); file.moveto(destination, ""); the second argument to nsifile.moveto() is an empty string to indicate that the same filename should be used. specif...
showPopup - Archive of obsolete content
p appears, either at a specific screen position, or relative to some element in the window. if either x or y are set to values, the popup will appear at the screen coordinate (x,y). if x and y are -1, the popup will be positioned relative to the element specified as the first argument. this is what you might do to show a popup below a button, for example. in this latter case, the anchor and align
arguments may be used to further control where the popup appears relative to the element. the anchor argument corresponds to the popupanchor attribute on the element. the align argument corresponds to the popupalign attribute on the element. the anchor and align
arguments are ignored if either x or y are not -1. to have a popup appear relative to another element yet still offset by some number of pixel...
... the popuptype should be one of the strings popup, context, or tooltip. ...
Positioning - Archive of obsolete content
enpopup overrides the attribute. however, if the attributesoverride argument to openpopup (the last argument, false in the example above) was true, the attribute would override the value supplied to openpopup. this allows the script and xul code to coordinate in different ways as to how the popup should be opened. positioning using coordinates a popup can be positioned further using the x and y
arguments to openpopup. after the popup is positioned using the anchor, the x and y
arguments may be used to offset the popup by a certain distance. the section on the openpopup method provides an example of this. if a menupopup, panel or tooltip has a margin specified in a style sheet or using the inline style attribute, this margin will be applied around the outside of the popup. in the following exampl...
...ay be used to open a popup via a script at a specific screen position. the section on the openpopupatscreen method provides more details. for all popups, the left and top attributes may be used to specify pixel coordinates of where the popup should appear on the screen. if these attributes are used, the popup will appear at the location the attributes specify. as with the position attribute, the
arguments to the openpopup method override unless the last argument is set to true. here is an example: <panel left="100" top="200"> <button label="test"/> </panel> the left and top attributes are most useful when using non-autohiding panels. with these, you can record the left and top positions as the popup is moved around, and use the persist attribute to maintain these attributes across sessions. ...
Creating an Installer - Archive of obsolete content
stall trigger. this involves the use of the special global object installtrigger. it contains a number of methods which can be used to start an installation. you can use this object in local or remote content, meaning that it is suitable for a download from a web site. let's create an example install trigger. this involves the use of the function installtrigger.install(). this function takes two
arguments, the first is a list of packages to install, and the second is a callback function which will be called when the installation is complete. here is an example: function donefn ( name , result ){ alert("the package " + name + " was installed with a result of " + result); } var xpi = new object(); xpi["calendar"] = "calendar.xpi"; installtrigger.install(xpi,donefn); first, we define a callback...
... an example: function donefn ( name , result ){ alert("the package " + name + " was installed with a result of " + result); } var xpi = new object(); xpi["calendar"] = "calendar.xpi"; installtrigger.install(xpi,donefn); first, we define a callback function donefn() which will be called when the install is complete. you can name the function whatever you like of course. this function has two
arguments. the first is the name of the package that was just installed. this is important if you are installing multiple components. the second argument is a result code. if the result is 0, the installation completed successfully. if the result is non-zero, an error occured and the value is an error code. the function donefn() here just displays an alert box to the user. next, we create an array xpi whi...
Open and Save Dialogs - Archive of obsolete content
ker component and initialize it. var nsifilepicker = components.interfaces.nsifilepicker; var fp = components.classes["@mozilla.org/filepicker;1"].createinstance(nsifilepicker); fp.init(window, "select a file", nsifilepicker.modeopen); first, a new file picker object is created and stored in the variable 'fp'. the 'init' function is used to initialize the file picker. this function takes three
arguments, the window that is opening the dialog, the title of the dialog and the mode. the mode here is modeopen which is used for an open dialog. you can also use modegetfolder and modesave for the other two modes. these modes are constants of the nsifilepicker interface. default directory and filters there are two features you can set of the dialog before it is displayed. the first is the default d...
... and the second is a semicolon-seperated list of file masks. you can add more masks or fewer masks as needed. you can call appendfilter as many times as necessary to add additional filters. the order you add them determines their priority. typically, the first one added is selected by default. getting the selected file finally, you can show the dialog by calling the show() function. it takes no
arguments but returns a status code that indicates what the user selected. note that the function does not return until the user has selected a file. the function returns one of three constants: returnok - the user selected a file and pressed ok. the file the user selected will be stored in the file picker's file property. returncancel - the user pressed cancel. returnreplace - in the save mode, this ...
prefwindow - Archive of obsolete content
button. centerwindowonscreen() return type: no return value centers the dialog on the screen. getbutton( type ) return type: button element returns the button element in the dialog corresponding to the given type. opensubdialog( url, features, params ) return type: window opens a child modal dialog. usually this method would be used to allow the user to configure advanced options. the
arguments are similar to the window's opendialog method except that the window name does not need to be supplied. the url should be a xul file. if the child dialog is also a prefwindow, set its type attribute to child so that preferences will be saved properly when the main dialog is closed. openwindow( windowtype, url, features, params ) return type: window open a child window. the windowtype is a str...
...dow() in case the window was already open. for example the permissions manager ui in firefox uses the same window for three dialogs: images, software installation and popups. it uses initwithparams() to change the dialog type without closing and re-opening it. the suggested usage pattern is as follows: // subwindow.js function onload(ev) { // do some initialization... initwithparams(window.
arguments[0]); // we expect a single parameter to be passed to the window } function initwithparams(aparams) { // this will also get called when an already open window is activated using openwindow() } closing a prefwindow sometimes you need to do things when the prefwindow is closed, such as things that can't (or shouldn't) be handled as preferences, such as saving passwords or updating sqlite data. ...
NPN_Invoke - Archive of obsolete content
npp npp, npobject *npobj, npidentifier methodname, const npvariant *args, uint32_t argcount, npvariant *result); parameters the function has the following parameters: npp the npp indicating which plugin wants to call the method on the object. npobj the object on which to invoke a method. methodname a string identifier indicating the name of the method to invoke. args an array of
arguments to pass to the method. argcount the number of
arguments in the args array. result a pointer to an npvariant to receive the result returned by the method. returns true if the method was successfully invoked, otherwise false. if the method was invoked successfully, any return value is stored in the npvariant specified by result. when the caller no longer needs the result, it must call npn_releasev...
...ents in the args array. result a pointer to an npvariant to receive the result returned by the method. returns true if the method was successfully invoked, otherwise false. if the method was invoked successfully, any return value is stored in the npvariant specified by result. when the caller no longer needs the result, it must call npn_releasevariantvalue() to release it. description the method
arguments are passed as an array of npvariants, and the number of
arguments is passed in. the result of the method invocation is returned through an npvariant result parameter. if the method invocation succeeds, npn_invoke() returns true, else false. note: early on in the development of the scriptability api this method used to be called npn_call() but was renamed for consistency. ...
NPN_InvokeDefault - Archive of obsolete content
ntax #include <npruntime.h> bool npn_invokedefault(npp npp, npobject *npobj, const npvariant *args, uint32_t argcount, npvariant *result); parameters the function has the following parameters: npp the npp indicating which plugin wants to call the default method on the object. npobj the object on which to invoke the default method. args an array of
arguments to pass to the default method. argcount the number of
arguments in the args array. result a pointer to an npvariant to receive the result returned by the default method. returns true if the default method was successfully invoked, otherwise false. if the default method was invoked successfully, any return value is stored in the npvariant specified by result. when the caller no lo...
...lt a pointer to an npvariant to receive the result returned by the default method. returns true if the default method was successfully invoked, otherwise false. if the default method was invoked successfully, any return value is stored in the npvariant specified by result. when the caller no longer needs the result, it must call npn_releasevariantvalue() to release it. description the method
arguments are passed as an array of npvariants, and the number of
arguments is passed in. the result of the method invocation is returned through an npvariant result parameter. if the method invocation succeeds, npn_invoke() returns true, else false. ...
NPP_New - Archive of obsolete content
instance contains instance-specific private data for the plug-in and the browser. this data is stored in instance->pdata. mode display mode of plug-in. values: np_embed: (1) instance was created by an embed tag and shares the browser window with other content. np_full: (2) instance was created by a separate file and is the primary content in the window. argc number of html
arguments in the embed tag for an embedded plug-in; determines the number of attributes in the argn and argv arrays. argn[] array of attribute names passed to the plug-in from the embed tag. argv[] array of attribute values passed to the plug-in from the embed tag. saved pointer to data saved by npp_destroy for a previous instance of this plug-in at the same url. if non-null, the browser pas...
...d the buffer it contains. returns if successful, the function returns nperr_no_error. if unsuccessful, the function returns an error code. for possible values, see error codes. description npp_new creates a new instance of a plug-in. it is called after np_initialize and is passed the mime type, embedded or full-screen display mode, and, for embedded plug-ins, information about html embed
arguments. a new instance pointer (npp instance) is created by the plug-in, which is valid until the instance is destroyed with npp_destroy. if instance data was saved from a previous instance of the plug-in by the npp_destroy function, it is returned in the saved parameter for the current instance to use. all attributes in the embed tag (standard and private) are passed in npp_new in the argn and argv ...
Object.prototype.__noSuchMethod__ - Archive of obsolete content
ct, but this function is no longer available. while __nosuchmethod__ has been dropped, the ecmascript 2015 specification has the proxy object, with which you can achieve the below (and more). syntax obj.__nosuchmethod__ = fun parameters fun a function that takes the form function (id, args) { . . . ...
... function (id, args) { . . . } id the name of the non-existent method that was called args an array of the
arguments passed to the method description by default, an attempt to call a method that doesn't exist on an object results in a typeerror being thrown. this behavior can be circumvented by defining a function at that object's __nosuchmethod__ member. the function takes two
arguments, the first is the name of the method attempted and the second is an array of the
arguments that were passed in the method call. the second argument is an actual array (that is, it inherits through the array.prototype chain) and not the array-like
arguments object. if this method cannot be called, either as if undefined by default, if deleted, or if manually set to a non-function, the javascript ...
2D maze game with device orientation - Game development
cript> </body> </html> so far we have a simple html website with some basic content in the <head> section: charset, title, css styling and the inclusion of the javascript files. the <body> contains initialization of the phaser framework and the definitions of the game states. var game = new phaser.game(320, 480, phaser.canvas, 'game'); the line above will initialize the phaser instance — the
arguments are the width of the canvas, height of the canvas, rendering method (we're using canvas, but there are also webgl and auto options available) and the optional id of the dom container we want to put the canvas in. if there's nothing specified in that last argument or the element is not found, the canvas will be added to the <body> tag. without the framework, to add the canvas element to the page, ...
... left absolute position on canvas in pixels. name of the image asset the button is using. function that will be executed when someone clicks the button. the execution context. frame from the image asset used as the button's "hover" state. frame from the image asset used as the button's "normal" or "out" state. frame from the image asset used as...
Graceful asynchronous programming with Promises - Learn web development
llectorder(order) ) .then(pizza => eatpizza(pizza) ) .catch(failurecallback); or even this: choosetoppings() .then(toppings => placeorder(toppings)) .then(order => collectorder(order)) .then(pizza => eatpizza(pizza)) .catch(failurecallback); this works because with arrow functions () => x is valid shorthand for () => { return x; }. you could even do this, since the functions just pass their
arguments directly, so there isn't any need for that extra layer of functions: choosetoppings().then(placeorder).then(collectorder).then(eatpizza).catch(failurecallback); this is not quite as easy to read, however, and this syntax might not be usable if your blocks are more complex than what we've shown here. note: you can make further improvements with async/await syntax, which we'll dig into in the n...
...inside the function we then return a new promise object — invoking the function will return the promise we want to use. inside the promise constructor, we do several checks inside if ... else structures: first of all, we check to see if the message is appropriate for being alerte...
A first splash into JavaScript - Learn web development
e constructs that listen out for the event happening are called event listeners, and the blocks of code that run in response to the event firing are called event handlers. add the following line below your checkguess() function: guesssubmit.addeventlistener('click', checkguess); here we are adding an event listener to the guesssubmit button. this is a method that takes two input values (called
arguments) — the type of event we are listening out for (in this case click) as a string, and the code we want to run when the event occurs (in this case the checkguess() function). note that we don't need to specify the parentheses when writing it inside addeventlistener(). try saving and refreshing your code now, and your example should work — to a point. the only problem now is that if you guess th...
...amming, which allow you to keep running a piece of code over and over again, until a certain condition is met. to start with, go to your browser developer tools javascript console again, and enter the following: for (let i = 1 ; i < 21 ; i++) { console.log(i) } what happened? the numbers 1 to 20 were printed out in your console. this is because of the loop. a for loop takes three input values (
arguments): a starting value: in this case we are starting a count at 1, but this could be any number you like. you could replace the letter i with any name you like too, but i is used as a convention because it's short and easy to remember. a condition: here we have specified i < 21 — the loop will keep going until i is no longer less than 21. when i reaches 21, the loop will no longer run. an incr...
Adding a new todo form: Vue events, methods, and models - Learn web development
ch calls the addtodo() method when the event fires. using the @ shorthand, the listener would look like this: @todo-added="addtodo": <to-do-form @todo-added="addtodo"></to-do-form> when you submit your todoform, you should see the console log from the addtodo() method. this is good, but we're still not passing any data back into the app.vue component. we can do that by passing additional
arguments to the this.$emit() function back in the todoform component. in this case, when we fire the event we want to pass the label data along with it. this is done by including the data you want to pass as another parameter in the $emit() method: this.$emit("todo-added", this.label). this is similar to how native javascript events include data, except custom vue events include no event object by def...
...pick up this data inside app.vue, we need to add a parameter to our addtodo() method that includes the label of the new to-do item. go back to app.vue and update this now: methods: { addtodo(todolabel) { console.log('to-do added:', todolabel); } } if you test your form again, you'll see whatever text you enter logged in your console upon submission. vue automatically passes the
arguments after the event name in this.$emit() to your event handler. adding the new todo into our data now that we have the data from todoform available in app.vue, we need to add an item representing it to the todoitems array. this can be done by pushing a new to-do item object to the array containing our new data. update your addtodo() method like so: addtodo(todolabel) { this.todoitems.pus...
Eclipse CDT
th=0" export cppflags="-fmessage-length=0" debugging to create a debug configuration, open the project properties window, and select "run/debug settings" on the left. click "new", then select "c/c++ application". in the window that opens enter the path to your firefox binary (something like {your-obj-dir}/dist/nightlydebug.app/contents/macos/firefox) and select "disable auto build". select the
arguments tab and enter any args you want to pass to firefox (such as "--no-remote -p my-testing-profile"). if you're on linux, you may also need to set the "working directory" to {your-obj-dir}/dist/bin, and then select the environment tab and set ld_library_path to ".:./plugins:." and library_path to ".:./components:.". (are these variables really necessary? if so, why? isn't library_path for compile tim...
... build option discovery? yes, but eclipse doesn't currently support it. instead of processing build console output, eclipse could use something like ld_preload to load its own little library into all the processes that are invoked as part of the build process. this library could then check whether the process is a compiler instance and, if so, use the processes' current working directory and the
arguments that were passed to it to reliably obtain the information it needs for each source file that is compiled. this would eliminate the requirement for non-parallelized, non-silenced builds. you could also build from eclipse and get the benefits that that brings. how can i run a more recent cdt version? this can be useful if you need to get certain bug fixes, or to help with testing to make sure tha...
Communicating with frame scripts
the api is mostly symmetrical, with one major exception: frame scripts can send asynchronous or synchronous messages to chrome, but chrome can only send asynchronous messages to content. this is an intentional design decision made to prevent content code from making chrome code unresponsive. where absolutely necessary, frame scripts can pass wrappers called cross process object wrappers (also known as cpows) to chrome, and chrome can use these wrappers to get synchronous access to content objects. ...
... removemessagelistener() to stop listening for messages from content, use the message manager's removemessagelistener() method: // chrome script messagemanager.removemessagelistener("my-addon@me.org:my-e10s-extension-message", listener); chrome to content to send a message from chrome to content...
AsyncShutdown.jsm
ase added to asyncshutdown, please file a bug. methods overview void addblocker(string name, function|promise condition, optional function info) boolean removeblocker(function|promise condition) methods addblocker () register a blocker for the completion of a phase. void addblocker( in string name, in function|promise|* condition, optional in function info )
arguments name the human-readable name of the blocker. used for debugging/error reporting. please make sure that the name respects the following model: "some service: some action in progress" - for instance "os.file: flushing all pending i/o". condition a condition blocking the completion of the phase. generally, this is a function returning a promise. this function is evaluated during the phase and ...
...n about the current state of the blocker as an object. used for providing more details when logging errors or crashing. removeblocker () remove the blocker for a condition. if several blockers have been registered for the same condition, remove all these blockers. if no blocker has been registered for this condition, this is a noop. boolean removeblocker( in function|promise|* condition )
arguments condition a condition blocking the completion of the phase. this must be the same condition as was passed to addblocker prior. return value returns true if a blocker has been removed, or false otherwise. note that a result of false may mean either that the blocker has never been installed or that the phase has completed and the blocker has already been resolved. examples asyncshutdown.pr...
JNI.jsm
hod overview cdata getforthread(); cdata loadclass(cdata ajenv, string aclassfullyqualifiedname, [optional] object adeclares); cdata newstring(cdata ajenv, string astr); string readstring(cdata ajenv, cdata ajavastring); void unloadclasses(); methods getforthread() blah blah cdata getforthread(); parameters this function does not take any
arguments. return value blah blah loadclass() blah blah cdata loadclass( ajenv, afullyqualifiedname, [optional] object adeclares ); parameters ajenv the return value of getforthread(). afullyqualifiedname a sig of a typed array or the name of the class that would be used in a signature, but without the surrounding l and ;. if it is the sig of a typed array such as '[i' then adeclares mu...
...etforthread(). astr a javascript string, use any encoding desired. return value blah blah readstring() blah blah string readstring( ajenv, ajavastring ); parameters ajenv the return value of getforthread(). ajavastring a cdata object that is a java string. return value a javascript string. unloadclasses() blah blah void unloadclasses(); parameters this function takes no
arguments. return value this function has no return value, if you try to store the return value in a variable, it will be undefined. working with arrays creating/preallocating a typed array methods cdata .get(number aindex); cdata .getelements(number astart, number alength); void .set(number aindex, cdata avalue); void .setelements(number astart, [array, size_is(...
NSPR Error Handling
tlength pr_geterrortext error codes error codes defined in prerror.h: pr_out_of_memory_error insufficient memory to perform request. pr_bad_descriptor_error the file descriptor used as an argument in the preceding function is invalid. pr_would_block_error the operation would have blocked, which conflicts with the semantics that have been established. pr_access_fault_error one of the
arguments of the preceding function specified an invalid memory address. pr_invalid_method_error the preceding function is invalid for the type of file descriptor used. pr_illegal_access_error one of the
arguments of the preceding function specified an invalid memory address. pr_unknown_error some unknown error has occurred. pr_pending_interrupt_error the operation terminated because another thread...
...untered some sort of an error, perhaps an invalid device. pr_io_timeout_error the i/o operation has not completed in the time specified for the preceding function. pr_io_pending_error an i/o operation has been attempted on a file descriptor that is currently busy with another operation. pr_directory_open_error the directory could not be opened. pr_invalid_argument_error one or more of the
arguments to the function is invalid. pr_address_not_available_error the network address (prnetaddr) is not available (probably in use). pr_address_not_supported_error the type of network address specified is not supported. pr_is_connected_error an attempt to connect on an already connected network file descriptor. pr_bad_address_error the network address specified is invalid (as reported by the ne...
NSS_3.12_release_notes.html
. bug 361077: clean up the use_pthreads related code in coreconf/hp-ux*.mk. bug 402114: fix the incorrect function prototypes of ssl handshake callbacks bug 402308: fix miscellaneous compiler warnings in nss/cmd bug 402777: lib/util can't be built stand-alone. bug 407866: contributed improvement to security/nss/lib/freebl/mpi/mp_comba.c bug 410587: ssl_getchannelinfo returns secsuccess on invalid
arguments bug 416508: fix a _msc_ver typo in sha512.c, and use sec_begin_protos/sec_end_protos in secport.h bug 419242: 'all' is not the default makefile target in lib/softoken and lib/softoken/legacydb bug 419523: export cert_newtempcertificate. bug 287061: crl number should be a big integer, not ulong bug 301213: combine internal libpkix function tests into a single statically linked program bug 324740: ...
...mozilla/security/lib/jar bug 118830: nss public header files should be c++ safe bug 123996: certutil -h doesn't document certutil -c -a bug 178894: quick decoder updates for lib/certdb and lib/certhigh bug 220115: ckm_invalid_mechanism should be an unsigned long constant. ...
NSS Sample Code Sample_1_Hashing
* it writes out the digest as a hexadecimal string. */ static int digestfile(prfiledesc *outfi...
... ploptstatus status; secstatus rv; char *hashname = null; char *progname = strrchr(argv[0], '/'); progname = progname ? ...
Hashing - sample 1
* it writes out the digest as a hexadecimal string. */ static int digestfile(prfiledesc *outfi...
... ploptstatus status; secstatus rv; char *hashname = null; char *progname = strrchr(argv[0], '/'); progname = progname ? ...
sample1
* it writes out the digest as a hexadecimal string. */ static int digestfile(prfile...
...state *optstate; ploptstatus status; secstatus rv; char *hashname = null; char *progname = strrchr(argv[0], '/'); progname = progname ? ...
NSS tools : cmsutil
name cmsutil — performs basic cryptograpic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. synopsis cmsutil [options]
arguments description the cmsutil command-line uses the s/mime toolkit to perform basic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. ...
...ons, such as encryption and decryption, on cryptographic message syntax (cms) messages. to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options. options and
arguments options options specify an action. option
arguments modify an action. the options and
arguments for the cmsutil command are defined as follows: -d decode a message. -c encrypt a message. -e envelope a message. -o create a certificates-only message. -s sign a message.
arguments option
arguments modify an action and are lowercase. -c content use this detached content (decode only). -d dbdir specify...
NSS Tools cmsutil
using cmsutil newsgroup: mozilla.dev.tech.crypto the cmsutil command-line utility uses the s/mime toolkit to perform basic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. syntax to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options. options and
arguments options specify an action. option
arguments modify an action. the options and
arguments for the cmsutil command are defined as follows: options -ddecode a message. -c encrypt a message. -e envelope a message. -o create...
... -d dbdir specify the key/certificate database directory (default is ".") -e envfile specify a file containing an enveloped message for a set of recipients to which you would like to send an encrypted message. ...
NSS tools : cmsutil
name cmsutil — performs basic cryptograpic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. synopsis cmsutil [options]
arguments description the cmsutil command-line uses the s/mime toolkit to perform basic operations, such as encryption and decryption, on cryptographic message syntax (cms) messages. to run cmsutil, type the command cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options. options and
arguments options options specify an action. option
arguments modify an action. the options...
... cmsutil option [
arguments] where option and
arguments are combinations of the options and
arguments listed in the following section. each command takes one option. each option may take zero or more
arguments. to see a usage string, issue the command without options. options and
arguments options options specify an action. option
arguments modify an action. the options and
arguments for the cmsutil command are defined as follows: -d decode a message. -c encrypt a message. -e envelope a message. -o create a certificates-only message. -s sign a message.
arguments option
arguments modify an action and are lowercase. -c content use this detached content (decode only). -d d...
NSS tools : pk12util
[sql:]directory] [-p dbprefix] [-k slotpasswordfile|-k slotpassword] [-w p12filepasswordfile|-w p12filepassword] ] description the pkcs #12 utility, pk12util, enables sharing certificates among any server that supports pkcs#12. the tool can import certificates and keys from pkcs#12 files into security databases, export certificates, and list certificates and keys. ...
... -d [sql:]directory specify the database directory into which to import to or export from certificates and keys. ...
Tutorial: Embedding Rhino
the examples live in the rhino/examples directory in the distribution and in mozilla/js/rhino/examples in cvs. this document will link to them using lxr. in this document, javascript code will be in green, java code will be in green, and shell logs will be in purple. ...
...xt. a context stores information about the execution environment of a script. initializing standard objects the code scriptable scope = cx.initstandardobjects(); initializes the standard objects (object, function, etc.) this must be done before scripts can be executed. the null parameter tells initstandardobjects to create and return a scope object that we use in later calls. collecting the
arguments this code is standard java and not specific to rhino. it just collects all the
arguments and concatenates them together. string s = ""; for (int i=0; i < args.length; i++) { s += args[i]; } evaluating a script the code object result = cx.evaluatestring(scope, s, "<cmd>", 1, null); uses the context cx to evaluate a string. evaluation of the script looks up variables in scope, and error...
Scripting Java
luated as well as being called. if we just view the method object by itself we can see the various overloaded forms of the method: js> f.listfiles function listfiles() {/* java.io.file[] listfiles() java.io.file[] listfiles(java.io.filenamefilter) java.io.file[] listfiles(java.io.filefilter) */} this output shows that the file class defines three overloaded methods listfiles: one that takes no
arguments, another with a filenamefilter argument, and a third with a filefilter argument. all the methods return an array of file objects. being able to view the parameters and return type of java methods is particularly useful in exploratory programming where we might be investigating a method and are unsure of the parameter or return types. another useful feature for exploratory programming is the abil...
...ames. a javabean property foo is defined by the methods getfoo and setfoo. additionally, a boolean property of the same name can be defined by an isfoo method. for example, the following code actually calls the file object's getname and isdirectory methods. js> f.name test.txt js> f.directory false calling overloaded methods the process of choosing a method to call based upon the types of the
arguments is called overload resolution. in java, overload resolution is performed at compile time, while in rhino it occurs at runtime. this difference is inevitable given javascript's use of dynamic typing as was discussed in chapter 2: since the type of a variable is not known until runtime, only then can overload resolution occur. as an example, consider the following java class that defines a number ...
How to embed the JavaScript engine
ller supplies fewer, the js engine should ensure that undefined is passed for the missing ones): #define doit_minargs 2 // [spidermonkey 24] use jsbool instead of bool. static bool doit(jscontext *cx, unsigned argc, jsval *vp) { js::callargs args = callargsfromvp(argc, vp); /* * look in argv for argc actual parameters, set *rval to return a * value to the caller. * * ex. add two
arguments as integer. * args.rval().setint32(args[0].toint32() + args[1].toint32()); */ return true; } then to wire it up to js, you could write: ok = js_definefunction(cx, global, "doit", doit, doit_minargs, 0); or, if you had a bunch of native functions to define, you would probably put them in a table: static jsfunctionspec my_functions[] = { js_fn("doit", doit, doit_minargs, 0), /* et...
...global, "doit", doit, doit_minargs, 0); or, if you had a bunch of native functions to define, you would probably put them in a table: static jsfunctionspec my_functions[] = { js_fn("doit", doit, doit_minargs, 0), /* etc... */ js_fs_end }; js_fs_end terminates the table. and say: ok = js_definefunctions(cx, global, my_functions); how to call javascript functions from c first, create
arguments for the call, here i create
arguments with 2 items: // [spidermonkey 24] js::autovaluearray is not defined. // js::autovaluevector argv(cx); // argv.resize(2); js::autovaluearray<2> argv(cx); argv[0].setint32(1); argv[1].setint32(2); then call the function: // [spidermonkey 24] pass
arguments length and the 'jsval *' pointer. // js_callfunctionname(cx, global, "func", 2, argv.begin(), rval.ad...
SpiderMonkey Internals
a switch statement (or faster alternative, depending on the compiler) to jump to the appropriate chunk of code for the current instruction. a js-to-js function call pushes a javascript stack frame without growing the c stack. but since js-to-c-to-js call stacks are common, the interpreter is reentrant. some spidermonkey bytecode operations have many special cases, depending on the type of their
arguments. common cases are inlined in the interpreter loop, breaking any abstractions that stand in the way. so optimizations such as dense arrays and the property cache are, alas, not transparently tucked away in the jsarray.* and jsobj.* files. both guest-star in jsinterp.cpp (to thunderous applause from firefox users). all state associated with an interpreter instance is passed through formal paramete...
...or no good reason save lack of time, the %e, %f, and %g formats cause your system's native sprintf, rather than js_dtoa(), to be used. this bug doesn't affect spidermonkey, because it uses its own js_dtoa() call in jsnum.cpp to convert from double to string, but it's a bug that we'll fix later, and one you should be aware of if you intend to use a js_*printf() function with your own floating type
arguments - various vendor sprintf's mishandle nan, +/-inf, and some even print normal floating values inaccurately. prmjtime.c, prmjtime.h time functions. these interfaces are named in a way that makes local vs. universal time confusion likely. caveat emptor, and we're working on it. to make matters worse, java (and therefore javascript) uses "local" time numbers (offsets from the epoch) in its date cla...
JS::CompileFunction
ile the function. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. scopechain js::autoobjectvector & the scope in which to compile the function. options js::readonlycompileoptions & compile options. name const char * name to assign the newly compiled function. nargs unsigned number of
arguments to pass to the function. argnames const char *const * names to assign to the
arguments passed to the function. chars const char16_t * string containing the body of the function to compile. bytes const char * string containing the body of the function to compile. length size_t the length, in characters, of body. srcbuf js::sou...
...y. srcbuf js::sourcebufferholder & source buffer containing the script function compile. fun js::mutablehandlefunction out parameter. on success, fun receives the result function. description js::compilefunction compiles a function from a text string chars, bytes, or srcbuf. name is the name to assign to the newly created function. nargs is the number of
arguments the function takes, and argnames is a pointer to the first element of an array of names to assign each argument. the number of argument names should match the number of
arguments specified in nargs. chars, bytes, or srcbuf is a string containing the source code of the function. length is the length of the source code in characters. on success, js::compilefunction stores an function object repre...
JSFastNative
(jscontext *cx, unsigned int argc, jsval *vp); name type description cx jscontext * the context in which the fast native is being called. provides request. in js_threadsafe builds, the javascript engine calls this callback only from within an active request on cx. the callback does not need to call js_beginrequest()). argc unsigned int the number of
arguments supplied to the function by the caller (as opposed to, say, the number of
arguments the function is specified to take in its jsfunctionspec). vp jsval * the
arguments, including the this argument, the return-value slot, and the callee function object are accessible through this pointer using macros described below. description the callback should use the following macros ...
...ot call js_this after calling js_set_rval. (js_this may call js_callee.) js_this_object(cx, vp) returns the this argument as a jsobject *, or null on error. native methods must not call js_this_object after calling js_set_rval. (js_this_object may call js_callee.) js_argv(cx, vp) returns the argv pointer. this points to element 0 of an array of argc jsvals, the
arguments supplied by the caller. js_rval(cx, vp) returns the jsval that is currently in the return-value slot. js_set_rval(cx, vp, value) sets the return value of the native function. it is safe to call this multiple times within a single call to a jsfastnative. if the jsfastnative returns js_true, the last value passed to this macro will be returned to the caller. on succes...
JSNative
(jscontext *cx, unsigned argc, js::value *vp); name type description cx jscontext * the context in which the native function is being called. provides request. in js_threadsafe builds, the javascript engine calls this callback only from within an active request on cx. the callback does not need to call js_beginrequest()). argc unsigned the number of
arguments supplied to the function by the caller (as opposed to, say, the number of
arguments the function is specified to take in its jsfunctionspec). vp js::value * the
arguments, the this argument, the return-value slot, and the callee function object are accessible through this pointer using macros described below. description jsnative is the type of native implementations of jav...
...use the js::callargs structure defined there; the macros providing equivalent functionality are deprecated. the behavior of a jsnative is implemented using a js::callargs structure added in spidermonkey 17. (this structure is now provided in "js/callargs.h" added in spidermonkey 24 as well as through "jsapi.h".) this structure encapsulates access to the callee function, this, the function call's
arguments, and the eventual return value. on success, the callback must set js::callargs::rval() or call js_set_rval (at least once) and return true. otherwise it should either report an error (using e.g. js_reporterror or js_reportoutofmemory) or raise an exception (using js_setpendingexception), and the callback must return false. (returning false without reporting an error or raising an exception termi...
JS_CallFunction
should be a native function or jsapi-compiled function. see below. name const char * pointer to the name of function to call. fval js::handlevalue pointer to the function value to call. args const js::handlevaluearray & reference to the array of argument values to pass to the function. added in spidermonkey 31 argc unsigned number of
arguments you are passing to the function. obsolete since jsapi 30 argv jsval * pointer to the array of argument values to pass to the function. obsolete since jsapi 30 rval js::mutablehandlevalue out parameter. on success, *rval receives the return value from the function call. description js_callfunction calls a specified function, fun, on an object, obj. in terms of...
...if js engine fails to get the function, it returns false. js_callfunctionvalue calls a specified function, fval on an object obj. js_callfunctionvalue(cx, obj, fval, args, rval) is analogous to the javascript statement rval = fval.apply(obj, args);. in args, pass a reference to the actual argument values to use. there should be one value for each argument you pass to the function; the number of
arguments you pass may be different from the number of
arguments defined for the function. obsolete since jsapi 30. in argc, indicate the number of
arguments passed to the function. in argv, pass a pointer to the actual argument values to use. rval is a pointer to a variable that will hold the function's return value, if any, on successful function execution. if the called function executes successfu...
JS_CompileFunction
name type description cx jscontext * the context in which to compile the function. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. obj jsobject * object with which the function is associated. name const char * name to assign the newly compiled function. nargs unsigned int number of
arguments to pass to the function. argnames const char ** names to assign to the
arguments passed to the function. body const char * or const jschar * string containing the body of the function to compile. length size_t the length, in characters, of body. filename const char * name of file or url containing the function. used to report filename or...
... lineno unsigned int line number. used to report the offending line in the file or url if an error occurs. description js_compilefunction compiles a function from a text string, bytes, and optionally associates it with a js object, obj. js_compileucfunction is the unicode version of the function. name is the name to assign to the newly created function. nargs is the number of
arguments the function takes, and argnames is a pointer to the first element of an array of names to assign each argument. the number of argument names should match the number of
arguments specified in nargs. body is a string containing the source code of the function. length is the length of the source code in characters. filename is the name of the file (or url) containing the function. this informatio...
JS_CompileFunctionForPrincipals
. in a js_threadsafe build, the caller must be in a request on this jscontext. obj jsobject * object with which the function is to be associated. principals jsprincipals * pointer to the structure holding the security information for this function. name const char * name to assign the newly compiled function. nargs unsigned int number of
arguments to pass to the function. argnames const char ** names to assign to the
arguments passed to the function. body const char * or const jschar * string containing the source code of the function to compile. length size_t the length, in characters, of body. filename const char * name of file or url containing the function. used to report file...
...rprincipals compiles a security-enabled function from a text string, bytes, and associates it with a js object, obj. js_compileucfunctionforprincipals is the unicode version of the function. principals is a pointer to the jsprincipals structure that contains the security information to associate with this function. name is the name to assign to the newly created function. nargs is the number of
arguments the function takes, and argnames is a pointer to the first element of an array of names to assign each argument. the number of argument names should match the number of
arguments specified in nargs. body is the string containing the source code of the function. length is the length of the string in characters. filename is the name of the file (or url) containing the function. this information i...
JS_DefineFunction
object for which to define a function as a property (method). name const char * or const char16_t * name to assign to the function. id js::handle<jsid> a pointer to jsid for name to assign to the function. added in spidermonkey 17 call jsnative the native c/c++ function to be wrapped by the new function. nargs unsigned number of
arguments that are passed to the function when it is called. flags unsigned the logical or of zero or more property attributes. description js_definefunction exposes a c/c++ function to scripts by defining a new method on an existing javascript object. it creates the new function object as though by calling js_newfunction, then makes it a method of obj as though by calling js_definepro...
...s_defineucfunction is the unicode version of the function. name is the name of the property to create in obj. that is, it is the method name that scripts can use to call the new function. it also becomes the name property of the new function object and can be accessed using js_getfunctionid. call is a pointer to the c/c++ function that is to be exposed to javascript. nargs indicates the number of
arguments the function expects to receive. this becomes the new function object's length property and can be accessed using js_getfunctionarity. flags is the logical or of zero or more property attributes, which apply to the new property. on success, js_definefunction and js_defineucfunction return a pointer to the new function. on error or exception, they return null. see also mxr id search for js_defin...
JS_GetProperty
f the property in *vp and returns true. however, several different hooks can affect property gets. the full algorithm is described below. details first, a property lookup is performed. if the lookup proceeds without error, exactly one of the following cases applies: if the property is not found, then *vp is set to undefined. then the jsclass.getproperty hook of obj's class is called with the
arguments (cx, obj, id, vp). for many objects, including objects of standard classes such as object and array, this hook does nothing and returns true, so the property get succeeds and undefined is left in *vp. if the property is found on a non-native object, get handler of proxy (only if the object is a proxy) or its jsobjectops.getproperty method is called. otherwise the property is found on a native o...
...und on a non-native object, get handler of proxy (only if the object is a proxy) or its jsobjectops.getproperty method is called. otherwise the property is found on a native object. if the property has a javascript getter, it is called. otherwise *vp is set to the property's stored value, or undefined if the property does not have a stored value, and then the property's getter is called with the
arguments (cx, obj, id, vp). for many properties, the getter does nothing and returns true, so the property get succeeds and the property's stored value is left in *vp. internally, property retrieval, including all the behavior described above, is implemented by obj's jsobjectops.getproperty callback. on success, these functions set *vp to the current value of the property, or undefined if obj has no su...
JS_InstanceOf
type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. obj js::handle<jsobject*> object to test. clasp jsclass * class against which to test the object. args js::callargs * optional pointer to
arguments. if non-null, report an error if obj is not of type clasp. added in spidermonkey 38 argv jsval * optional argument vector. if non-null, report an error if obj is not of type clasp. argv must be the argv argument passed from the engine to a jsnative callback, js_argv(cx, rv) in a jsfastnative callback, or null. obsolete since jsapi 32 description js_instanceof can be used to...
...s_instanceof can be used to check whether an object obj is of a particular jsclass. to use it this way, pass null for argv. js_instanceof returns true if obj is of the given class and false otherwise. that is, it returns js_getclass(obj) == clasp. js_instanceof can also be used in native functions to check the class of an argument when a particular class is required. to use it this way, pass the
arguments provided by the engine for args with js::callargsfromvp(argc, vp). when args is non-null, js_instanceof behaves as follows. if obj is of the given class, it returns true. otherwise, it returns false; it also reports a typeerror containing the function's name. note that js_instanceof is not the equivalent of the javascript instanceof keyword, which examines constructor properties along the protot...
JS_NewFunction
le<jsobject*> parent, js::handle<jsid> id); // added in spidermonkey 17 name type description cx jscontext * the context in which to create the new function. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. call jsnative native c/c++ implementation of this function. nargs unsigned number of
arguments the function expects. flags unsigned pass jsfun_constructor to make a native that can be called as a constructor, otherwise 0. parent js::handle<jsobject*> pointer to the parent object for this function. if this is null, a default parent object is used. obsolete since jsapi 39 name const char * name to assign to the new function. if this is null,...
... no name. id js::handle<jsid> a pointer to jsid of the name to assign to the new function. added in spidermonkey 17 description js_newfunction creates a new javascript function implemented in c/c++. (to create a new function implemented in javascript, use js_compilefunction instead.) call is a c/c++ function pointer that the new function wraps. nargs is the number of
arguments the function expects. if flags is jsfun_constructor, a created function can be called as a constructor. parent may be used to specify the new function's parent; null is usually the right thing here. name is the name to assign to the function. if name is null, the new function has no name. (js_getfunctionid, passed the new function, will return null.) on success, js_newfunction returns a pointer ...
JS_SetProperty
the cases above involves creating a new own property on obj. the name of the new property is given by name or id. the initial stored value of the new property is undefined. its getter and setter are the jsclass.getproperty and setproperty hooks of obj's class, and its property attributes are exactly jsprop_enumerate. after the new property is added, the jsclass.addproperty hook is called with the
arguments (cx, obj, id, &v). this hook may assign to v. if the hook succeeds and the property has a stored value, then the value left in v by the addproperty hook becomes the stored value of the property. setting the value. two of the cases above can involve setting the value of a new or existing property of obj. this is done as follows. if the property has a javascript setter, it is called; otherwise, i...
...e value left in v by the addproperty hook becomes the stored value of the property. setting the value. two of the cases above can involve setting the value of a new or existing property of obj. this is done as follows. if the property has a javascript setter, it is called; otherwise, if it has a javascript getter, then an error is reported; otherwise the property's setter is called, passing the
arguments (cx, obj, id, &v). if the setter succeeds and the property has a stored value, then the value left in v becomes the stored value of the property. on success, js_setproperty returns true, and the value in v is left unchanged unless a hook or setter modified it. on error or exception, it returns false, and the value left in v is unspecified. internally, property assignment, including all the beha...
SpiderMonkey 1.8.8
the engine is now implemented in c++. some c++ helpers have been introduced into the api, to help embedders writing c++ projects. please note that spidermonkey reserves the js:: namespace for itself. ...list new c++ helpers here... obsolete apis ...list obsolete methods/structs/apis here... deleted apis js_get_class (use js_getclass instead) js_constructobject and js_constructobjectwith
arguments (preferably use js_new instead, or use this reimplementation as a short-term fix) js_newcompartmentandglobalobject (use js_newglobalobject instead.) jspd_argument jsval_is_object() (use !jsval_is_primitive(v) to detect objects and jsval_is_null(v) to detect null). js_isscriptframe jsclass_new_resolve_gets_start flag js_newnumbervalue api changes break out and discuss all api changes here..
..._null(v) to detect null). js_isscriptframe jsclass_new_resolve_gets_start flag js_newnumbervalue api changes break out and discuss all api changes here... jsclass prototype has changed a number of optional members have been removed from the jsclass prototype. jsclass callback changes many of the jsclass callbacks such as jsresolveop, jsenumerateop and jspropertyop, have a type change on their
arguments to jshandleobject, jshandleid, jshandlemutableobject etc. atleast for the c api this wraps an extra pointer around these objects, so you would cast the argument to jsobject**, in the callback function. removal of jscontext* parameters to many methods the js_getclass method now takes only a jsobject*, where previously it also required a jscontext* in threadsafe builds. (the js_get_class macro abs...
SpiderMonkey 17
the engine is now implemented in c++. some c++ helpers have been introduced into the api, to help embedders writing c++ projects. please note that spidermonkey reserves the js:: namespace for itself. ...list new c++ helpers here... obsolete apis ...list obsolete methods/structs/apis here... deleted apis js_get_class (use js_getclass instead) js_constructobject and js_constructobjectwith
arguments (preferably use js_new instead, or use this reimplementation as a short-term fix) js_newcompartmentandglobalobject (use js_newglobalobject instead.) jspd_argument jsval_is_object() (use !jsval_is_primitive(v) to detect objects and jsval_is_null(v) to detect null). js_isscriptframe jsclass_new_resolve_gets_start flag js_newnumbervalue js_finalizestub js_clearnewbornroots jsclass_mark_is_t...
...bervalue js_finalizestub js_clearnewbornroots jsclass_mark_is_trace flag js_setscriptstackquota api changes break out and discuss all api changes here... jsclass prototype has changed a number of optional members have been removed from the jsclass prototype. jsclass callback changes many of the jsclass callbacks such as jsresolveop, jsenumerateop and jspropertyop, have a type change on their
arguments to jshandleobject, jshandleid, jshandlemutableobject etc. atleast for the c api this wraps an extra pointer around these objects, so you would cast the argument to jsobject**, in the callback function. removal of jscontext* parameters to many methods the js_getclass method now takes only a jsobject*, where previously it also required a jscontext* in threadsafe builds. (the js_get_class macro abs...
The Publicity Stream API
at [address]. this stream can be pulled down by getpublicitystream() and helps determine the results for getuserrecommendedapps(). example use cases: 'adam got a high score in mafia wars', 'bethany bought a plane ticket to the caribbean', etc. activity is an object, formatted as per the fixme: deadlinkactivity streams open specification. onsuccess is a callback that will be invoked with no
arguments if the activity is successfully posted. onerror is an error callback that will be invoked if the publicity fails. possible error codes include: denied - if the user refuses to publicize the activity permissiondenied - if the publicizing site is not allowed to post to the publicity stream networkerror - if the publicity server is unreachable activityparseerror - if the activity co...
...ondenied - if the publicizing site is not allowed to post to the publicity stream networkerror - if the publicity server is unreachable activityparseerror - if the activity contains syntax errors (not proper json) invalidactivity - if the activity contains semantic errors (i.e. missing required properties) finally, the publicizeactivity() function will throw an exception if required
arguments are missing, or if unsupported
arguments are present. getpublicitystream( onsuccess: <function>, { [ onerror: <function> ], [ for_apps: <list> ], [ since: <date> ], [ before: <date> ], [ count: <int> ]): provides a means for a web store to receive a list of the current user's socially relevant app activity by being called from an origin which hosts a web store. it is not recommended that ...
Creating the Component Code
nterfaces described in this chapter: nsimodule and nsifactory, which are entry points for your implementation code. once your component implements these interfaces, the rest of the registration process itself is simple. applications typically use regxpcom, described in the next section. the regxpcom program an explicit way to register a component is to run the application regxpcom. without any
arguments passed to regxpcom, the program registers the component in the default component registry. we suggest that when you are testing your component in the mozilla or netscape client, you copy your component into the components directory in the client's installation folder. when it is copied there, run regxpcom from the command line to register that component and all the others in that directory. seve...
...xpcom - the class and the interface ids - are examples of uuids, or universal unique identifiers, which were discussed in object interface discovery. generating cids to generate a cid for your component, you can use the uuidgen tool that comes with most unix distributions and with microsoft visual c++. uuidgen is a command-line tool that returns a unique 128-bit number when you call it with no
arguments: $ uuidgen ce32e3ff-36f8-425f-94be-d85b26e634ee on windows, a program called guidgen.exe does the same thing and also provides a graphical user interface if you'd rather point and click. or you can use one of the special "bots" on irc in #developers, where you can also get help from human beings. irc irc.mozilla.org /join #developers /msg firebot uuid this command makes the bot generate and...
nsICommandLineHandler
1.0 66 introduced gecko 1.8 inherits from: nsisupports last changed in gecko 1.8 (firefox 1.5 / thunderbird 1.5 / seamonkey 1.0) each command line handler is registered in the category "command-line-handler". the entries in this category are read in alphabetical order, and each category value is treated as a service contract id implementing this interface. by convention, handlers with ordinary priority should begin with "m". ...
...plication is launched with the -help argument, this attribute is retrieved and displayed to the user (on stdout). the text should have embedded newlines which wrap at 76 columns, and should include a newline at the end. by convention, the right column which contains flag descriptions begins at the 24th character. read only. methods handle() processes a command line. if this handler finds
arguments that it understands, it should perform the appropriate actions (such as opening a window), and remove the
arguments from the command-line array. void handle( in nsicommandline acommandline ); parameters acommandline command line to process. see also nsicommandline chrome: command line xulrunner:commandline ...
nsIDialogCreator
embedding/base/nsidialogcreator.idlscriptable please add a summary to this article. ...
...opendialog(in unsigned long atype, in acstring aname, in acstring afeatures, in nsidialogparamblock a
arguments, [optional] in nsidomelement aframeelement); constants constant value description unknown_dialog 0 generic_dialog 1 select_dialog 2 methods opendialog() void opendialog( in unsigned long atype, in acstring aname, in acstring afeatures, in nsidialogparamblock a
arguments, in nsidomelement aframeelement optional ); parameters atype aname afeatures a
arguments aframeelement optional ...
nsIStringBundleService
nsible bundle corresponding to the properties file(s). flushbundles() flushes the string bundle cache - useful when the locale changes or when we need to get some extra memory back. (automatically called for the memory-pressure and chrome-flush-caches global observer topics.) void flushbundles(); parameters none. formatstatusmessage() formats a message string from a status code and status
arguments. ...
... return value the formatted message. see also code snippets : miscellaneous : using string bundles from javascript how to localize html pages, xul files, and js/jsm files from bootstrapped add-ons. ...
nsIWebBrowser
r notifications in which case the the iid is that of the interface. void addwebbrowserlistener( in nsiweakreference alistener, in nsiidref aiid ); parameters alistener the listener to be added. aiid the iid of the interface that will be called on the listener as appropriate. return value ns_ok listener was successfully added. ns_error_invalid_arg one of the
arguments was invalid or the object did not implement the interface specified by the iid. removewebbrowserlistener() removes a previously registered listener. void removewebbrowserlistener( in nsiweakreference alistener, in nsiidref aiid ); parameters alistener the listener to be removed. aiid the iid of the interface on the listener that will no longer be called. return value ...
...emovewebbrowserlistener() removes a previously registered listener. void removewebbrowserlistener( in nsiweakreference alistener, in nsiidref aiid ); parameters alistener the listener to be removed. aiid the iid of the interface on the listener that will no longer be called. return value ns_ok listener was successfully added. ns_error_invalid_arg one of the
arguments was invalid or the object did not implement the interface specified by the iid. see also nsibasewindow nsicontextmenulistener nsidomwindow nsiembeddingsitewindow nsiinterfacerequestor nsishistorylistener nsitooltiplistener nsiuricontentlistener nsiweakreference nsiwebbrowserchrome nsiwebbrowserchromefocus nsiwebprogresslistener ...
nsIWebBrowserPersist
cheme. aoutputcontenttype the desired mime type format to save the document and all sub-documents into or nsnull to use the default behavior. aencodingflags flags to pass to the encoder. awrapcolumn for text documents, indicates the desired width to wrap text at. parameter is ignored if wrapping is not specified by the encoding flags. exceptions thrown ns_error_invalid_arg one or more
arguments was invalid. saveuri() as of firefox 26, this method should no longer be used from add-on code. please use downloads.createdownload() instead. as of firefox 36, a new parameter areferrerpolicy was added as the fourth argument, changing the number of parameters from 7 to 8 and shifting the order of the parameters in a backwards incompatible way. save the specified uri to file. void saveuri...
...t that no such relevant context exists (ie. the uri being saved is unrelated to any current browsing session). important: if you think that you should be passing null here, you are almost certainly wrong. null should be passed only when no plausible privacy context exists for the uri to be saved, which is an exceedingly rare corner case. exceptions thrown ns_error_invalid_arg one or more
arguments was invalid. saveprivacyawareuri() save the specified uri to file, explicitly dictating whether the operation should be considered private for the purposes of network requests, caching, etc. all
arguments and exceptions are identical to saveuri, with the exception of aisprivate which is used to indicate the private nature of the operation. example function downloadfile(httploc, sourcewindow)...
XPIDL
eters are properties which help native code implementations determine how the call was made from script. if implicit_jscontext is present on a method, then an additional jscontext *cx parameter is added just after the regular list which receives the context of the caller. if optional_argc is present, then an additional uint8_t _argc method is added at the end which receives the number of optional
arguments that were actually used (obviously, you need to have an optional argument in the first place). note that if both properties are set, the jscontext *cx is added first, followed by the uint8_t _argc, and then ending with return value parameter. finally, as an exception to everything already mentioned, for attribute getters and setters the jscontext *cx comes before any other
arguments. another nat...
...lugins that expect the interfaces to be stored in a specific way in memory. in other words, some changes made to idl interfaces require the author to modify the unique identifier (iid) in order to make it clear to plugins that utilize these interfaces that they have changed, and thus their plugin must be recompiled. common changes to an interface, such as changes to a method signature, number of
arguments, and number or type of attributes, automatically require an iid change. in addition, some changes to interface attributes require that an iid be changed, as well. when a change to an interface made by an xpidl developer requires that third-party binary addons be recompiled, we say that it affects binary compatibility. when a change to an interface made by an xpidl developer requires that third-pa...
Creating a gloda message query
bject that is contributed to your namespace. you can find the file, which includes doxygen markup of sorts, here: https://hg.mozilla.org/comm-central/file/tip/mailnews/db/gloda/modules/gloda.js components.utils.import("resource:///modules/gloda/public.js"); create the query let query = gloda.newquery(gloda.noun_message); add constraints to the query each constraint function takes one or more
arguments which are "or"ed together. so if we had a "color" constraint such as query.color("red", "green", "blue") would mean any of red, green, or blue is okay. constraints are "and"ed together. so if we had a "shape" constraint such as query.shape("square") and we combined it with the previous color constraint it would match a red square, a green square, or a blue square. query.involves(identity1, i...
...onstraint that the message must be (or not be) starred (flagged). query.read(true/false): add the constraint that the message must be (or not be) marked as read. query.bodymatches(searchstring): perform a full-text search against plaintext message bodies. query.attachmenttypes(mimetype1, mimetype2, ...): constrain to messages with attachments among the given mime types. in theory, providing no
arguments should result in finding messages with any attachment, but this is somewhat untested. more constraints can be found in the three js files given further below. from https://developer.mozilla.org/docs/mozilla/thunderbird/thunderbird_extensions/demo_addon, demo3, it seems that the attributename given in these files is the constraintname to be used (e.g. query.subjectmatches(searchstring) for messag...
Using Objective-C from js-ctypes
e, the selector, and variable argument list for the message, returning the returned value from the method. id objc_msgsend(id self, sel op, ...); id is defined as the following, in /usr/include/objc/objc.h, it's also an opaque type. class can be cast into id, so we can pass class returned by objc_getclass. typedef struct objc_object *id; in this example, we send an alloc message without any
arguments using the following code. this code returns an allocated nsspeechsynthesizer instance that has not yet been initialized. id tmp = objc_msgsend((id)nsspeechsynthesizer, alloc); here, class is always cast into id, which is an opaque type. we could choose to use id instead, reducing casting and making our code more efficient in future. id nsspeechsynthesizer = (id)objc_getclass("nsspeechsynthesi...
...that has not yet been initialized. id tmp = objc_msgsend((id)nsspeechsynthesizer, alloc); here, class is always cast into id, which is an opaque type. we could choose to use id instead, reducing casting and making our code more efficient in future. id nsspeechsynthesizer = (id)objc_getclass("nsspeechsynthesizer"); id tmp = objc_msgsend(nsspeechsynthesizer, alloc); selector for a method with
arguments in this case, [nsspeechsynthesizer initwithvoice:] takes one argument; the selector name with a trailing colon. sel initwithvoice = sel_registername("initwithvoice:"); if a method takes two or more
arguments, the selector name becomes a concatenation of each name. // [nsstring getbytes:maxlength:usedlength:encoding:options:range:remainingrange:] sel foo = sel_registername("getbytes:maxlength...
Standard OS Libraries
own dll (for windows) or so (for linux) file with c functions that can be called from your add-on with js-ctypes. the dll/so/etc file you make must be shipped with your add-on. standard libraries offer the advantage of not having to ship anything. they are already available on the operating system for you. you just need to supply the path to appropriate files and set up the proper types of values/
arguments in the js-ctypes code. this article allows you to find out what types to give to values/
arguments by supplying links to the documentation of the os libraries. windows windows has many standard os libraries. the most common, found on all windows os version, is "winapi". windows also has the "winapilists" and ".net framework" (i'm not sure if it can be accessed jsctypes but probably). a complete ...
...ete list of windows apis can be found at the msdn api index. winapi this is the one that is most commonly used by js-ctypes. this comes shipped by default with all installations of windows operating systems since win98. it's also known as winapi32 or just winapi. a list of all the functions available through this api can be found at the msdn winapi index. for finding out the values and types of
arguments and returns of the functions you want to use from this api, you must visit the functions page on this linked msdn site; it will give you all that information. example: getcursorpos i wanted to get the mouse cursor position without using a mousemove listener, as this is a high overhead event listener. so i went to the msdn winapi index page and then went to the "cursors" category and came across...
js-ctypes reference
i. types and data to use js-ctypes effectively, it is important to understand the different kinds of objects that the module provides. there are three major categories: types these represent a type in c, and are thus represented by ctype objects. these objects have two main purposes. first, they provide a concrete representation of different data types, allowing the programmer to describe the
arguments and return type of a native function (see library.declare()). second, they serve as constructors to create concrete instances of the given type, i.e. cdata objects. out of the box, js-ctypes supports a number of predefined types. type constructors these are functions that define new types, and thus return a ctype object. these include ctypes.pointertype(type) and the .ptr property, which c...
...2 ...]), which creates a new type describing a c function. data these are instances of types, represented by cdata objects and instantiated by calling ctype objects as functions. these distinctions are crucial, and understanding them will alleviate much of the confusion surrounding js-ctypes. calling a type constructor will return a ctype. calling a ctype will return a cdata. you declare the
arguments and return value of a native function with ctype objects. you call a native function with cdata objects. other features error-handling js-ctypes supports both errno (on all platforms) and getlasterror (on windows platforms). callbacks you can pass regular javascript functions as callbacks to native functions. see the callbacks page for details. 64-bit integer handling because javascript nu...
Debugger.Frame - Firefox Developer Tools
represent the evaluation of debuggee code, like calls non-debuggee functions, host functions or "debugger" frames. callee the function whose application created this frame, as a debuggee value, or null if this is not a "call" frame. generator true if this frame is a generator frame, false otherwise. constructing true if this frame is for a function called as a constructor, false otherwise.
arguments the
arguments passed to the current frame, or null if this is not a "call" frame. when non-null, this is an object, allocated in the same global as the debugger, with array.prototype on its prototype chain, a non-writable length property, and properties whose names are array indices. each property is a read-only accessor property whose getter returns the current value of the corresponding parame...
...hread calls: the call takes place in the thread to which the frame belongs, and runs in the compartment to which the handler method belongs. debugger.frame instances inherit the following handler method properties: onstep this property must be either undefined or a function. if it is a function, spidermonkey calls it when execution in this frame makes a small amount of progress, passing no
arguments and providing this debugger.frame instance as the thisvalue. the function should return a resumption value specifying how the debuggee’s execution should proceed. what constitutes “a small amount of progress” varies depending on the implementation, but it is fine-grained enough to implement useful “step” and “next” behavior. if multiple debugger instances each have debugger.fram...
Debugger.Object - Firefox Developer Tools
e, or { asconstructor: true } to invoke the referent as a constructor, in which case spidermonkey provides an appropriate this value itself. eachargument must be a debuggee value. all extant handler methods, breakpoints, watchpoints, and so on remain active during the call. if the referent is not callable, throw a typeerror. this function follows the invocation function conventions. ...
...ides an appropriate this value itself. eachargument must be a debuggee value. all extant handler methods, breakpoints, watchpoints, and so on remain active during the call. if the referent is not callable, throw a typeerror. this function follows the invocation function conventions. apply(this,
arguments) if the referent is callable, call it with the giventhis value and the argument values in
arguments, and return a completion value describing how the call completed.this should be a debuggee value, or { asconstructor: true } to invokefunction as a constructor, in which case spidermonkey provides an appropriate this value itself.
arguments must either be an array (in the debugger) of debuggee values, or null or undefined, which are treated as an empty array. all extant handler methods, breakpoint...
Web Console remoting - Firefox Developer Tools
n dom/base/consoleapi.js. for each console message we receive in the server, we send the following consoleapicall packet to the client: { "from": "conn0.console9", "type": "consoleapicall", "message": { "level": "error", "filename": "http://localhost/~mihai/mozilla/test.html", "linenumber": 149, "functionname": "", "timestamp": 1347302713771, "private": false, "
arguments": [ "error omg aloha ", { "type": "object", "classname": "htmlbodyelement", "actor": "conn0.consoleobj20" }, " 960 739 3.141592653589793 %a", "zuzu", { "type": "null" }, { "type": "undefined" } ] } } similar to how we send the page errors, here we send the actual console event received from the nsiobserverservice. we change...
... "error omg aloha ", { "type": "object", "classname": "htmlbodyelement", "actor": "conn0.consoleobj20" }, " 960 739 3.141592653589793 %a", "zuzu", { "type": "null" }, { "type": "undefined" } ] } } similar to how we send the page errors, here we send the actual console event received from the nsiobserverservice. we change the
arguments array - we create objectactor instances for each object passed as an argument - and, lastly, we remove some unneeded properties (like window ids). in the case of long strings we use the longstringactor. the web console can then inspect the
arguments. the private flag tells if the console api call comes from a private window/tab (added in firefox 24). we have small variations for the object, dep...
Beacon API - Web APIs
ot only do these techniques represent poor coding patterns, some of them are unreliable and result in the perception of poor page load performance for the next navigation. the beacon api provides a standard way to address these issues. global context the beacon api's navigator.sendbeacon() method is used to send a beacon of data to the server in the global browsing context. the method takes two
arguments, the url and the data to send in the request. the data argument is optional and its type may be an arraybufferview, blob, domstring, or formdata. if the browser successfully queues the request for delivery, the method returns "true" and returns "false" otherwise. worker context the beacon api's navigator.sendbeacon() method is used to send a beacon of data to the server from the worker global s...
...end in the request. the data argument is optional and its type may be an arraybufferview, blob, domstring, or formdata. if the browser successfully queues the request for delivery, the method returns "true" and returns "false" otherwise. worker context the beacon api's navigator.sendbeacon() method is used to send a beacon of data to the server from the worker global scope. the method takes two
arguments, the url and the data to send in the request. the data argument is optional and its type may be an arraybufferview, blob, domstring, or formdata. if the browser successfully queues the request for delivery, the method returns "true" and otherwise returns "false". ...
BlobEvent.BlobEvent() - Web APIs
data is a blob associated with the event. timecode optional a domhighrestimestamp to be used in initializing the blob event. ...
... data is a blob associated with the event. timecode optional a domhighrestimestamp to be used in initializing the blob event. ...
Transformations - Web APIs
tx.scale(-1, 1); ctx.font = '48px serif'; ctx.filltext('mdn', -135, 120); } <canvas id="canvas" width="150" height="150"></canvas> draw(); screenshotlive sample transforms finally, the following transformation methods allow modifications directly to the transformation matrix. transform(a, b, c, d, e, f) multiplies the current transformation matrix with the matrix described by its
arguments. the transformation matrix is described by: [acebdf001]\left[ \begin{array}{ccc} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{array} \right] if any of the
arguments are infinity the transformation matrix must be marked as infinite instead of the method throwing an exception. the parameters of this function are: a (m11) horizontal scaling. b (m12) horizontal skewing. c (m21) vertical ske...
...ite instead of the method throwing an exception. the parameters of this function are: a (m11) horizontal scaling. b (m12) horizontal skewing. c (m21) vertical skewing. d (m22) vertical scaling. e (dx) horizontal moving. f (dy) vertical moving. settransform(a, b, c, d, e, f) resets the current transform to the identity matrix, and then invokes the transform() method with the same
arguments. this basically undoes the current transformation, then sets the specified transform, all in one step. resettransform() resets the current transform to the identity matrix. this is the same as calling: ctx.settransform(1, 0, 0, 1, 0, 0); example for transform and settransform function draw() { var ctx = document.getelementbyid('canvas').getcontext('2d'); var sin = math.sin(math.pi / 6);...
performance.clearMarks() - Web APIs
if this argument is omitted, all performance entries with an entry type of "mark" will be removed. return value void example the following example shows both uses of the clearmarks() method. ...
...if this argument is omitted, all performance entries with an entry type of "mark" will be removed. return value void example the following example shows both uses of the clearmarks() method. ...
performance.clearMeasures() - Web APIs
if this argument is omitted, all performance entries with an entry type of "measure" will be removed. return value void example the following example shows both uses of the clearmeasures() method. ...
...if this argument is omitted, all performance entries with an entry type of "measure" will be removed. return value void example the following example shows both uses of the clearmeasures() method. ...
ProgressEvent() - Web APIs
type is a domstring representing the name of the type of the progressevent. it is case-sensitive. ...
... type is a domstring representing the name of the type of the progressevent. it is case-sensitive. ...
User Timing API - Web APIs
entries). performance.getentriesbytype(entrytype) returns all performance entries in the performance timeline with the specified entrytype, thus set entrytype to "mark" to get all marks. removing performance marks to remove a specific mark from the performance timeline, call performance.clearmarks(name) where name is the name of the mark(s) you want removed. if this method is called with no
arguments, all mark type entries will be removed from the performance timeline. performance measures measure events are also named by the application but they are placed between two marks thus they are effectively a midpoint between two marks. creating a performance measure a measure is created by calling performance.measure(measurename, startmarkname, endmarkname) where measurename is the measure's na...
...mance.getentriesbytype(entrytype) returns all performance entries in the performance timeline with the specified entrytype, thus set entrytype to "measure" to get all measures. removing performance measures to remove a specific measure from the performance timeline, call performance.clearmeasures(name) where name is the name of the measure(s) you want removed. if this method is called with no
arguments, all measure type entries will be removed from the performance timeline. interoperability as shown in the performance interface's browser compatibility table, the user timing methods are broadly implemented by desktop and mobile browsers (the only exceptions are desktop safari and mobile safari, however the safari technology preview 24 has support). to test your browser's support for this api...
Web Authentication API - Web APIs
hentication request is valid and approved. options publickeycredentialcreationoptions the options passed to credentialscontainer.create(). publickeycredentialrequestoptions the options passed to credentialscontainer.get(). examples for security reasons, web authentication calls (create() and get()) are cancelled if the browser window loses focus while the call is pending. // sample
arguments for registration var createcredentialdefaultargs = { publickey: { // relying party (a.k.a. - service): rp: { name: "acme" }, // user: user: { id: new uint8array(16), name: "john.p.smith@example.com", displayname: "john p. smith" }, pubkeycredparams: [{ type: "public-key", ...
...testation: "direct", timeout: 60000, challenge: new uint8array([ // must be a cryptographically random number sent from a server 0x8c, 0x0a, 0x26, 0xff, 0x22, 0x91, 0xc1, 0xe9, 0xb9, 0x4e, 0x2e, 0x17, 0x1a, 0x98, 0x6a, 0x73, 0x71, 0x9d, 0x43, 0x48, 0xd5, 0xa7, 0x6a, 0x15, 0x7e, 0x38, 0x94, 0x52, 0x77, 0x97, 0x0f, 0xef ]).buffer } }; // sample
arguments for login var getcredentialdefaultargs = { publickey: { timeout: 60000, // allowcredentials: [newcredential] // see below challenge: new uint8array([ // must be a cryptographically random number sent from a server 0x79, 0x50, 0x68, 0x71, 0xda, 0xee, 0xee, 0xb9, 0x94, 0xc3, 0xc2, 0x15, 0x67, 0x65, 0x26, 0x22, 0xe3, 0xf3, 0xab, 0x3b, 0x78, 0x2e, 0...
Using the Web Storage API - Web APIs
ext, we set the values displayed in the form elements to those values, so that they keep in sync when you reload the page. finally, we update the styles/decorative image on the page, so your customization options come up again on reload. setting values in storage storage.setitem() is used both to create new data items, and (if the data item already exists) update existing values. this takes two
arguments — the key of the data item to create/modify, and the value to store in it. function populatestorage() { localstorage.setitem('bgcolor', document.getelementbyid('bgcolor').value); localstorage.setitem('font', document.getelementbyid('font').value); localstorage.setitem('image', document.getelementbyid('image').value); setstyles(); } the populatestorage() function sets three items in l...
...ve stringified so you can see its content). deleting data records web storage also provides a couple of simple methods to remove data. we don't use these in our demo, but they are very simple to add to your project: storage.removeitem() takes a single argument — the key of the data item you want to remove — and removes it from the storage object for that domain. storage.clear() takes no
arguments, and simply empties the entire storage object for that domain. specifications specification status comment html living standard living standard ...
Window.showModalDialog() - Web APIs
this feature has been removed. please fix your web sites and applications. this method was removed in chrome 43 and firefox 56. the window.showmodaldialog() created and displayed a modal dialog box containing a specified html document. syntax returnval = window.showmodaldialog(uri[,
arguments][, options]); returnval holds the returnvalue property as set by the document specified by uri. uri is the url of the document to display in the dialog.
arguments is an optional variant containing values passed to the dialog; these are made available in the window object's window.dialog
arguments property. options is an optional string specifying window ornamentation for the dialog, using one or more semicolon delimited values: syntax description center: {on | off ...
...f | yes | no | 1 | 0 } if this argument's value is on, yes, or 1, the dialog window can be resized by the user; otherwise its size is fixed. the default value is no. scroll: {on | off | yes | no | 1 | 0 } if on, yes, or 1, the dialog window has scroll bars; otherwise its size is fixed. default is no. note: firefox does not implement the dialoghide, edge, status, or unadorned
arguments. examples try out showmodaldialog(). notes showmodaldialog() was briefly standardized as part of html5. the third argument for additional options was not present in the html5 version. specification msdn page for showmodaldialog browser compatibility the compatibility table in this page is generated from structured data. if you'd like to contribute to the data, please check out https://...
Basic Shapes - CSS: Cascading Style Sheets
apes, it is worth understanding two pieces of information that go together to make these shapes possible: the <basic-shape> type the reference box the <basic-shape> type the <basic-shape> type is used as the value for all of our basic shapes. this type uses functional notation: the type of shape is followed by brackets, inside of which are additional values used to describe the shape. the
arguments which are accepted vary depending on the shape that you are creating. we will cover these in the examples below. the reference box understanding the reference box used by css shapes is important when using basic shapes, as it defines each shape's coordinate system. you have already met the reference box in the guide on creating shapes from box values, which directly uses the reference box to cr...
...nge the offset values to see how the shape changes. you can also add the box value that you wish to use as a reference box. in the example below change the reference box from margin-box to border-box, padding-box or content-box to see how the reference box used as the starting point before offsets are calculated changes. circle() the circle() value for shape-outside can accept two possible
arguments. the first is the shape-radius. both circle() and ellipse() values for shape-outside are specified as accepting this argument of <shape-radius>. this argument can be a length or percentage but can also be one of the keywords closest-side or farthest-side. the keyword closest-side uses the length from the center of the shape to the closest side of the reference box. for circles, this is the clos...
CSS values and units - CSS: Cascading Style Sheets
cification. functional notation calc() min() max() clamp() toggle() attr() functional notation is a type of value that can represent more complex types or invoke special processing by css. the syntax starts with the name of the function immediately followed by a left parenthesis ( followed by the argument(s) to the notation followed by a right parenthesis ). ...
... specifications specification status comment css values and units module level 4 editor's draft adds the vi, vb, ic, cap, lh and rlh units. ...
paint() - CSS: Cascading Style Sheets
the paint() css function defines an <image> value generated with a paintworklet. syntax paint(workletname, parameters) where: workletname the name of the registered worklet. parameters optional additional parameters to pass to the paintworklet examples you can pass additional
arguments via the css paint() function. ...
... the paint() css function defines an <image> value generated with a paintworklet. syntax paint(workletname, parameters) where: workletname the name of the registered worklet. parameters optional additional parameters to pass to the paintworklet examples you can pass additional
arguments via the css paint() function. ...
Concurrency model and the event loop - JavaScript
wing sections explain a theoretical model. modern javascript engines implement and heavily optimize the described semantics. visual representation stack function calls form a stack of frames. function foo(b) { let a = 10 return a + b + 11 } function bar(x) { let y = 3 return foo(x * y) } console.log(bar(7)) //returns 42 when calling bar, a first frame is created containing bar's
arguments and local variables. when bar calls foo, a second frame is created and pushed on top of the first one containing foo's
arguments and local variables. when foo returns, the top frame element is popped out of the stack (leaving only bar's call frame). when bar returns, the stack is empty. heap objects are allocated in a heap which is just a name to denote a large (mostly unstructured) region of m...
...message processing short and if possible cut down one message into several messages. adding messages in web browsers, messages are added anytime an event occurs and there is an event listener attached to it. if there is no listener, the event is lost. so a click on an element with a click event handler will add a message—likewise with any other event. the function settimeout is called with 2
arguments: a message to add to the queue, and a time value (optional; defaults to 0). the time value represents the (minimum) delay after which the message will actually be pushed into the queue. if there is no other message in the queue, and the stack is empty, the message is processed right after the delay. however, if there are messages, the settimeout message will have to wait for other messages to be ...
Using Promises - JavaScript
you might see this expressed with arrow functions instead: dosomething() .then(result => dosomethingelse(result)) .then(newresult => dothirdthing(newresult)) .then(finalresult => { console.log(`got the final result: ${finalresult}`); }) .catch(failurecallback); important: always return results, otherwi...
...unctions down to a promise chain equivalent to: promise.resolve().then(func1).then(func2).then(func3); this can be made into a reusable compose function, which is common in functional programming: const applyasync = (acc,val) => acc.then(val); const composeasync = (...funcs) => x => funcs.reduce(applyasync, promise.resolve(x)); the composeasync() function will accept any number of functions as
arguments, and will return a new function that accepts an initial value to be passed through the composition pipeline: const transformdata = composeasync(func1, func2, func3); const result3 = transformdata(data); in ecmascript 2017, sequential composition can be done more simply with async/await: let result; for (const f of [func1, func2, func3]) { result = await f(result); } /* use last result (i.e.
Working with objects - JavaScript
lue that is stored in a variable: var propertyname = 'make'; mycar[propertyname] = 'ford'; propertyname = 'model'; mycar[propertyname] = 'mustang'; you can use the bracket notation with for...in to iterate over all the enumerable properties of an object. ...
...then if you want to find out the name of the owner of car2, you can access the following property: car2.owner.name note that you can always add a property to a previously defined object. for example, the statement car1.color = 'black'; adds a property color to car1, and assigns it a value of "black." however, this does not affect any other objects. to add the new property to...
constructor - JavaScript
the constructor method is a special method of a class for creating and initializing an object of that class. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax constructor([
arguments]) { ... } description a constructor enables you to provide any custom initialization that must be done before any other methods can be called on an instantiated object. class person { constructor(name) { this.name = name; } introduce() { console.log(`hello, my name is ${this.name}`); } } const otto = new person('otto'); otto.introduce(); if you don't provide your own constructor, then a default constructor will ...
...{ console.log(`hello, my name is ${this.name}`); } } const otto = new person('otto'); otto.introduce(); if you don't provide your own constructor, then a default constructor will be supplied for you. ...
Deprecated and obsolete features - JavaScript
empting a match in a string. lastindex the index at which to start the next match. multiline whether or not to search in strings across multiple lines. source the text of the pattern. regexp methods the compile() method is deprecated. the valueof method is no longer specialized for regexp. use object.valueof(). function properties the caller and
arguments properties are deprecated, because they leak the function caller. instead of the
arguments property, you should use the
arguments object inside function closures. legacy generator legacy generator function statement and legacy generator function expression are deprecated. use function* statement and function* expression instead. js1.7/js1.8 array comprehension and js1.7/js1.8 generator comp...
...eval() evaluates a string of javascript code in the context of the specified object. object.observe() asynchronously observing the changes to an object. object.unobserve() remove observers. object.getnotifier() creates an object that allows to synthetically trigger a change. function property description arity number of formal
arguments. array property description array.observe() asynchronously observing changes to arrays. array.unobserve() remove observers. number number.tointeger() parallelarray parallelarray statements for each...in is deprecated. use for...of instead. destructuring for...in is deprecated. use for...of instead. let blocks and let expressions ar...
Default parameters - JavaScript
me, greeting, message] } greet('david', 'hi') // ["david", "hi", "hi david"] greet('david', 'hi', 'happy birthday!') // ["david", "hi", "happy birthday!"] this functionality can be approximated like this, which demonstrates how many edge cases are handled: function go() { return ':p' } function withdefaults(a, b = 5, c = b, d = go(), e = this, f =
arguments, g = this.value) { return [a, b, c, d, e, f, g] } function withoutdefaults(a, b, c, d, e, f, g) { switch (
arguments.length) { case 0: a; case 1: b = 5; case 2: c = b; case 3: d = go(); case 4: e = this; case 5: f =
arguments; case 6: g = this.value; default: } return [a, b, c, d, e, f, g]; } withdefaults.call({val...
...ion withoutdefaults(a, b, c, d, e, f, g) { switch (
arguments.length) { case 0: a; case 1: b = 5; case 2: c = b; case 3: d = go(); case 4: e = this; case 5: f =
arguments; case 6: g = this.value; default: } return [a, b, c, d, e, f, g]; } withdefaults.call({value: '=^_^='}); // [undefined, 5, 5, ":p", {value:"=^_^="},
arguments, "=^_^="] withoutdefaults.call({value: '=^_^='}); // [undefined, 5, 5, ":p", {value:"=^_^="},
arguments, "=^_^="] scope effects if default parameters are defined for one or more parameter, then a second scope (environment record) is created, specifically for the identifiers within the parameter list. this scope is a parent of the scope created for the function body. this means that functions...
Array.prototype.concat() - JavaScript
led. see the description below for more details. return value a new array instance. description the concat method creates a new array consisting of the elements in the object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array). it does not recurse into nested array
arguments. the concat method does not alter this or any of the arrays provided as
arguments but instead returns a shallow copy that contains copies of the same elements combined from the original arrays. elements of the original arrays are copied into the new array as follows: object references (and not the actual object): concat copies object references into the new array. both the original and new ar...
...d from the original arrays. elements of the original arrays are copied into the new array as follows: object references (and not the actual object): concat copies object references into the new array. both the original and new array refer to the same object. that is, if a referenced object is modified, the changes are visible to both the new and original arrays. this includes elements of array
arguments that are also arrays. data types such as strings, numbers and booleans (not string, number, and boolean objects): concat copies the values of strings and numbers into the new array. note: concatenating array(s)/value(s) will leave the originals untouched. furthermore, any operation on the new array (except operations on elements which are object references) will have no effect on the original...
Array.prototype.filter() - JavaScript
pository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax let newarray = arr.filter(callback(element[, index, [array]])[, thisarg]) parameters callback function is a predicate, to test each element of the array. return true to keep the element, false otherwise. it accepts three
arguments: element the current element being processed in the array. indexoptional the index of the current element being processed in the array. arrayoptional the array filter was called upon. thisargoptional value to use as this when executing callback. return value a new array with the elements that pass the test. if no elements pass the test, an empty array will be returned. de...
...ew array of all the values for which callback returns a value that coerces to true. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. array elements which do not pass the callback test are simply skipped, and are not included in the new array. callback is invoked with three
arguments: the value of the element the index of the element the array object being traversed if a thisarg parameter is provided to filter, it will be used as the callback's this value. otherwise, the value undefined will be used as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. filter() does n...
Array.prototype.find() - JavaScript
xists in an array, use array.prototype.includes(). again, it checks each element for equality with the value instead of using a testing function. if you need to find if any element satisfies the provided testing function, use array.prototype.some(). syntax arr.find(callback(element[, index[, array]])[, thisarg]) parameters callback function to execute on each value in the array, taking 3
arguments: element the current element in the array. index optional the index (position) of the current element in the array. array optional the array that find was called on. thisarg optional object to use as this inside callback. return value the value of the first element in the array that satisfies the provided testing function. otherwise, undefined is returned. description the...
... var o = object(this); // 2. let len be ? tolength(? get(o, "length")). var len = o.length >>> 0; // 3. if iscallable(predicate) is false, throw a typeerror exception. if (typeof predicate !== 'function') { throw typeerror('predicate must be a function'); } // 4. if thisarg was supplied, let t be thisarg; else let t be undefined. var thisarg =
arguments[1]; // 5. let k be 0. var k = 0; // 6. repeat, while k < len while (k < len) { // a. let pk be ! tostring(k). // b. let kvalue be ? get(o, pk). // c. let testresult be toboolean(? call(predicate, t, « kvalue, k, o »)). // d. if testresult is true, return kvalue. var kvalue = o[k]; if (predicate.call(thisarg, kvalue, k, o)...
Array.prototype.forEach() - JavaScript
. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax arr.foreach(callback(currentvalue [, index [, array]])[, thisarg]) parameters callback function to execute on each element. it accepts between one and three
arguments: currentvalue the current element being processed in the array. index optional the index currentvalue in the array. array optional the array foreach() was called upon. thisarg optional value to use as this when executing callback. return value undefined. description foreach() calls a provided callback function once for each element in an array in ascending order. it is ...
...e array foreach() was called upon. thisarg optional value to use as this when executing callback. return value undefined. description foreach() calls a provided callback function once for each element in an array in ascending order. it is not invoked for index properties that have been deleted or are uninitialized. (for sparse arrays, see example below.) callback is invoked with three
arguments: the value of the element the index of the element the array object being traversed if a thisarg parameter is provided to foreach(), it will be used as callback's this value. the thisarg value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. the range of elements processed by foreach() is set before the first invocat...
Array.prototype.lastIndexOf() - JavaScript
math.min(n, len - 1) : len - math.abs(n); k >= 0; k--) { if (k in t && t[k] === searchelement) { return k; } } return -1; }; } aga...
...math.min(n, len - 1) : len - math.abs(n); k >= 0; k--) { if (k in t && t[k] === searchelement) { return k; } } return -1; }; } again, note that this implementation aims fo...
Array.of() - JavaScript
array.of(7); // [7] array.of(1, 2, 3); // [1, 2, 3] array(7); // array of 7 empty slots array(1, 2, 3); // [1, 2, 3] syntax array.of(element0[, element1[, ...[, elementn]]]) parameters elementn elements used to create the array. ...
... array. return value a new array instance. description this function is part of the ecmascript 2015 standard. for more information, see: array.of() array.from() proposal array.of() polyfill polyfill running the following code before any other code will create array.of() if it's not natively available. if (!array.of) { array.of = function() { return array.prototype.slice.call(
arguments); // or let vals = []; for(let prop in
arguments){ vals.push(
arguments[prop]); } return vals; } } examples using array.of array.of(1); // [1] array.of(1, 2, 3); // [1, 2, 3] array.of(undefined); // [undefined] specifications specification ecmascript (ecma-262)the definition of 'array.of' in that specification. ...
Array.prototype.slice() - JavaScript
'cherry condition', 'purchased 1997'] newcar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2] mycar[0].color = red newcar[0].color = red the new color of my honda is purple mycar[0].color = purple newcar[0].color = purple array-like objects slice method can also be called to convert array-like objects/collections to a new array. you just bind the method to the object. the
arguments inside a function is an example of an 'array-like object'. function list() { return array.prototype.slice.call(
arguments) } let list1 = list(1, 2, 3) // [1, 2, 3] binding can be done with the call() method of function.prototype and it can also be reduced using [].slice.call(
arguments) instead of array.prototype.slice.call. anyway, it can be simplified using bind. let unboundslice = array.
...lice.call(
arguments) } let list1 = list(1, 2, 3) // [1, 2, 3] binding can be done with the call() method of function.prototype and it can also be reduced using [].slice.call(
arguments) instead of array.prototype.slice.call. anyway, it can be simplified using bind. let unboundslice = array.prototype.slice let slice = function.prototype.call.bind(unboundslice) function list() { return slice(
arguments) } let list1 = list(1, 2, 3) // [1, 2, 3] specifications specification ecmascript (ecma-262)the definition of 'array.prototype.slice' in that specification. ...
Array.prototype.some() - JavaScript
it returns a boolean value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax arr.some(callback(element[, index[, array]])[, thisarg]) parameters callback a function to test for each element, taking three
arguments: element the current element being processed in the array. indexoptional the index of the current element being processed in the array. arrayoptional the array some() was called upon. thisargoptional a value to use as this when executing callback. return value true if the callback function returns a truthy value for at least one element in the array. otherwise, false. des...
...s the one where callback returns a truthy value (a value that becomes true when converted to a boolean). if such an element is found, some() immediately returns true. otherwise, some() returns false. callback is invoked only for indexes of the array with assigned values. it is not invoked for indexes which have been deleted or which have never been assigned values. callback is invoked with three
arguments: the value of the element, the index of the element, and the array object being traversed. if a thisarg parameter is provided to some(), it will be used as the callback's this value. otherwise, the value undefined will be used as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function. some() does no...
Error.prototype.stack - JavaScript
the stack string proceeds from the most recent calls to earlier ones, leading back to the original global scope call. description each step will be separated by a newline, with the first part of the line being the function name (if not a call from the global scope), then by an at (@) sign, the file location (except when the function is the error constructor as the error is being thrown), a colon, and, if there is a file location, the line number. ...
...refox 14, the function name would be followed by the argument values converted to string in parentheses immediately before the at (@) sign. while an object (or array, etc.) would appear in the converted form "[object object]", and as such could not be evaluated back into the actual objects, scalar values could be retrieved (though it may be — it is still possible in firefox 14 — easier to use
arguments.callee.caller.
arguments, as could the function name be retrieved by
arguments.callee.caller.name). "undefined" is listed as "(void 0)". note that if string
arguments were passed in with values such as "@", "(", ")" (or if in file names), you could not easily rely on these for breaking the line into its component parts. thus, in firefox 14 and later this is less of an issue. different browsers se...
Function() constructor - JavaScript
ctionbody a string containing the javascript statements comprising the function definition. description function objects created with the function constructor are parsed when the function is created. this is less efficient than declaring a function with a function expression or function statement and calling it within your code because such functions are parsed with the rest of the code. all
arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed. omitting an argument will result in the value of that parameter being undefined. invoking the function constructor as a function (without using the new operator) has the same effect as invoking it as a constructor. examples specifying argume...
...nction to be created, in the order in which they are passed. omitting an argument will result in the value of that parameter being undefined. invoking the function constructor as a function (without using the new operator) has the same effect as invoking it as a constructor. examples specifying
arguments with the function constructor the following code creates a function object that takes two
arguments. // example can be run directly in your javascript console // create a function that takes two
arguments, and returns the sum of those
arguments const adder = new function('a', 'b', 'return a + b'); // call the function adder(2, 6); // 8 the
arguments "a" and "b" are formal argument names that are used in the function body, "return a + b". specifications specification ...
Intl.DateTimeFormat - JavaScript
totype.formatrangetoparts() this method receives two dates and returns an array of objects containing the locale-specific tokens representing each part of the formatted date range. examples using datetimeformat in basic use without specifying a locale, datetimeformat uses the default locale and default options. var date = new date(date.utc(2012, 11, 20, 3, 0, 0)); // tolocalestring without
arguments depends on the implementation, // the default locale, and the default time zone console.log(new intl.datetimeformat().format(date)); // → "12/19/2012" if run with en-us locale (language) and time zone america/los_angeles (utc-0800) using locales this example shows some of the variations in localized date and time formats. in order to get the format of the language used in the user interface ...
...le, use 'default' console.log(new intl.datetimeformat('default', options).format(date)); // → "12/19/2012, 19:00:00" // sometimes it's helpful to include the period of the day options = {hour: "numeric", dayperiod: "short"}; console.log(new intl.datetimeformat('en-us', options).format(date)); // → 10 at night the used calendar and numbering formats can also be set independently via options
arguments: var options = {calendar: 'chinese', numberingsystem: 'arab'}; var dateformat = new intl.datetimeformat('default', options); var usedoptions = dateformat.resolvedoptions(); console.log(usedoptions.calendar); // → "chinese" console.log(usedoptions.numberingsystem); // → "arab" console.log(usedoptions.timezone); // → "america/new_york" (the users default timezone) specifications ...
Map.prototype.forEach() - JavaScript
rtion order. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax mymap.foreach(callback([value][,key][,map])[, thisarg]) parameters callback function to execute for each entry of mymap. it takes the following
arguments: value optional value of each iteration. key optional key of each iteration. map optional the map being iterated (mymap in the above syntax box). thisarg optional value to use as this when executing callback. return value undefined. description the foreach method executes the provided callback once for each key of the map which actually exist. it is not invoked for keys ...
...he above syntax box). thisarg optional value to use as this when executing callback. return value undefined. description the foreach method executes the provided callback once for each key of the map which actually exist. it is not invoked for keys which have been deleted. however, it is executed for values which are present but have the value undefined. callback is invoked with three
arguments: the entry's value the entry's key the map object being traversed if a thisarg parameter is provided to foreach, it will be passed to callback when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a functi...
Math.max() - JavaScript
rameters. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax math.max([value1[, value2[, ...]]]) parameters value1, value2, ... numbers. return value the largest of the given numbers. ...
...return value the largest of the given numbers. if at least one of the
arguments cannot be converted to a number, nan is returned. description because math is not a constructor, max() is a static method of math (you always use it as math.max(), rather than as a method of an instanced math object). -infinity is the initial comparant because almost every other value is bigger, that's why when no
arguments are given, -infinity is returned. if at least one of
arguments cannot be converted to a number, the result is nan. examples using math.max() math.max(10, 20); // 20 math.max(-10, -20); // -10 math.max(-10, 20); // 20 getting the maximum element of an array array.reduce() can be used to find the maximum element in a numeric array, by comparing each value: var arr = [1,2,3]; var max = ...
Math - JavaScript
) returns the absolute value of x. math.acos(x) returns the arccosine of x. math.acosh(x) returns the hyperbolic arccosine of x. math.asin(x) returns the arcsine of x. math.asinh(x) returns the hyperbolic arcsine of a number. math.atan(x) returns the arctangent of x. math.atanh(x) returns the hyperbolic arctangent of x. math.atan2(y, x) returns the arctangent of the quotient of its
arguments. math.cbrt(x) returns the cube root of x. math.ceil(x) returns the smallest integer greater than or equal to x. math.clz32(x) returns the number of leading zeroes of the 32-bit integer x. math.cos(x) returns the cosine of x. math.cosh(x) returns the hyperbolic cosine of x. math.exp(x) returns ex, where x is the argument, and e is euler's constant (2.718…, the base of the natural log...
...p(x) returns ex, where x is the argument, and e is euler's constant (2.718…, the base of the natural logarithm). math.expm1(x) returns subtracting 1 from exp(x). math.floor(x) returns the largest integer less than or equal to x. math.fround(x) returns the nearest single precision float representation of x. math.hypot([x[, y[, …]]]) returns the square root of the sum of squares of its
arguments. math.imul(x, y) returns the result of the 32-bit integer multiplication of x and y. math.log(x) returns the natural logarithm (㏒e; also, ㏑) of x. math.log1p(x) returns the natural logarithm (㏒e; also ㏑) of 1 + x for the number x. math.log10(x) returns the base-10 logarithm of x. math.log2(x) returns the base-2 logarithm of x. math.max([x[, y[, …]]]) returns the largest of z...
Object - JavaScript
new boolean(false) let o = new object(boolean()) object prototypes when altering the behavior of existing object.prototype methods, consider injecting code by wrapping your extension before or after the existing logic. for example, this (untested) code will pre-conditionally execute custom logic before the built-in logic or someone else's extension is executed. when a function is called, the
arguments to the call are held in the array-like "variable"
arguments. for example, in the call myfn(a, b, c), the
arguments within myfn's body will contain 3 array-like elements corresponding to (a, b, c). when modifying prototypes with hooks, pass this and the
arguments (the call state) to the current behavior by calling apply() on the function. this pattern can be used for any prototype, such as node.p...
... object.prototype: object.prototype.valueof = function() { if (this.hasownproperty('-prop-value')) { return this['-prop-value']; } else { // it doesn't look like one of my objects, so let's fall back on // the default behavior by reproducing the current behavior as best we can. // the apply behaves like "super" in some other languages. // even though valueof() doesn't take
arguments, some other hook may. return current.apply(this,
arguments); } } since javascript doesn't exactly have sub-class objects, prototype is a useful workaround to make a “base class” object of certain functions that act as objects. for example: var person = function(name) { this.name = name; this.cantalk = true; }; person.prototype.greet = function() { if (this.cantalk) { conso...
Promise.prototype.then() - JavaScript
if the promise that then is called on adopts a state (fulfillment or rejection) for which then has no handler, the returned promise simply adopts the final state of the original promise on which then was called. ...
...if the promise that then is called on adopts a state (fulfillment or rejection) for which then has no handler, the returned promise simply adopts the final state of the original promise on which then was called. ...
handler.apply() - JavaScript
the handler.apply() method is a trap for a function call. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax const p = new proxy(target, { apply: function(target, thisarg,
argumentslist) { } }); parameters the following parameters are passed to the apply() method. this is bound to the handler. target the target object. thisarg the this argument for the call.
argumentslist the list of
arguments for the call. return value the apply() method can return any value. description the handler.apply() method is a trap for a function call. interceptions this trap can intercept these operations: proxy(.
...rgs) function.prototype.apply() and function.prototype.call() reflect.apply() invariants if the following invariants are violated, the proxy will throw a typeerror. the target must be a callable itself. that is, it must be a function object. examples trapping a function call the following code traps a function call. const p = new proxy(function() {}, { apply: function(target, thisarg,
argumentslist) { console.log('called: ' +
argumentslist.join(', ')); return
argumentslist[0] +
argumentslist[1] +
argumentslist[2]; } }); console.log(p(1, 2, 3)); // "called: 1, 2, 3" // 6 specifications specification ecmascript (ecma-262)the definition of '[[call]]' in that specification. ...
Proxy() constructor - JavaScript
et, handler) parameters target a target object to wrap with proxy. it can be any sort of object, including a native array, a function, or even another proxy. handler an object whose properties are functions that define the behavior of the proxy when an operation is performed on it. description use the proxy() constructor to create a new proxy object. this constructor takes two mandatory
arguments: target is the object for which you want to create the proxy handler is the object that defines the custom behavior of the proxy. an empty handler will create a proxy that behaves, in almost all respects, exactly like the target. by defining any of a set group of functions on the handler object, you can customise specific aspects of the proxy's behavior. for example, by defining get() you c...
...arget has two properties, notproxied and proxied. we define a handler that returns a different value for proxied, and lets any other accesses through to the target. const target = { notproxied: "original value", proxied: "original value" }; const handler = { get: function(target, prop, receiver) { if (prop === "proxied") { return "replaced value"; } return reflect.get(...
arguments); } }; const proxy = new proxy(target, handler); console.log(proxy.notproxied); // "original value" console.log(proxy.proxied); // "replaced value" specifications specification ecmascript (ecma-262)the definition of 'proxy constructor' in that specification. ...
Reflect.apply() - JavaScript
the static reflect.apply() method calls a target function with
arguments as specified. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax reflect.apply(target, thisargument,
argumentslist) parameters target the target function to call. thisargument the value of this provided for the call to target.
argumentslist an array-like object specifying the
arguments with which target should be called. return value the result of calling the given target function with the specified this value and
arguments. exceptions a typeerror, if the target is not callable. description in es5, you typically use the functio...
... function.prototype.apply.call(math.floor, undefined, [1.75]); with reflect.apply() this becomes less verbose and easier to understand. ...
RegExp.prototype[@@replace]() - JavaScript
[symbol.replace](str, newsubstr|function) parameters str a string that is a target of the replacement. newsubstr (replacement) the string that replaces the substring. a number of special replacement patterns are supported; see the specifying a string as a parameter section in string.prototype.replace() page. function (replacement) a function to be invoked to create the new substring. the
arguments supplied to this function are described in the specifying a function as a parameter section in string.prototype.replace() page. return value a new string with some or all matches of a pattern replaced by a replacement. description this method is called internally in string.prototype.replace() if the pattern argument is a regexp object. for example, following two examples return same result.
....replace(/a/, 'a'); /a/[symbol.replace]('abc', 'a'); this method exists for customizing replace behavior in regexp subclass. if pattern argument is not a regexp object, string.prototype.replace() doesn't call this method, nor creates a regexp object. examples direct call this method can be used in almost the same way as string.prototype.replace(), except the different this and the different
arguments order. var re = /-/g; var str = '2016-01-01'; var newstr = re[symbol.replace](str, '.'); console.log(newstr); // 2016.01.01 using @@replace in subclasses subclasses of regexp can override the [@@replace]() method to modify the default behavior. class myregexp extends regexp { constructor(pattern, flags, count) { super(pattern, flags); this.count = count; } [symbol.replace](str...
Set.prototype.forEach() - JavaScript
or each value in the set object, in insertion order. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax myset.foreach(callback[, thisarg]) parameters callback function to execute for each element, taking three
arguments: currentvalue, currentkey the current element being processed in the set. as there are no keys in set, the value is passed for both
arguments. set the set object which foreach() was called upon. thisarg value to use as this when executing callback. return value undefined. description the foreach() method executes the provided callback once for each value which actually exis...
...was called upon. thisarg value to use as this when executing callback. return value undefined. description the foreach() method executes the provided callback once for each value which actually exists in the set object. it is not invoked for values which have been deleted. however, it is executed for values which are present but have the value undefined. callback is invoked with three
arguments: the element value the element key the set object being traversed there are no keys in set objects, however, so the first two
arguments are both values contained in the set. this is to make it consistent with other foreach() methods for map and array. if a thisarg parameter is provided to foreach(), it will be passed to callback when invoked, for use as its this value. otherwise, the val...
String.prototype.concat() - JavaScript
the concat() method concatenates the string
arguments to the calling string and returns a new string. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax str.concat(str2 [, ...strn]) parameters str2 [, ...strn] strings to concatenate to str. return value a new string containing the combined text of the strings provided. description the concat() function concatenates the string
arguments to the calling string and returns a new string. changes to the original string or the returned string don't affect the other. ...
...l request. syntax str.concat(str2 [, ...strn]) parameters str2 [, ...strn] strings to concatenate to str. return value a new string containing the combined text of the strings provided. description the concat() function concatenates the string
arguments to the calling string and returns a new string. changes to the original string or the returned string don't affect the other. if the
arguments are not of the type string, they are converted to string values before concatenating. performance it is strongly recommended that the assignment operators (+, +=) are used instead of the concat() method. examples using concat() the following example combines strings into a new string. let hello = 'hello, ' console.log(hello.concat('kevin', '. have a nice day.')) // hello, kevin. have a nice...
String.fromCodePoint() - JavaScript
ethod of a string object you created. polyfill the string.fromcodepoint() method has been added to ecmascript 2015 and may not be supported in all web browsers or environments yet. ...
...point() method has been added to ecmascript 2015 and may not be supported in all web browsers or environments yet. ...
String.prototype.normalize() - JavaScript
ne based on canonical equivalence and the other based on compatibility. canonical equivalence normalization in unicode, two sequences of code points have canonical equivalence if they represent the same abstract characters, and should always have the same visual appearance and behavior (for example, they should always be sorted in the same way). you can use normalize() using the "nfd" or "nfc"
arguments to produce a form of the string that will be the same for all canonically equivalent strings. in the example below we normalize two representations of the character "ñ": let string1 = '\u00f1'; // ñ let string2 = '\u006e\u0303'; // ñ string1 = string1.normalize('nfd'); string2 = string2.normalize('nfd'); console.log(string1 === string2); // true console.log(string1.length); ...
..."ff". it is compatible with two consecutive u+0066 code points ("ff"). the code point u+24b9 represents the symbol "Ⓓ". it is compatible with the u+0044 code point ("d"). in some respects (such as sorting) they should be treated as equivalent—and in some (such as visual appearance) they should not, so they are not canonically equivalent. ...
String.raw() - JavaScript
ate string, optionally with substitutions (${...}). return value the raw string form of a given template string. exceptions typeerror a typeerror is thrown if the first argument is not a well-formed object. description in most cases, string.raw() is used with template strings. the first syntax mentioned above is only rarely used, because the javascript engine will call this with proper
arguments for you, (just like with other tag functions). string.raw() is the only built-in tag function of template strings. it works just like the default template function and performs concatenation. you can even re-implement it with normal javascript code. examples using string.raw() string.raw`hi\n${2+3}!`; // 'hi\n5!', the character after 'hi' // is not a newline character, // '\' and 'n' are two...
...rmally you would not call string.raw() as a function, // but to simulate `foo${2 + 3}bar${'java' + 'script'}baz` you can do: string.raw({ raw: ['foo', 'bar', 'baz'] }, 2 + 3, 'java' + 'script'); // 'foo5barjavascriptbaz' // notice the first argument is an object with a 'raw' property, // whose value is an iterable representing the separated strings // in the template literal. // the rest of the
arguments are the substitutions. // the first argument’s 'raw' value can be any iterable, even a string! // for example, 'test' is treated as ['t', 'e', 's', 't']. // the following is equivalent to // `t${0}e${1}s${2}t`: string.raw({ raw: 'test' }, 0, 1, 2); // 't0e1s2t' specifications specification ecmascript (ecma-262)the definition of 'string.raw' in that specification. ...
TypedArray.prototype.every() - JavaScript
(). typedarray is one of the typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.every(callback[, thisarg]) parameters callback function to test for each element, taking three
arguments: currentvalue the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the typed array every was called upon. thisarg optional. value to use as this when executing callback. return value true if the callback function returns a truthy value for every array element; otherwise, false. description ...
...thod executes the provided callback function once for each element present in the typed array until it finds one where callback returns a falsy value (a value that becomes false when converted to a boolean). if such an element is found, the every method immediately returns false. otherwise, if callback returned a true value for all elements, every will return true. callback is invoked with three
arguments: the value of the element, the index of the element, and the array object being traversed. if a thisarg parameter is provided to every, it will be passed to callback when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this ...
TypedArray.prototype.filter() - JavaScript
s one of the typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.filter(callback[, thisarg]) parameters callback function to test each element of the typed array. invoked with
arguments (element, index, typedarray). return true to keep the element, false otherwise. thisarg optional value to use as this when executing callback. return value a new typed array with the elements that pass the test. description the filter() method calls a provided callback function once for each element in a typed array, and constructs a new typed array of all the values for which callback ret...
...array of all the values for which callback returns a true value. callback is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. typed array elements which do not pass the callback test are simply skipped, and are not included in the new typed array. callback is invoked with three
arguments: the value of the element the index of the element the typed array object being traversed if a thisarg parameter is provided to filter, it will be passed to callback when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the...
TypedArray.prototype.find() - JavaScript
typed array instead of its value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.find(callback[, thisarg]) parameters callback function to execute on each value in the typed array, taking three
arguments: element the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the array find was called upon. thisarg optional. object to use as this when executing callback. return value a value in the array if an element passes the test; otherwise, undefined. description the find method executes the cal...
...the typed array until it finds one where callback returns a true value. if such an element is found, find immediately returns the value of that element. otherwise, find returns undefined. callback is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. callback is invoked with three
arguments: the value of the element, the index of the element, and the typed array object being traversed. if a thisarg parameter is provided to find, it will be used as the this for each invocation of the callback. if it is not provided, then undefined is used. find does not mutate the typed array on which it is called. the range of elements processed by find is set before the first invocation of callb...
TypedArray.prototype.findIndex() - JavaScript
d array instead of its index. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.findindex(callback[, thisarg]) parameters callback function to execute on each value in the typed array, taking three
arguments: element the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the typed array findindex was called upon. thisarg optional. object to use as this when executing callback. return value an index in the array if an element passes the test; otherwise, -1. description the findindex method execut...
... typed array until it finds one where callback returns a true value. if such an element is found, findindex immediately returns the index of that element. otherwise, findindex returns -1. callback is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. callback is invoked with three
arguments: the value of the element, the index of the element, and the typed array object being traversed. if a thisarg parameter is provided to findindex, it will be used as the this for each invocation of the callback. if it is not provided, then undefined is used. findindex does not mutate the typed array on which it is called. the range of elements processed by findindex is set before the first invo...
TypedArray.prototype.forEach() - JavaScript
the foreach() method executes a provided function once per array element. this method has the same algorithm as array.prototype.foreach(). typedarray is one of the typed array types here. syntax typedarray.foreach(callback[, thisarg]) parameters callback function that produces an element of the new typed array, taking three
arguments: currentvalue the current element being processed in the typed array. index the index of the current element being processed in the array. array the array foreach() was called upon. thisarg optional. value to use as this when executing callback. return value undefined. description the foreach() method executes the provided callback once for each element present in the typed array in ascending order. it is not invoked for indexes that ha...
... optional. value to use as this when executing callback. return value undefined. description the foreach() method executes the provided callback once for each element present in the typed array in ascending order. it is not invoked for indexes that have been deleted or elided. however, it is executed for elements that are present and have the value undefined. callback is invoked with three
arguments: the element value the element index the typed array being traversed if a thisarg parameter is provided to foreach(), it will be passed to callback when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a fu...
TypedArray.prototype.map() - JavaScript
typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.map(mapfn[, thisarg]) parameters mapfn a callback function that produces an element of the new typed array, taking three
arguments: currentvalue the current element being processed in the typed array. index optional the index of the current element being processed in the typed array. array optional the typed array map() was called upon. thisarg optional value to use as this when executing mapfn. return value a new typed array. description the map() method calls a provided callback function (mapfn) o...
...ion the map() method calls a provided callback function (mapfn) once for each element in a typed array, in order, and constructs a new typed array from the results. mapfn is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes that are undefined, those which have been deleted, or which have never been assigned values. mapfn is invoked with three
arguments: the value of the element, the index of the element, and the typed array object being traversed. if a thisarg parameter is provided to map(), it will be passed to mapfn when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by mapfn is determined according to the usual rules for determining the this s...
TypedArray.prototype.reduce() - JavaScript
the typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.reduce(callback[, initialvalue]) parameters callback function to execute on each value in the typed array, taking four
arguments: previousvalue the value previously returned in the last invocation of the callback, or initialvalue, if supplied (see below). currentvalue the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the typed array reduce was called upon. initialvalue optional. object to use as the first argument...
...cessed in the typed array. array the typed array reduce was called upon. initialvalue optional. object to use as the first argument to the first call of the callback. return value the value that results from the reduction. description the reduce method executes the callback function once for each element present in the typed array, excluding holes in the typed array, receiving four
arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the typed array over which iteration is occurring. the first time the callback is called, previousvalue and currentvalue can be one of two values. if initialvalue is provided in the call to reduce, then previousvalue will be equal to initialvalue and currentvalue will be equal ...
TypedArray.prototype.reduceRight() - JavaScript
applies a function against an accumulator and each value of the typed array (from right-to-left) has to reduce it to a single value. this method has the same algorithm as array.prototype.reduceright(). typedarray is one of the typed array types here. syntax typedarray.reduceright(callback[, initialvalue]) parameters callback function to execute on each value in the typed array, taking four
arguments: previousvalue the value previously returned in the last invocation of the callback, or initialvalue, if supplied (see below). currentvalue the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the typed array reduce was called upon. initialvalue optional. object to use as the first argument...
...d in the typed array. array the typed array reduce was called upon. initialvalue optional. object to use as the first argument to the first call of the callback. return value the value that results from the reduction. description the reduceright method executes the callback function once for each element present in the typed array, excluding holes in the typed array, receiving four
arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the typed array over which iteration is occurring. the call to the reduceright callback would look something like this: typedarray.reduceright(function(previousvalue, currentvalue, index, typedarray) { // ... }); the first time the function is called, the previousvalue and...
TypedArray.prototype.some() - JavaScript
e(). typedarray is one of the typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.some(callback[, thisarg]) parameters callback function to test for each element, taking three
arguments: currentvalue the current element being processed in the typed array. index the index of the current element being processed in the typed array. array the typed array some was called upon. thisarg optional. value to use as this when executing callback. return value true if the callback function returns a truthy value for any array element; otherwise, false. description th...
... return value true if the callback function returns a truthy value for any array element; otherwise, false. description the some method executes the callback function once for each element present in the typed array until it finds one where callback returns a true value. if such an element is found, some immediately returns true. otherwise, some returns false. callback is invoked with three
arguments: the value of the element, the index of the element, and the array object being traversed. if a thisarg parameter is provided to some, it will be passed to callback when invoked, for use as its this value. otherwise, the value undefined will be passed for use as its this value. the this value ultimately observable by callback is determined according to the usual rules for determining the this s...
eval() - JavaScript
aller code size well worth the benefit function() more easily allows your code to utilize the performance buttering "use strict"; the code does not use eval(), making it orders of magnitude faster than otherwise. lastly, let's examine minification. with using function() as shown above, you can minify the code string passed to runcodewithdatefunction() far more efficiently because the function
arguments names can be minified too as seen in the minified code below. console.log(function('"use strict";return(function(a){return a(5)})')()(function(a){ return"monday tuesday wednesday thursday friday saturday sunday".split(" ")[a%7||0]})); there are also additional safer (and faster!) alternatives to eval() or function() for common use-cases. accessing member properties you should not use eval() t...
...esc.split('.'); while (arr.length > 1) { obj = obj[arr.shift()]; } return obj[arr[0]] = value; } var obj = {a: {b: {c: 0}}}; var proppath = getproppath(); // returns e.g. "a.b.c" var result = setdescendantprop(obj, proppath, 1); // obj.a.b.c will now be 1 use functions instead of evaluating snippets of code javascript has first-class functions, which means you can pass functions as
arguments to other apis, store them in variables and objects' properties, and so on. many dom apis are designed with this in mind, so you can (and should) write: // instead of settimeout(" ... ", 1000) use: settimeout(function() { ... }, 1000); // instead of elt.setattribute("onclick", "...") use: elt.addeventlistener('click', function() { ... } , false); closures are also helpful as a way to create pa...
new operator - JavaScript
the new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function. syntax new constructor[([
arguments])] parameters constructor a class or function that specifies the type of the object instance.
arguments a list of values that the constructor will be called with. description the new keyword does the following things: creates a blank, plain javascript object; links (sets the constructor of) this object to another object; passes the newly created object from step 1 as the this context; returns this if the function doesn't return an object. creating a user-defined object requires two steps: define the object type by writing a function. create an instance of the object with new. to de...
...the object with new. to define an object type, create a function for the object type that specifies its name and properties. an object can have a property that is itself another object. see the examples below. when the code new foo(...) is executed, the following things happen: a new object is created, inheriting from foo.prototype. the constructor function foo is called with the specified
arguments, and with this bound to the newly created object. new foo is equivalent to new foo(), i.e. if no argument list is specified, foo is called without
arguments. the object (not null, false, 3.1415 or other primitive types) returned by the constructor function becomes the result of the whole new expression. if the constructor function doesn't explicitly return an object, the object created in step 1...
super - JavaScript
the super keyword can also be used to call functions on a parent object. examples using super in classes this code snippet is taken from the classes sample (live demo). ...
...the super keyword can also be used to call functions on a parent object. examples using super in classes this code snippet is taken from the classes sample (live demo). ...
for...of - JavaScript
it invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
...a map const iterable = new map([['a', 1], ['b', 2], ['c', 3]]); for (const entry of iterable) { console.log(entry); } // ['a', 1] // ['b', 2] // ['c', 3] for (const [key, value] of iterable) { console.log(value); } // 1 // 2 // 3 iterating over a set const iterable = new set([1, 1, 2, 2, 3, 3]); for (const value of iterable) { console.log(value); } // 1 // 2 // 3 iterating over the
arguments object you can iterate over the
arguments object to examine all of the parameters passed into a javascript function: (function() { for (const argument of
arguments) { console.log(argument); } })(1, 2, 3); // 1 // 2 // 3 iterating over a dom collection iterating over dom collections like nodelist: the following example adds a read class to paragraphs that are direct descendants of an ...
MathML documentation index - MathML
mathml, mathml reference, mathml:element, mathml:general layout schemata the mathml <mphantom> element is rendered invisibly, but dimensions (such as height, width, and baseline position) are still kept. 25 <mroot> mathml, mathml reference, mathml:element, mathml:general layout schemata the mathml <mroot> element is used to display roots with an explicit index. ...
... 27 <ms> mathml, mathml reference, mathml:element, mathml:token elements the mathml <ms> element represents a string literal meant to be interpreted by programming languages and computer algebra systems. by default, string literals are displayed as enclosed by double quotes ("); by using the lquote and rquote attributes, you can set custom characters to display. ...
Using custom elements - Web Components
so far support only autonomous custom elements. high-level view the controller of custom elements on a web document is the customelementregistry object — this object allows you to register a custom element on the page, return information on what custom elements are registered, etc. to register a custom element on the page, you use the customelementregistry.define() method. this takes as its
arguments: a domstring representing the name you are giving to the element. note that custom element names require a dash to be used in them (kebab-case); they can't be single words. a class object that defines the behaviour of the element. optionally, an options object containing an extends property, which specifies the built-in element your element inherits from, if any (only relevant to customized ...
...s() { return ['c', 'l']; } this is placed right at the top of the constructor, in our example. note: find the full javascript source here. polyfills vs. classes custom element polyfills may patch native constructors such as htmlelement and others, and return a different instance from the one just created. if you need a constructor and a mandatory super call, remember to pass along optional
arguments and return the result of such a super call operation. class customelement extends htmlelement { constructor(...args) { const self = super(...args); // self functionality written in here // self.addeventlistener(...) // return the right context return self; } } if you don't need to perform any operation in the constructor, you can simply omit it so that its native behavio...
Exported WebAssembly functions - WebAssembly
exported webassembly functions are how webassembly functions are represented in javascript. this article describes what they are in a little more detail. exported... what? exported webassembly functions are basically just javascript wrappers that represent webassembly functions in javascript. when you call them, you get some activity in the background to convert the
arguments into types that wasm can work with (for example converting javascript numbers to int32), the
arguments are passed to the function inside your wasm module, the function is invoked, and the result is converted and passed back to javascript. you can retrieve exported webassembly functions in two ways: by calling table.prototype.get() on an existing table. by accessing a function exported from a wasm module instance via in...
...n go on to do pretty much anything to this function that you can do to other functions in javascript — call(), bind(), etc. testfunc.tostring() returns an interesting result: function 0() { [native code] } this gives you more of an idea of its wrapper-type nature. some other particulars to be aware of with exported webassembly functions: their length property is the number of declared
arguments in the wasm function signature. their name property is the tostring() result of the function's index in the wasm module. if you try to call a exported wasm function that takes or returns an i64 type value, it currently throws an error because javascript currently has no precise way to represent an i64. this may well change in the future though — a new int64 type is being considered for future...
Classes and Inheritance - Archive of obsolete content
earlier. for instance, to define a constructor for a class shape in terms of class, we can write: let shape = class({ initialize: function (x, y) { this.x = x; this.y = y; }, draw: function () { throw new error("not yet implemented"); } }); the property initialize is special. when it is present, the call to the constructor is forwarded to it, as are any
arguments passed to it (including the this object). in effect, initialize specifies the body of the constructor. note that the constructors created with class automatically check whether they are called as constructors, so an explicit check is no longer necessary. another special property is extends. it specifies the base class from which this class inherits, if any. class uses this information to automat...
Working with Events - Archive of obsolete content
he type of event we are interested in, identified by a string. many event emitters may emit more than one type of event: for example, a browser window might emit both open and close events. the list of valid event types is specific to an event emitter and is included with its documentation. listener: the listener itself. this is a function which will be called whenever the event occurs. the
arguments that will be passed to the listener are specific to an event type and are documented with the event emitter. for example, the following add-on registers a listener with the tabs module to listen for the ready event, and logs a string to the console reporting the event: var tabs = require("sdk/tabs"); tabs.on("ready", function () { console.log("tab loaded"); }); it is not possible to enu...
page-mod - Archive of obsolete content
ed every time this page-mod's content scripts are attached to a document. so if the user loads several documents which match this page-mod's include pattern, attach will be triggered for each document, each time with a distinct worker instance. each worker then represents a channel of communication with the set of content scripts loaded by this particular page-mod into that particular document.
arguments worker : the listener function is passed a worker object that can be used to communicate with any content scripts attached to this document. error this event is emitted when an uncaught runtime error occurs in one of the page-mod's content scripts.
arguments error : listeners are passed a single argument, the error object. ...
page-worker - Archive of obsolete content
scripts under self.options property. any kind of jsonable value (object, array, string, etc.) can be used here. optional. events message if you listen to this event you can receive message events from content scripts associated with this page worker. when a content script posts a message using self.postmessage(), the message is delivered to the add-on code in the page worker's message event.
arguments value : listeners are passed a single argument which is the message posted from the content script. the message can be any json-serializable value error this event is emitted when an uncaught runtime error occurs in one of the page worker's content scripts.
arguments error : listeners are passed a single argument, the error object. ...
panel - Archive of obsolete content
n be used here. optional. events show this event is emitted when the panel is shown. hide this event is emitted when the panel is hidden. message if you listen to this event you can receive message events from content scripts associated with this panel. when a content script posts a message using self.postmessage(), the message is delivered to the add-on code in the panel's message event.
arguments value : listeners are passed a single argument which is the message posted from the content script. the message can be any json-serializable value. error this event is emitted when an uncaught runtime error occurs in one of the panel's content scripts.
arguments error : listeners are passed a single argument, the error object. ...
querystring - Archive of obsolete content
lue pair. by default this is "&". assignment : string the string to use between each name and its corresponding value. by default this is "=". returns string : the query string. parse(querystring, separator, assignment) parse a query string into an object containing name:value pairs: querystring.parse('foo=bar&baz=bla') // => { foo: 'bar', baz: 'bla' } optionally separator and assignment
arguments may be passed to override default '&' and '=' characters: querystring.parse('foo:bar|baz:bla', '|', ':') // => { foo: 'bar', baz: 'bla' } parameters querystring : string the query string. separator : string the string to use as a separator between each name:value pair. by default this is "&". assignment : string the string to use between each name and its corresponding value. by default...
request - Archive of obsolete content
nsole.log("you have been rate limited!"); } } }).get(); methods get() make a get request. head() make a head request. post() make a post request. put() make a put request. delete() make a delete request. properties url headers content contenttype response events complete the request object emits this event when the request has completed and a response has been received.
arguments response : listener functions are passed the response to the request as a response object. response the response object contains the response to a network request issued using a request object. it is returned by the get(), head(), post(), put() or delete() method of a request object. all members of a response object are read-only. properties url the url of the response content. text the ...
system - Archive of obsolete content
usage querying your environment using the system module you can access environment variables (such as path), find out which operating system your add-on is running on and get information about the host application (for example, firefox or fennec), such as its version. ...
High-Level APIs - Archive of obsolete content
strings. request make simple network requests. selection get and set text and html selections in the current web page. self access data that is bundled with the add-on, and add-on metadata. simple-prefs store preferences across application restarts. simple-storage lets an add-on store data so that it's retained across firefox restarts. system query the add-on's environment and access
arguments passed to it. tabs open, manipulate, and access tabs, and receive tab events. timers set one-off and periodic timers. ui provides access to button, toolbar, and sidebar ui objects. url construct, validate, and parse urls. widget create a simple user interface for an add-on in firefox's add-on bar. windows enumerate and examine open browser windows, open new windows, and listen for win...
content/worker - Archive of obsolete content
om the worker using the port.on function url the url of the content. tab if this worker is attached to a content document, returns the related tab. events message this event allows the content worker to receive messages from its associated content scripts. calling the self.postmessage() function from a content script will asynchronously emit the message event on the corresponding worker.
arguments value : the event listener is passed the message, which must be a json-serializable value. error this event allows the content worker to react to an uncaught runtime script error that occurs in one of the content scripts.
arguments error : the event listener is passed a single argument which is an error object. detach this event is emitted when the document associated with this worker is u...
dev/panel - Archive of obsolete content
unction gotroot(root) { // can use root actor here } actors actors in the remote debugging protocol are volcan.js objects. the messages actors can accept are methods of those objects. the message type becomes the method name. for example, the root actor object has a method listtabs and the stylesheet actor object has a method getstylesheets. any additional parameters sent in the message become
arguments to the method. if a message is expected to get a reply, then the method returns a promise which is fulfilled with the reply. if the message reply in the remote debugging protocol would contain an actor id, then in volcan.js the object that fulfills the promise contains that actor instance. if the message reply contains some json object, then in volcan.js the object that fulfills the promise incl...
event/target - Archive of obsolete content
ects that emit events. this module provides an exemplar eventtarget object, that implements an interface for adding and removing event listeners of a specific type. eventtarget is the base class for all objects in sdk on which events are emitted. also see the tutorial on implementing event targets to get started with this api. instantiation it's easy to create event target objects, no special
arguments are required. const { eventtarget } = require("sdk/event/target"); let target = eventtarget(); for a convenience though optional options
arguments may be used, in which case all the function properties with keys like: onmessage, onmyevent... will be auto registered for associated 'message', 'myevent' events on the created instance. all other properties of options will be ignored. adding listen...
lang/type - Archive of obsolete content
value : mixed the variable to check. returns boolean : boolean indicating if value is an object. isarray(value) returns true if value is an array, false otherwise. uses native array.isarray. let { isarray } = require('sdk/lang/type'); isarray([]); // true isarray({}); // false parameters value : mixed the variable to check. returns boolean : boolean indicating if value is an array. is
arguments(value) returns true if value is an array-like
arguments object, false otherwise. let { is
arguments } = require('sdk/lang/type'); function run () { is
arguments(
arguments); // true is
arguments([]); // false is
arguments(array.slice(
arguments)); // false } run(1, 2, 3); parameters value : mixed the variable to check. returns boolean : boolean indicating if value is an
arguments object. ...
loader/sandbox - Archive of obsolete content
privileges giving it access to all the xpcom components. optionally the sandbox function can be passed a second argument (see sandbox documentation on mdn for details). evaluate code module provides evaluate function that lets you execute code in the given sandbox: evaluate(scope, 'var a = 5;'); evaluate(scope, 'a + 2;'); //=> 7 more details about evaluated script may be passed via optional
arguments that may improve exception reporting: // evaluate code as if it was loaded from 'http://foo.com/bar.js' and // start from 2nd line. evaluate(scope, 'a ++', 'http://foo.com/bar.js', 2); version of javascript can be also specified via an optional argument: evaluate(scope, 'let b = 2;', 'bar.js', 1, '1.5'); // throws cause `let` is not defined in js 1.5. load scripts this module provides a limi...
ui/button/action - Archive of obsolete content
fox 36. value to attach to the button as a badge. may be a number or a string. the badge can contain as many characters (or digits) as you like, but only the first four will be displayed. badgecolor new in firefox 36. color for the badge, specified as a css <color> value. events click this event is emitted when a user clicks the button or your add-on calls the button's click() method.
arguments state : the button's state. this contains all the button's properties. ...
ui/sidebar - Archive of obsolete content
the built-in sidebars. usage creating, showing, and hiding sidebars you construct a sidebar object using the sidebar() constructor. once you've done that, you can show the sidebar by calling the sidebar's show() method. if a new window is opened from a window that has a sidebar visible, the new window gets a sidebar, too. you can hide the sidebar by calling its hide() method. called with no
arguments, show() and hide() will operate on the currently active window. from firefox 33 onwards you can pass a browserwindow into these methods, and they will then operate on the specified window. alternatively, the view->sidebar submenu in firefox will contain a new item which the user can use to show or hide the sidebar: the sidebar generates a show event when it is shown and a hide event when it is ...
util/uuid - Archive of obsolete content
generate or parse uuids. usage it exports a single function, uuid(). for more details about uuid representations and what they are used for by the platform see the mdn documentation for jsid. generate uuid to generate a new uuid, call uuid() with no
arguments: let uuid = require('sdk/util/uuid').uuid(); parsing uuid to convert a string representation of a uuid to an nsid, pass the string representation to uuid(): let { uuid } = require('sdk/util/uuid'); let firefoxuuid = uuid('{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'); globals functions uuid(stringid) generate a new uuid, or convert a string representation of a uuid to an nsid. parameters stringid : string string representation of a uuid, such as: "8cbc9bf4-4a16-11e2-aef7-c1a56188709b" optional. if this argument is supplied, it ...
Listening for Load and Unload - Archive of obsolete content
to follow this tutorial you'll need to have learned the basics of jpm. if your add-on exports a function called main(), then that function will be called whenever the add-on is loaded, and it will be passed an object containing a string describing the reason it was loaded as well as any
arguments passed to it. if your add-on exports a function called onunload(), then that function will be called when the add-on is unloaded, and it will be passed a string describing the reason it was unloaded. you don't have to use exports.main() or exports.onunload(). you can just place your add-on's code at the top level instead of wrapping it in a function assigned to exports.main(). it will be loaded in the same circumstances, but you won't get access to the load/unload reason or
arguments. exports.main()...
Tutorials - Archive of obsolete content
use them too. unit testing writing and running unit tests using the sdk's test framework. chrome authority get access to the components object, enabling your add-on to load and use any xpcom object. creating event targets enable the objects you define to emit their own events. listen for load and unload get notifications when your add-on is loaded or unloaded by firefox, and pass
arguments into your add-on from the command line. using third-party modules (jpm) install and use additional modules which don't ship with the sdk itself. localization writing localizable code. mobile development develop add-ons for firefox mobile on android. add-on debugger debug your add-on's javascript. putting it together annotator add-on a walkthrough of a relatively complex add-...
File I/O - Archive of obsolete content
function(status) { if (!components.issuccesscode(status)) { // handle error! return; } // data has been written to the file. }); copy a stream to a file this function copies all of the data from an input stream to a file asyncronously. it overwrites the file if it is there, and if it is not there it creates a file then writes into it. it takes an nsiinputstream and an nsifile as
arguments, and uses netutil.jsm and fileutils.jsm. the callback argument is optional. function streamtofile(stream, file, callback) { var output = fileutils.opensafefileoutputstream(file) netutil.asynccopy(stream, output, callback); } synchronous checking the existence of a file // |file| is nsifile if (file.exists()) { // ... } note: you should avoid checking the existence of a file, not...
Preferences - Archive of obsolete content
var prefservice = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); this._branch = prefservice.getbranch(branch_name); this._branch.queryinterface(compon...
Rosetta - Archive of obsolete content
var ascripts = document.getelementsbytagname("script"), nidx = 0; nidx < ascripts.length; parsescript(ascripts[nidx++]) ); } var odicts = {}, rignoremimes = /^\s*(?:text\/javascript|text\/ecmascript)\s*$/; this.translatescript = parsescript; this.translateall = parsedocument; this.appendcompiler = function (vmimetypes, fcompiler) { if (
arguments.length < 2) { throw new typeerror("rosetta.appendcompiler() \u2013 not enough
arguments"); } if (typeof fcompiler !== "function") { throw new typeerror("rosetta.appendcompiler() \u2013 second argument must be a function"); } if (!array.isarray(vmimetypes)) { odicts[(vmimetypes).tostring()] = fcompiler; return true; } for (var nidx = 0; nidx < vmi...
Sidebar - Archive of obsolete content
y. for example the code below calls a function defined in the sidebar's context: var sidebarwindow = document.getelementbyid("sidebar").contentwindow; // verify that our sidebar is open at this moment: if (sidebarwindow.location.href == "chrome://yourextension/content/whatever.xul") { // call "yournotificationfunction" in the sidebar's context: sidebarwindow.yournotificationfunction(any
arguments); } testing which sidebar is open the sidebar content may contain different panels (bookmarks, history, webpanel, etc.) and sometimes one wants to only act on the sidebar when it contains a specific panel. the good practice to determine which sidebar is open at a time is by testing in location property, which is a chrome url: var sidebarwindow = document.getelementbyid("sidebar").contentwindo...
View Source for XUL Applications - Archive of obsolete content
of the content window containing the document that we want to view the source of. pass this if you want to attempt to load the document source out of the network cache. linenumber (optional) the line number to focus on once the source has loaded. deprecated api this api is likely to go away in the future, and should no longer be used. the viewsource method will also accept the following
arguments in place of the object: aurl a string url for the document to view the source of. apagedescriptor (optional) a "descriptor" that allows the source to be retrieved from the network cache. this is usually gotten from the nsiwebpagedescriptor interface via currentdescriptor. adocument (optional) the content document that we're attempting to load the source from. alinenumber (optional) the ...
Offering a context menu for form controls - Archive of obsolete content
ght-click behavior the overlaid code is responsible for adjusting the behavior of right-clicking on form controls. window.addeventlistener("load", function() { let settargetoriginal = nscontextmenu.prototype.settarget; components.utils.reporterror(settargetoriginal); nscontextmenu.prototype.settarget = function(anode, arangeparent, arangeoffset) { settargetoriginal.apply(this,
arguments); if (this.istargetaformcontrol(anode)) this.shoulddisplay = true; }; }, false); this code, which is run when the window is opened up, works by replacing the settarget() routine for the prototype of nscontextmenu with one that forces the context menu to display if the target of the menu is a form control. as a result, all controls in the window will support a context menu w...
Adding windows and dialogs - Archive of obsolete content
somevalue = 2; let returnvalue = { accepted : false , result : "" }; window.opendialog( "chrome://xulschoolhello/content/somedialog.xul", "xulschoolhello-some-dialog", "chrome,centerscreen", somevalue, returnvalue); // you can send as many extra parameters as you need. // if (returnvalue.accepted) { do stuff } the optional parameters are available in the dialog code through the window.
arguments property: let somevalue = window.
arguments[0]; let returnvalue = window.
arguments[1]; // returnvalue.accepted = true; // returnvalue.result = "something"; the parameter named returnvalue is an object that the dialog will modify to reflect what the user did in it. this is the simplest way to have the dialog return something to its opener. note that the opener will wait until the dialog is ...
Appendix C: Avoiding using eval in Add-ons - Archive of obsolete content
mous function (which is called immediately). // this will encapsulate local variables such as _original and // not pollute the global namespace. (function() { // keep a reference to the original function. var _original = gbrowser.addtab; // override a function. gbrowser.addtab = function() { // execute some action before the original function call. try { myaddon.onaddtab(
arguments[0]); } catch (ex) { /* might handle this */ } // execute original function. var rv = _original.apply(gbrowser,
arguments); // execute some action afterwards. try { myaddon.doneaddtab(rv); } catch (ex) { /* might handle this */ } // return the original result return rv; }; })(); this is admittedly a bit more verbose, but at the same time it should be e...
Setting Up a Development Environment - Archive of obsolete content
h multiple firefox installations. for instance, you may want to test your extension in firefox 3.5 and firefox 3.6, or test it in a localized version of firefox. you can install as many firefox versions as you want, and mix profiles and versions. on windows and linux it's easy to create shortcuts for every profile you create, using the commands described at http://kb.mozillazine.org/command_line_
arguments . for mac os x developers, there is also a way to set up "shortcuts". you can do this by opening the automator application, choosing run shell script and then entering the profile-loading script in the textbox: /applications/firefox.app/contents/macos/firefox-bin -no-remote -p myprofile > /dev/null & you can change "/dev/null" to a file location, in case you want to see dump output from fi...
User Notifications and Alerts - Archive of obsolete content
line button. nb.appendnotification( message, "xulschoolhello-friend-notification", "chrome://xulschoolhello/skin/friend-notification.png", nb.priority_info_high, [ acceptbutton, declinebutton ]); all browser tabs have a notification box by default, so you don't need to do any overlaying. the notificationbox elements can be obtained from the gbrowser object. in this case we don't pass any
arguments to getnotificationbox so that we get the notification box that corresponds to the tab currently on display. the appendnotification method takes the message, id, image (32x32), level and buttons. the level argument determines the "strength" of the message, indicated by its background color when it is displayed. you should look for the level that better fits your message, and use the lowest applica...
Updating addons broken by private browsing changes - Archive of obsolete content
e} will cause a private window to open, otherwise the window will always be non-private. use {private: privatebrowsingutils.iswindowprivate(window)} to open a window that matches the current window's privacy status. openlinkin: can receive an extra private boolean property in the parameter object. internalsave: takes a new required document argument (prior to the optional boolean and string
arguments) indicating the document that originated the save action. gprivatebrowsingui: can no longer be used to control private browsing of any kind. any new private browsing session should be opened using openbrowserwindow, and any queries for private browsing status should use privatebrowsingutils.iswindowprivate(win) on a relevant window object. saveurl: takes a new required document argument ind...
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
red hat 3.4.3-22.fc3) -wall -w -wno-unused -wpointer-arith -wcast-align -wno-long-long -pedantic -pthread -pipe c++ gcc version 3.4.3 20050227 (red hat 3.4.3-22.fc3) -fno-rtti -fno-exceptions -wall -wconversion -wpointer-arith -wcast-align -woverloaded-virtual -wsynth -wno-ctor-dtor-privacy -wno-non-virtual-dtor -wno-long-long -pedantic -fshort-wchar -pthread -pipe -i/usr/x11r6/include configure
arguments --disable-mailnews --enable-extensions=cookie,xml-rpc,xmlextras,pref,transformiix,universalchardet,webservices,inspector,gnomevfs,negotiateauth --enable-crypto --disable-composer --enable-single-profile --disable-profilesharing --with-system-jpeg --with-system-zlib --with-system-png --with-pthreads --disable-tests --disable-jsd --disable-installer '--enable-optimize=-os -g -pipe -m32 -march=i386 ...
ActiveX Control for Hosting Netscape Plug-ins in IE - Archive of obsolete content
have administrator privileges to install a new control on operating systems such as windows nt, 2000 & xp. usage insert some html like this into your content: <object classid="clsid:dbb2de32-61f1-4f7f-beb8-a37f5bc24ee2" width="500" height="300"> <param name="type" value="video/quicktime"/> <param name="src" value="http://www.foobar.com/some_movie.mov"/> <!-- custom
arguments --> <param name="loop" value="true"/> </object> the classid attribute tells ie to create an instance of the plug-in hosting control, the width and height specify the dimensions in pixels. you may optionally specify a codebase attribute if you have packaged the control into a cab file and wish for it to be installed automatically. the following <embed> attributes have <param> tag equiva...
Creating a Firefox sidebar extension - Archive of obsolete content
sidebarurl="chrome://emptysidebar/content/emptysidebar.xul" sidebartitle="&emptysidebar.title;" oncommand="togglesidebar('viewemptysidebar');" /> </broadcasterset> </overlay> the overlay file consists of three entries, the menu definition, shortcut keys and the broadcaster. the broadcaster serves two purposes. the first is it indirectly provides the
arguments for the togglesidebar function. the second is it provides attributes to the menuitem, some of which are changed automatically when togglesidebar is called. see code_snippets/sidebar for more information. if the sidebar is not going to have a command-key, one can remove the openemptysidebar.commandkey and openemptysidebar.modifierskey keys from the dtd, remove the <keyset> from the firefoxoverlay...
JavaScript Client API - Archive of obsolete content
case "weave:engine:stop-tracking": if (this._enabled) { // remove event handler or observer here ... this._enabled = false; } break; }, onevent: function onevent() { /* here is where you'd handle the event. see the documentation for whatever service you are observing to find out what to call this method, what
arguments to expect, and how to interpret them. */ var guid = 0; /* here is where you'd include code to figure out the guid of the item that has changed... */ this.addchangedid(guid); // update the score as you see fit: this.score += 10; } }; writing an engine class your engine class serves to tie together your store, tracker, and record classes into a bundle that ...
Helper Apps (and a bit of Save As) - Archive of obsolete content
lemac. unix: launch directly via nsiprocess. security considerations multiple checks for whether a file is executable (on windows) to keep from launching such files via ::shellexecute(). checks happen in onstartrequest, in the helper app dialog, and as a last ditch in the launching code. limitations of nsimimeinfo no way to say "do whatever the os default is." no support for command-line
arguments. no support for multiple commands connected by pipes (mostly useful on unix). ongoing work support synchronous dialogs, not just asynchronous ones (fixes many issues related to pre-downloading, content-decoding, etc). reworking the nsimimeservice api to improve the quality of the mimeinfo we get. reworking the helper app dialog to save user choices better. gnome integration for unix. fu...
generateCRMFRequest() - Archive of obsolete content
request for each key pair that is generated. the first three parameters will be applied to every request. the "escrowauthoritycert" parameter will only be used for requests that pertain to a key that is being escrowed. after the "escrowauthoritycert" parameter, the method takes some javascript code that is invoked when the crmf request is ready. finally, there are 1 or more sets of key generation
arguments. each key generation will be associated with its own request. all the requests will have the same dn. argument description "requesteddn" an rfc 1485 formatted dn to include in the certificate request. "regtoken" a value used to authenticate the user to the ra/ca. "authenticator" a value that the user can authenticate with in the future when their pr...
JavaScript crypto - Archive of obsolete content
smflags and cipherflags pkcs11mechanismflags = pkcs11_mech_dsa_flag | pkcs11_mech_skipjack_flag | pkcs11_mech_random_flag; pkcs11cipherflags = 0; return values js_ok_add_module = 3 // successfully added a module js_err_other = -1 // errors other than the following js_err_user_cancel_action = -2 // user aborted an action js_err_incorrect_num_of_
arguments = -3 // calling a method w/ incorrect # of //
arguments js_err_add_module = -5 // error adding a module js_err_bad_module_name = -6 // the module name is invalid js_err_add_module_duplicate = -10 // the module being installed has the // same name as one of the modules that ...
Twitter - Archive of obsolete content
lib.twitter.statuses.update(). to call trends/current, use jetpack.lib.twitter.trends.current(). for search, jetpack.lib.twitter.search(). replace slashes with dots. most of twitter's methods are supported, but not all. list methods, spam reporting methods, and oauth are not currently supported. if something is not supported but you would like it to be, please file a bug. (or write a patch!)
arguments each and every method in the library takes a single argument, an object. there are two styles you can use to define this object. the first is simple: define properties on the object corresponding to the parameters of the twitter method. for instance, some twitter methods have an id parameter, so you would define an id property and set its value to a user's id. (you can read about the parameters o...
Jetpack Snippets - Archive of obsolete content
)">test</a> <script><![cdata[ //firebug lite bookmarklet code: var firebug=document.createelement('script'); firebug.setattribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'); document.body.appendchild(firebug); (function(){if(window.firebug.version){firebug.init();}else{settimeout(
arguments.callee);}})();void(firebug); ]]></script> </body></html>, width: 800, //wide enough to use firebug onselect: function(slide) { slide.slide(800, true); }}); calling into a slidebar from the global jetpack scope jetpack.slidebar.append({ onready: function (slide) { // call out to a global function, passing the slidebar object exinitslidebar(slide...
Clipboard - Archive of obsolete content
e access to the clipboard. the api is fairly straightforward; examples can be found here. the api lives in the future and must be imported for use. jetpack.future.import("clipboard"); methods set(contentstringflavorstring) stringwrites data from jetpack to the clipboard. this is the recommended method of copying data to the clipboard. contentthe content to be copied to the clipboard. if no other
arguments are specified, the flavor of the content is assumed to 'plain'.string flavordata type. this is an optional parameter. the only flavors currently implemented are 'plain' (text/unicode) and 'html' (which is html).string"text" here's an example of how to use the method to set the clipboard. jetpack.import.future("clipboard");// in text formatjetpack.clipboard.set("hello world");// in other clipboa...
Clipboard Test - Archive of obsolete content
the clipboard. the api is fairly straightforward; examples can be found here. this api currently lives in the future and must be imported for use. jetpack.future.import("clipboard"); methods set(contentstringflavorstring)writes data from jetpack to the clipboard. this is the recommended method of copying data to the clipboard. string contentthe content to be copied to the clipboard. if no other
arguments are specified, the flavor of the content is assumed to 'plain'.string flavordata type. this is an optional parameter. the only flavors currently implemented are 'plain' (text/unicode) and 'html' (which is html).string"text" here's an example of how to use the method to set the clipboard. jetpack.import.future("clipboard");// in text formatjetpack.clipboard.set("hello world");// in other clipboa...
Clipboard - Archive of obsolete content
o the clipboard. the api is fairly straightforward; examples can be found here. this api currently lives in the future and must be imported for use. jetpack.future.import("clipboard"); methods set(contentstringflavorstring)writes data from jetpack to the clipboard. this is the recommended method of copying data to the clipboard. string contentthe content to be copied to the clipboard. if no other
arguments are specified, the flavor of the content is assumed to 'plain'.string flavordata type. this is an optional parameter. the only flavors currently implemented are 'plain' (text/unicode) and 'html' (which is html).string"text" here's an example of how to use the method to set the clipboard. jetpack.import.future("clipboard"); // in text format jetpack.clipboard.set("hello world"); // in other clip...
Selection - Archive of obsolete content
html; setting the selection the following is an example of getting the selection from the user. jetpack.import.future("selection");jetpack.selection.text = 'hello';jetpack.selection.html = '<b>hello</b>'; methods onselection(func function)this method allows you to execute an event function when a selection is made. funca function to be called when the selection is made. this function receives no
arguments. use jetpack.selection.*. function adding a selection event jetpack.selection.onselection( fn ); removal of a selection event jetpack.selection.onselection.unbind( fn ); verbose example the following example will bold the html that you select. jetpack.import.future("selection");jetpack.selection.onselection(function(){ var html = jetpack.selection.html; jetpack.selection.html = "<b>" + ht...
Selection - Archive of obsolete content
; setting the selection the following is an example of getting the selection from the user. jetpack.import.future("selection"); jetpack.selection.text = 'hello'; jetpack.selection.html = '<b>hello</b>'; methods onselection(func function)this method allows you to execute an event function when a selection is made. funca function to be called when the selection is made. this function receives no
arguments. use jetpack.selection.*. function adding a selection event jetpack.selection.onselection( fn ); removal of a selection event jetpack.selection.onselection.unbind( fn ); verbose example the following example will bold the html that you select. jetpack.import.future("selection"); jetpack.selection.onselection(function(){ var html = jetpack.selection.html; jetpack.selection.html = "<b>"...
Clipboard - Archive of obsolete content
to the clipboard. the api is fairly straightforward; examples can be found here. the api currently lives in the future and must be imported for use. jetpack.future.import("clipboard"); methods set(contentstringflavorstring) stringwrites data from jetpack to the clipboard. this is the recommended method of copying data to the clipboard. contentthe content to be copied to the clipboard. if no other
arguments are specified, the flavor of the content is assumed to 'plain'.string flavordata type. this is an optional parameter. the only flavors currently implemented are 'plain' (text/unicode) and 'html' (which is html).string"text" here's an example of how to use the method to set the clipboard. jetpack.import.future("clipboard"); // in text format jetpack.clipboard.set("hello world"); // in other clip...
Selection - Archive of obsolete content
; setting the selection the following is an example of getting the selection from the user. jetpack.import.future("selection"); jetpack.selection.text = 'hello'; jetpack.selection.html = '<b>hello</b>'; methods onselection(func function)this method allows you to execute an event function when a selection is made. funca function to be called when the selection is made. this function receives no
arguments. use jetpack.selection.*. function adding a selection event jetpack.selection.onselection( fn ); removal of a selection event jetpack.selection.onselection.unbind( fn ); verbose example the following example will bold the html that you select. jetpack.import.future("selection"); jetpack.selection.onselection(function(){ var html = jetpack.selection.html; jetpack.selection.html = "<b>"...
Reading textual data - Archive of obsolete content
0xfffd); is.queryinterface(components.interfaces.nsiunicharlineinputstream); if (is instanceof components.interfaces.nsiunicharlineinputstream) { var line = {}; var cont; do { cont = is.readline(line); // now you can do something with line.value } while (cont); } the above example reads an entire stream until eof. see nsiconverterinputstream for nsiconverterinputstream.init()
arguments. earlier versions reading strings earlier versions of gecko do not provide easy ways to read unicode data from a stream. you will have to manually read a block of data and convert it using nsiscriptableunicodeconverter. for example: // first, get and initialize the converter var converter = components.classes["@mozilla.org/intl/scriptableunicodeconverter"] .createin...
Safely loading URIs - Archive of obsolete content
ow with such expanded privileges, it may be able to abuse it to gain access to those privileges itself. to solve this problem, gecko provides methods that allow the caller to check whether it's safe to load a particular uri. these methods are exposed on the nsiscriptsecuritymanager interface and are called checkloaduri, checkloaduriwithprincipal, and checkloaduristr. all three methods take three
arguments: the first argument identifies the source of the uri, the second argument is the uri that one plans to load, and the third argument is a set of flags that can be used to impose additional restrictions on the uris that may be loaded. it's important to make sure that the first argument to these methods identifies the source of the uri. so if you're implementing a context menu and you add a "view im...
Space Manager Detailed Design - Archive of obsolete content
-coordinates by adding the space manager's offset to the occupied space rect passed in. create a new frame info instance for the frame and rect, returning an error if allocation fails. check if the occupied space rect (adjusted) is empty, if so, return an error (note: this could be done earlier, or prevented by the caller) allocate a new bandrect instance with the rect and frame as constructor
arguments, and insert it into the collection via insertbandrect insertbandrect: internal method to insert a band rect into the bandlist in the correct location. there are several cases it has to handle, as specified in the source file comments: // when comparing a rect to a band there are seven cases to consider. // 'r' is the rect and 'b' is the band. // // case 1 case 2 ...
Supporting per-window private browsing - Archive of obsolete content
ivatebrowsingservice). privatebrowsingenabled; if (!inprivatebrowsing) { ... } } catch(e) { components.utils.reporterror(e); return; } } obtaining an nsiloadcontext for privacy-sensitive apis some apis (such as nsitransferable and nsiwebbrowserpersist) take nsiloadcontext
arguments that are used to determine whether they should be classed as private or not (for example, whether the uri being persisted by saveuri should be added to the permanent download history). to do this, import resource://gre/modules/privatebrowsingutils.jsm and use privatebrowsingutils.getprivacycontextfromwindow(win), passing a window object that is related to the content in question. as an example, i...
Tamarin Acceptance Test Template - Archive of obsolete content
ion = "test"; // provide a document reference (ie, actionscript section) var version = "as3"; // version of ecmascript or actionscript var title = "test"; // provide ecma section title or a description var bugnumber = ""; starttest(); // leave this alone /** * calls to addtestcase here. ...
Tamarin build documentation - Archive of obsolete content
command to create a copy of the tamarin repository: $ hg clone http://hg.mozilla.org/tamarin-central tamarin-central tips for working with mercurial can be found here. building tamarin building tamarin will create all the libraries for the avmplus and garbage collector (mmgc), and create a standalone executable (shell) for executing files in the abc file format. running the shell without any
arguments will list the available options. note that additional command-line
arguments are only available in the debug configuration. the tamarin codebase contains a cross-platform build system for mozilla developers. the cross-platform build system is used for daily automated build testing so it is the most reliable system. the tamarin codebase has the ability to build additional code which supports deb...
Example Sticky Notes - Archive of obsolete content
eturn st.replace(re,''); } else { return ''; } ]]></getter> <setter><![cdata[ // "val" in setter contains the assignment value. // here we simply echoing it back: return val; ]]></setter> </property> <method name="setborder"> <!-- new method for the bound element. unlike virtual property it is called in function context: this.setborder(arg) you also may define any amount of named
arguments using <parameter name="argumentname"/> --> <parameter name="arg"/> <body><![cdata[ this.style.border = arg; ]]></body> </method> </implementation> <handlers> <!-- event handlers. mouse events sent to bindings are refactored, so event.target / event.relatedtarget always points to the bound element, even if it was originated to/from a child. --> <handler event="click"><![cdata[...
Properties - Archive of obsolete content
ilable. extension, theme, and plug-in developers must switch away from install.js based packages to the new packaging scheme with an install.rdf manifest. in particular plugin developers should see how to package a plugin as an extension. properties archive full local path of the archive after it is downloaded to the platform specific temp folder. (e.g. c:\temp\argstest.xpi)
arguments args can be passed in through the triggering apis by attaching a ? and then the rg string to the xpi url: (e.g. startsoftwareupdate("http://webserver/argstest.xpi?argument_string") will result in the value of install.
arguments being argument_string #). note that spaces in the arg string are legal. everything after the question mark is treated as one string which becomes the install.argumen...
droppedLinkHandler - Archive of obsolete content
« xul reference home droppedlinkhandler type: function this function is called when links are dropped to the browser element, with the following
arguments. droppedlinkhandler(event, uri, name) -- firefox 51 or older droppedlinkhandler(event, links) -- firefox 52 or newer event -- drop event, or null if no event is available uri -- uri string of the dropped link name -- name string of the dropped link links -- array of the dropped items with nsidroppedlinkitem interface ...
Writing to Files - Archive of obsolete content
file(). it doesn't matter whether the file exists or not. nsiscriptableio.newoutputstream() is called to create a new output stream, which will be used to write to the file. in this example, the operations are enclosed in a try-catch block in order to capture any errors that might occur during the process. see file errors for a list of errors that might occur. the newoutputstream method takes two
arguments in this example. the first argument is the file to write to, and the second is a set of flags which control the writing. in this case, the 'text' flag is used which indicates that you will be writing text to the file. when writing text files, characters are writing using a chosen character set, encoded automatically. the default character set is 'utf-8' but this can be changed using an additional...
appendNotification - Archive of obsolete content
rity_warning_high priority_critical_low priority_critical_medium priority_critical_high priority_critical_block buttons : the buttons argument is an array of button descriptions. each description is an object with the following properties: accesskey - the accesskey to appear on the button callback - function to be called when the button is activated. this function is passed three
arguments: the <notification> the button is associated with the button description as passed to appendnotification. the element which was the target of the button press event. if the return value from this function is not true, then the notification is closed. the notification is also not closed if an error is thrown. label - the label to appear on the button popup - the id of a popup...
openPopup - Archive of obsolete content
popup is oriented depends on the direction of the anchor. position possible values for position are: before_start, before_end, after_start, after_end, start_before, start_after, end_before, end_after, overlap, and after_pointer. check positioning of the popup guide for a precise description of the effect of the different values. x, y for an anchored popup, the x and y
arguments may be used to offset the popup from its anchored position by some number, measured in css pixels. an unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. in this case, the position and attributesoverride
arguments are ignored. iscontextmenu the iscontextmenu argument should be true for context menus and f...
openSubDialog - Archive of obsolete content
« xul reference home opensubdialog( url, features, params ) return type: window opens a child modal dialog. usually this method would be used to allow the user to configure advanced options. the
arguments are similar to the window's opendialog method except that the window name does not need to be supplied. the url should be a xul file. if the child dialog is also a prefwindow, set its type attribute to child so that preferences will be saved properly when the main dialog is closed. ...
selectItemRange - Archive of obsolete content
« xul reference home selectitemrange( startitem, enditem ) return type: no return value selects the items between the two items given as
arguments, including the start and end items. all other items are deselected. this method does nothing for single-selection list boxes. a select event is sent after the selection is made. ...
MenuModification - Archive of obsolete content
lete"); in this example, the insertitemat method is used to insert a new 'delete' item at the beginning of the menu's popup. the first argument is the index where the new item should be inserted. in this case, 0 is supplied as the index, which means before the first item. indicies are counted starting at 0, so to insert an item before the fourth item pass 3 as the argument. the second and third
arguments to insertitemat are the label and value for the new item, as with appenditem. both the appenditem and insertitemat methods return the new menuitem, so you can further modify it, for instance to add an access key, as in the following example: var item = menu.appenditem("insert", "insert"); item.accesskey = "i"; appending submenus there is no built-in method to append submenus to a menu. to do...
MoveResize - Archive of obsolete content
sizing a popup menus and popups have methods which may be used to move and resize them. moving a popup once a popup is open, it can be moved using the popup's moveto method. void moveto(in long left, in long top); the left argument is the horizontal screen position and the top argument is the vertical screen position. this method will change the left and top attributes to match the supplied
arguments, so if these attributes are persisted the values will be restored when the window is displayed again. for instance, the following example will move a popup to the upper left corner of the screen: popup.moveto(0, 0); the position may be shifted so as not to cover user interface elements provided by the operating system, such as the menu bar or the task bar. resizing a popup the size of a pop...
SQLite Templates - Archive of obsolete content
e value double for double precision floating point values. if no type is specified, a string is assumed. we could later change the age to use in the query with a short script: function adjustage(min, max) { document.getelementbyid("minage").textcontent = min; document.getelementbyid("maxage").textcontent = max; document.getelementbyid("friends").builder.rebuild(); } this function takes two
arguments, the minimum and maximum values to use. we retrieve the param elements and set their textcontent properties to the desired value. finally, we rebuild the entire template. « previousnext » ...
textbox (Toolkit autocomplete) - Archive of obsolete content
l this method yourself. select() return type: no return value selects all the text in the textbox. setselectionrange( start, end ) return type: no return value sets the selected portion of the textbox, where the start argument is the index of the first character to select and the end argument is the index of the character after the selection. set both
arguments to the same value to move the cursor to the corresponding position without selecting text. related interfaces nsiaccessibleprovider, nsiautocompleteinput, nsidomxulmenulistelement articles how to implement custom autocomplete search component ...
Textbox (XPFE autocomplete) - Archive of obsolete content
pletesession interface. select() return type: no return value selects all the text in the textbox. setselectionrange( start, end ) return type: no return value sets the selected portion of the textbox, where the start argument is the index of the first character to select and the end argument is the index of the character after the selection. set both
arguments to the same value to move the cursor to the corresponding position without selecting text. syncsessions( autocompleteelement ) obsolete since gecko 26 return type: void copy the sessions from another autocomplete element. related interfaces nsiaccessibleprovider, nsidomxulmenulistelement ...
Tree Widget Changes - Archive of obsolete content
get the columns object which implements the nsitreecolumns interface for a tree using the tree's columns property. from there you can get specific columns, the current sort column, and position and size info about the columns. for the most part these objects are readonly; you can modify the columns by just adjusting the treecol attributes directly. the tree and view methods no longer take ids as
arguments when columns are used. instead, they use nsitreecolumns. for example, nsitreeview.getcellvalue() takes a row index and a nsitreecolumn as
arguments, whereas before it took a row index and a column id. to get a column in javascript: tree.columns.getcolumnfor(treecolelement); tree.columns.getnamedcolumn(treecolid); tree.columns.getcolumnat(index); you can also just use array syntax to get a col...
Adding Methods to XBL-defined Elements - Archive of obsolete content
en a binding is attached by changing the -moz-binding style property of an element. the existing binding will be removed, after its destructor is called. then, the new binding will be added in its place and its constructor invoked. the script for a constructor or destructor should be placed directly inside the appropriate tag. there should only be at most one of each per binding and they take no
arguments. here are some examples: <constructor> if (this.childnodes[0].getattribute("open") == "true"){ this.loadchildren(); } </constructor> <destructor action="savemyself(this);"/> the next section shows how to add event handlers to xbl-defined elements. « previousnext » ...
Features of a Window - Archive of obsolete content
rowsing context (window, <iframe> or tab) with the specified name. if the name doesn't exist, then a new window is opened and the specified resource is loaded into its browsing context.">window.open() function to open the second window. this function will return a reference to the newly opened window. you can use this reference to call functions of the other window. the open function takes three
arguments. the first is the url of the file you wish to open. the second is an internal name of the window. the third is a list of display flags. the flag 'chrome' is important to open the window as a chrome file. if you do not add the 'chrome' flag, the file will open up as the content in a browser window. for example: var mywin = window.open("chrome://findfile/content/findfile.xul", "findfile", "chrome...
Manipulating Lists - Archive of obsolete content
to the dom appendchild() function except that it takes a string label, and you do not have to worry about where to add it in the list structure. here is an example: example 1 : source view <script> function additem(){ document.getelementbyid('thelist').appenditem("thursday", "thu"); } </script> <listbox id="thelist"/> <button label="add" oncommand="additem();"/> the appenditem() takes two
arguments, the label, in this case 'thursday', and a value 'thu'. the two
arguments correspond to the label attribute and the value attribute on the listitem element. the value is used only as an extra optional value associated with an item which you might wish to use in a script. similarly, there is also an insertitemat() and a removeitemat() function which inserts a new item and removes an existing item...
More Event Handlers - Archive of obsolete content
on, the event object is examined and additional events are described. the event object every event handler is passed an event object. in the attribute form of the event handler, the event object is an implied argument to the script code which can be referred to using the name 'event'. in the addeventlistener form, the first argument passed to the listener function will be the event object. other
arguments can be passed to a listener function, if required. the event object has a number of properties which can be examined during an event. for a full list, see the reference. we already saw the event's target property in the last section. it holds a reference to the element where the event occurred. a similar property currenttarget holds the element that is currently having its event listeners handle...
Styling a Tree - Archive of obsolete content
r rdf-built trees, you can use the same syntax. however, you will often set the properties based on values in the datasource. setting properties for the custom view for trees with a custom view script, you can set properties by supplying the functions getrowproperties(), getcolumnproperties() and getcellproperties() in the view. these return information about an individual row, column and cell.
arguments to these functions indicate which row and/or column. prior to gecko 22 the last argument to each of these functions is a properties list which the view is expected to fill with a list of properties. the function getcolumnproperties() also supplies the corresponding treecol element for the column. getrowproperties : function(row,prop){} getcolumnproperties : function(column,columnelement,prop){}...
The Chrome URL - Archive of obsolete content
enter chrome urls anywhere normal urls can be used. you can even enter them directly into the url bar in a firefox browser window. if you enter the url mentioned above into the browser's address bar, you should see that window appear like a web page might do and for the most part will function as if it was a separate window. some dialog boxes may not work right, however, as they may be expecting
arguments to be supplied from the window that opened them. you will also see chrome urls without specified filenames, such as: chrome://browser/content/ in this case, only the package name and part is specified. this type of reference will automatically select an appropriate file from that right directory. for content, a file with the same name of the package and a xul extension is selected. in the above ...
Tree Selection - Archive of obsolete content
u can retrieve each block of contigous selections using the getrangecount() and getrangeat() functions. the first function returns the number of selection ranges there are. if only one value is selected, this value will be 1. you would then write a loop for the number of ranges, calling getrangeat() to get the actual indices of the start and end of the range. the getrangeat() function takes three
arguments. the first is the range index. the second is an object which will be filled in by the function with the index of the first selected item. the third argument is an object which will be filled in with the index of the last selected item. getrangeat example var start = new object(); var end = new object(); var numranges = tree.view.selection.getrangecount(); for (var t = 0; t < numranges; t...
Tree View Details - Archive of obsolete content
, we use the rowcountchanged function to inform the tree that some rows were added to the underlying data. the tree will then redraw the tree as needed and the result is that the child rows will appear inside the container. the various other functions implemented above such as getlevel and iscontainer are used by the tree to determine how to draw the tree. the rowcountchanged function takes two
arguments, the index where the first row was inserted and the number of rows to insert. in the code above we indicate that the starting row is the value of 'idx' plus one, which will be the first child under the parent. the tree will use this information and add space for the appropriate number of rows and push the rows afterwards down. make sure to pass the right number or the tree might redraw incorrectl...
Using the Editor from XUL - Archive of obsolete content
rimary" id="content-frame" src="about:blank" flex="1"/> the attribute type="content-primary" identifies this as the window content element, i.e. that which you get from window._content. having an id attribute, id="content-frame", allows us to find this element with document.getelementbyid("content-frame"), and to style it from css. editoronload() is called. it does some getting of window.
arguments (which is a way callers can pass parameters to new windows -- we use this to get the url to be loaded), then it calls editorstartup(), where the real work happens. it passes two parameters; the first indicates whether we want a plain text or html editor (pass text or html here), and the second is the <iframe> element on which we wish to create the editor. we could either pass document.geteleme...
browser - Archive of obsolete content
ype: boolean disables global history for the docshell attached to the browser while keeping session history active. disablesecurity type: boolean set this attribute to true to disable the security ui for this browser. omit this attribute off to enable it. droppedlinkhandler type: function this function is called when links are dropped to the browser element, with the following
arguments. droppedlinkhandler(event, uri, name) -- firefox 51 or older droppedlinkhandler(event, links) -- firefox 52 or newer event -- drop event, or null if no event is available uri -- uri string of the dropped link name -- name string of the dropped link links -- array of the dropped items with nsidroppedlinkitem interface homepage type: url this attribute allows you to set a ...
listbox - Archive of obsolete content
of the items. a select event is sent after the selection is made. selectitem( item ) return type: no return value deselects all of the currently selected items and selects the given item. a select event is sent after the selection is made. selectitemrange( startitem, enditem ) return type: no return value selects the items between the two items given as
arguments, including the start and end items. all other items are deselected. this method does nothing for single-selection list boxes. a select event is sent after the selection is made. timedselect( item, timeout ) return type: no return value selects the item specified by the argument item after the number of milliseconds given by the timeout argument. all other items are deselecte...
notificationbox - Archive of obsolete content
rity_warning_high priority_critical_low priority_critical_medium priority_critical_high priority_critical_block buttons : the buttons argument is an array of button descriptions. each description is an object with the following properties: accesskey - the accesskey to appear on the button callback - function to be called when the button is activated. this function is passed three
arguments: the <notification> the button is associated with the button description as passed to appendnotification. the element which was the target of the button press event. if the return value from this function is not true, then the notification is closed. the notification is also not closed if an error is thrown. label - the label to appear on the button popup - the id of a popup...
panel - Archive of obsolete content
popup is oriented depends on the direction of the anchor. position possible values for position are: before_start, before_end, after_start, after_end, start_before, start_after, end_before, end_after, overlap, and after_pointer. check positioning of the popup guide for a precise description of the effect of the different values. x, y for an anchored popup, the x and y
arguments may be used to offset the popup from its anchored position by some number, measured in css pixels. an unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. in this case, the position and attributesoverride
arguments are ignored. iscontextmenu the iscontextmenu argument should be true for context menus and f...
promptBox - Archive of obsolete content
.alert() method or the nsiprompt interface instead. see using tab-modal prompts for details. method overview nsidomelement appendprompt(args, onclosecallback); void removeprompt(nsidomelement aprompt); nodelist listprompts(nsidomelement aprompt); methods appendprompt() creates a new prompt, adding it to the tab. nsidomelement appendprompt( args, onclosecallback ); parameters args
arguments for the prompt. onclosecallback the callback routine to be called when the prompt is closed. return value an nsidomelement object representing the new prompt. removeprompt() removes an existing prompt. void removeprompt( nsidomelement aprompt ); parameters aprompt the prompt to dispose of. listprompts() returns a list of all the prompts on the tabbrowser. nodelist listprompts( nsidomeleme...
richlistbox - Archive of obsolete content
the items. a select event is sent after the selection is made. selectitem( item ) return type: no return value deselects all of the currently selected items and selects the given item. a select event is sent after the selection is made. selectitemrange( startitem, enditem ) return type: no return value selects the items between the two items given as
arguments, including the start and end items. all other items are deselected. this method does nothing for single-selection list boxes. a select event is sent after the selection is made. timedselect( item, timeout ) return type: no return value selects the item specified by the argument item after the number of milliseconds given by the timeout argument. all other items are deselect...
textbox - Archive of obsolete content
saction list (gecko 1.9). select() return type: no return value selects all the text in the textbox. setselectionrange( start, end ) return type: no return value sets the selected portion of the textbox, where the start argument is the index of the first character to select and the end argument is the index of the character after the selection. set both
arguments to the same value to move the cursor to the corresponding position without selecting text. inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), getelementsbyattribute, getelementsbyattribute...
XULRunner tips - Archive of obsolete content
with a precompiled xulrunner: use xulrunner-stub.exe to start your application but rename it into myapplication.exe. with xulrunner 1.9 this will make the desired name appear in the task bar (not with xulrunner 1.8 however). your application's icon can also be added to this executable with a tool like resource hacker. to change icon of specific window, see window icons. reading command line
arguments see chrome: command line and xulrunner:commandline. command line
arguments are handled via nsicommandlinehandler. preferences needed for file download dialogs to use the unknown-content-type and file-downloads dialogs from a <browser> element, you need to add the following prefs: pref("browser.download.usedownloaddir", true); pref("browser.download.folderlist", 0); pref("browser.download.mana...
Mozprocess - Archive of obsolete content
e), along with any child processes, on windows, os x, and linux. mozprocess utilizes and extends subprocess.popen to these ends. api mozprocess.processhandler:processhandler is the central exposed api for mozprocess. processhandler utilizes a contained subclass of subprocess.popen, process, which does the brunt of the process management. ...
Mozilla release FAQ - Archive of obsolete content
y to happen in nspr, as it still uses the classic build system. it's doubtful that this will happen in the main tree. /usr/include/stdlib.h:196: previous declaration of `seed48' see section 3.7 nothing looks much like an error, except something returned error status your compiler has a switch (probably) that prints everything it's doing (i.e. programs spawned), which might help you find out what
arguments it's passing to ld, or whatever, and thus perhaps enlighten you as to the problem. on gcc, try gcc -v (rest of command line). how long will mozilla take to build? a long time, but this will depend quite a bit on your system. ram will probably be the bottleneck in most cases, at least until you are well over 128m ram. here are a few representative systems (please send your specs in to me) removed ...
Tamarin Tracing Build Documentation - Archive of obsolete content
mercurial at tamarin tracing. use the following command to create a copy of the tamarin repository: $ hg clone http://hg.mozilla.org/tamarin-tracing tamarin-tracing building tamarin building tamarin will create all the libraries for the avmplus and garbage collector (mmgc), and create a standalone executable, avmshell, for executing files in the abc file format. running avmshell without any
arguments will list the available options. note that additional command-line
arguments are only available in the debug configuration. the tamarin codebase contains a cross-platform build system for mozilla developers. the cross-platform build system is used for daily automated build testing so it is the most reliable system. the tamarin codebase has the ability to build additional code which supports debug...
Expression closures - Archive of obsolete content
ions. expression closures are a shorthand function syntax for writing simple functions. syntax function [name]([param1[, param2[, ..., paramn]]]) expression parameters name the function name. can be omitted, in which case the function is anonymous. the name is only local to the function body. paramn the name of an argument to be passed to the function. a function can have up to 255
arguments. expression the expression which comprise the body of the function. description this addition is nothing more than a shorthand for writing simple functions, giving the language something similar to a typical lambda notation. javascript 1.7 and older: function(x) { return x * x; } javascript 1.8: function(x) x * x this syntax allows you to leave off the braces and 'return' statement - ma...
Legacy generator function expression - Archive of obsolete content
on a legacy generator, the function body should contain at least one yield expression. syntax function [name]([param1[, param2[, ..., paramn]]]) { statements } parameters name the function name. can be omitted, in which case the function is anonymous. the name is only local to the function body. paramn the name of an argument to be passed to the function. a function can have up to 255
arguments. statements the statements which comprise the body of the function. this should contain at least one yield expression. description an overview of the usage is available on the iterators and generators page. ...
Legacy generator function - Archive of obsolete content
functions with the specified parameters. you can also define functions using the function constructor with functionbody and at least one yield expression, and a legacy generator function expression. syntax function name([param,[, param,[..., param]]]) { [statements] } name the function name. param the name of an argument to be passed to the function. a function can have up to 255
arguments. statements the statements which comprise the body of the function. this should contain at least one yield expression. description an overview of the usage is available on the iterators and generators page. ...
New in JavaScript 1.2 - Archive of obsolete content
<script language="javascript1.1"> <!-- javascript for navigator 3.0. --> <script language="javascript1.2"> <!-- javascript for navigator 4.0. --> new features in javascript 1.2 new objects you can create objects using literal notation (inspired by dictionary literal syntax from python 1.x). arrays can now be created using literal notation (inspired by list literal syntax from python 1.x). ...
New in JavaScript 1.6 - Archive of obsolete content
pt for xml (e4x) for creating and processing xml content within javascript has been added. see for details. array.prototype.indexof() array.prototype.lastindexof() array.prototype.every() array.prototype.filter() array.prototype.foreach() array.prototype.map() array.prototype.some() array generics string generics for each...in changed functionality in javascript 1.6 a bug in which
arguments[n] cannot be set if n is greater than the number of formal or actual parameters has been fixed. ...
New in JavaScript 1.8.5 - Archive of obsolete content
array.isarray() checks if a variable is an array. bug 510537 date.prototype.tojson() returns a json format string for a date object. function.prototype.bind() creates a new function that, when called, itself calls this function in the context provided (with a given sequence of
arguments). bug 429507 new ecmascript5 features get and set operators now allows the identifier to be numeric or a string. bug 520696 function.apply() can accept any array-like object as the
arguments list, instead of only true arrays. strict mode support array.tostring() now works even on non-arrays by eith...
ECMAScript 2015 support in Mozilla - Archive of obsolete content
efox 27) use symbol.iterator property (firefox 36) functions rest parameters (firefox 15) default parameters (firefox 15) parameters without defaults after default parameters (firefox 26) destructured parameters with default value assignment (firefox 41) arrow functions (firefox 22) generator function (firefox 26) yield (firefox 26) yield* (firefox 27)
arguments[@@iterator] (firefox 46) other features binary and octal numeric literals (firefox 25) template strings (firefox 34) object initializer: shorthand property names (firefox 33) object initializer: computed property names (firefox 34) object initializer: shorthand method names (firefox 34) ...
Archived JavaScript Reference - Archive of obsolete content
this property has been removed and no longer works.array comprehensionsthe array comprehension syntax was a javascript expression which allowed you to quickly assemble a new array based on an existing one. however, it has been removed from the standard and the firefox implementation. do not use it!array.observe()the array.observe() method was used for asynchronously observing changes to arrays, similar to object.observe() for objects. it provided a stream of changes in order of occurrence. ...
LiveConnect Overview - Archive of obsolete content
to the newinstance method to create an array. // javascript 1.3 var theclass = java.lang.class.forname("java.lang.string"); var thearray = java.lang.reflect.array.newinstance(theclass, 5); in javascript 1.4 and later, you can pass a javaclass object directly to a method, as shown in the following example: // javascript 1.4 var thearray = java.lang.reflect.array.newinstance(java.lang.string, 5);
arguments of type char in javascript 1.4 and later, you can pass a one-character string to a java method which requires an argument of type char. for example, you can pass the string "h" to the character constructor as follows: var c = new java.lang.character("h"); in javascript 1.3 and earlier, you must pass such methods an integer which corresponds to the unicode value of the character. for example, the...
JSException - Archive of obsolete content
l message or other information for the exception. the getwrappedexception method was not available. jsexception constructors, deprecated in javascript 1.4, constructs a jsexception object with an optional detail message. declaration 1. public jsexception() 2. public jsexception(string s) 3. public jsexception(string s, string filename, int lineno, string source, int tokenindex)
arguments s the detail message. filename the url of the file where the error occurred, if possible. lineno the line number of the file, if possible. source the string containing the javascript code being evaluated. tokenindex the index into the source string where the error occurred. getwrappedexception instance method getwrappedexception. declaration public object getwrap...
forEach - Archive of obsolete content
while retaining the rest of the document. feel free to alter the text as english is not my mother tongue and i'm more concerned with the code quality that the english grammar ;-s dotnetcarpenter 30 june 2012 <hr> the compatibility section goes to extraordinary lengths in providing a foreach implementation. a much more sane approach would be to count on the implementation to throw errors if wrong
arguments are provided and implement this in fewer lines of code. i've removed the lengthy example, while still linking to it and provided a much simpler and leaner implementation. dotnetcarpenter 30 june 2012 <hr> i have released the write access restriction, but i will be watching changes closely. jswisher 01 october 2011 <hr> there is some mistype in array.prototype.foreach: kvalue = o[ pk ]; should be ...
Window.importDialog() - Archive of obsolete content
is no longer supported; for that reason, this function is obsolete and should never be used. summary because opening windows on mobile isn't necessarily appropriate, the firefox mobile team designed the importdialog() method to replace window.opendialog(). instead of opening a new window, it merges the specified xul dialog into the main window. syntax newdialog = importdialog(aparent, asrc, a
arguments) newdialog the opened window aparent the dialog's parent; can be null. asrc the chrome url of the xul dialog. a
arguments a javascript object containing data to pass to the dialog. example var dialog = importdialog(null, "chrome://myextension/content/dialog.xul", myobject); notes the xul passed to importdialog() is very similar to xul passed to window.opendialog(), with some limit...
Constructor - MDN Web Docs Glossary: Definitions of Web-related terms
s object and can provide access to its private information. the concept of a constructor can be applied to most object-oriented programming languages. essentially, a constructor in javascript is usually declared at the instance of a class. syntax // this is a generic default constructor class default function default() { } // this is an overloaded constructor class overloaded // with parameter
arguments function overloaded(arg1, arg2, ...,argn){ } to call the constructor of the class in javascript, use a new operator to assign a new object reference to a variable. function default() { } // a new reference of a default object assigned to a // local variable defaultreference var defaultreference = new default(); learn more general knowledge constructor on wikipedia technical referenc...
Function - MDN Web Docs Glossary: Definitions of Web-related terms
a function in javascript is also an object. a function name is an identifier included as part of a function declaration or function expression. the function name's scope depends on whether the function name is a declaration or expression. different types of functions an anonymous function is a function without a function name. ...
undefined - MDN Web Docs Glossary: Definitions of Web-related terms
undefined is a primitive value automatically assigned to variables that have just been declared, or to formal
arguments for which there are no actual
arguments. example var x; //create a variable but assign it no value console.log("x's value is", x) //logs "x's value is undefined" learn more general knowledge undefined value on wikipedia technical reference javascript data types and data structures ...
Introducing asynchronous JavaScript - Learn web development
not yet available. instead, you need your code to wait until the response is returned before it tries to do anything else to it. there are two main types of asynchronous code style you'll come across in javascript code, old-style callbacks and newer promise-style code. in the below sections we'll review each of these in turn. async callbacks async callbacks are functions that are specified as
arguments when calling a function which will start executing code in the background. when the background code finishes running, it calls the callback function to let you know the work is done, or to let you know that something of interest has happened. using callbacks is slightly old-fashioned now, but you'll still see them in use in a number of older-but-still-commonly-used apis. an example of an async c...
Functions — reusable blocks of code - Learn web development
n, this looks something like this: mybutton.onclick = function() { alert('hello'); // i can put as much code // inside here as i want } function parameters some functions require parameters to be specified when you are invoking them — these are values that need to be included inside the function parentheses, which it needs to do its job properly. note: parameters are sometimes called
arguments, properties, or even attributes. as an example, the browser's built-in math.random() function doesn't require any parameters. when called, it always returns a random number between 0 and 1: let mynumber = math.random(); the browser's built-in string replace() function however needs two parameters — the substring to find in the main string, and the substring to replace that string with: let...
Drawing graphics - Learn web development
e whole 3d world we are trying to display. next, we need a camera so we can see the scene. in 3d imagery terms, the camera represents a viewer's position in the world. to create a camera, add the following lines next: const camera = new three.perspectivecamera(75, window.innerwidth / window.innerheight, 0.1, 1000); camera.position.z = 5; the perspectivecamera() constructor takes four
arguments: the field of view: how wide the area in front of the camera is that should be visible onscreen, in degrees. the aspect ratio: usually, this is the ratio of the scene's width divided by the scene's height. using another value will distort the scene (which might be what you want, but usually isn't). the near plane: how close to the camera objects can be before we stop rendering them t...
Manipulating documents - Learn web development
on your document, which we'll look at now. delete the previous five lines you added to the javascript. add the following inside your html <head>: <style> .highlight { color: white; background-color: black; padding: 10px; width: 250px; text-align: center; } </style> now we'll turn to a very useful method for general html manipulation — element.setattribute() — this takes two
arguments, the attribute you want to set on the element, and the value you want to set it to. in this case we will set a class name of highlight on our paragraph: para.setattribute('class', 'highlight'); refresh your page, and you'll see no change — the css is still applied to the paragraph, but this time by giving it a class that is selected by our css rule, not as inline css styles. which method...
Solve common problems in your JavaScript code - Learn web development
over the members in an object? how do you iterate over the members of an object nested inside an array? intermediate use cases functions how do you find functions in the browser? what is the difference between a function and a method? how do you create your own functions? how do you run (call, or invoke) a function? what is an anonymous function? how do you specify parameters (or
arguments) when invoking a function? what is function scope? what are return values, and how do you use them? objects how do you create an object? what is dot notation? what is bracket notation? how do you get and set the methods and properties of an object? what is this, in the context of an object? what is object-oriented programming? what are constructors and instances, and how do you creat...
Object building practice - Learn web development
s can be gotten from the window.innerwidth and window.innerheight properties). note that we are chaining multiple assignments together, to get the variables all set quicker — this is perfectly ok. the last bit of the initial script looks as follows: function random(min, max) { const num = math.floor(math.random() * (max - min + 1)) + min; return num; } this function takes two numbers as
arguments, and returns a random number in the range between the two. modeling a ball in our program our program will feature lots of balls bouncing around the screen. since these balls will all behave in the same way, it makes sense to represent them with an object. let's start by adding the following constructor to the bottom of our code. function ball(x, y, velx, vely, color, size) { this.x = x; t...
Getting started with React - Learn web development
ra-pwa serviceworker.unregister(); as with app.js, the file starts by importing all the js modules and other assets it needs to run. src/index.css holds global styles that are applied to our whole app. we can also see our app component imported here; it is made available for import thanks to the export statement at the bottom of app.js. line 7 calls react’s reactdom.render() function with two
arguments: the component we want to render, <app /> in this case. the dom element inside which we want the component to be rendered, in this case the element with an id of root. if you look inside public/index.html, you'll see that this is a <div> element just inside the <body>. all of this tells react that we want to render our react application with the app component as the root, or first component...
Vue conditional rendering: editing existing todos - Learn web development
an itemedited() method to our todoitem component's methods. this method should take the new item label as an argument, emit an itemedited event to the parent component, and set isediting to false. add it now, below your existing methods: itemedited(newlabel) { this.$emit('item-edited', newlabel); this.isediting = false; } next, we'll need an editcancelled() method. this method will take no
arguments and just serve to set isediting back to false. add this method below the previous one: editcancelled() { this.isediting = false; } last for this section, we'll add event handlers for the events emitted by the todoitemeditform component, and attach the appropriate methods to each event. update your <to-do-item-edit-form></to-do-item-edit-form> call to look like so: <to-do-item-edit-form v-e...
Focus management with Vue refs - Learn web development
= true; } if you activate the "edit" button at this point, you should see an html <button> element referenced in your console. vue's $nexttick() method we want to set focus on the "edit" button when a user saves or cancels their edit. to do that, we need to handle focus in the todoitem component’s itemedited() and editcancelled() methods. for convenience, create a new method which takes no
arguments called focusoneditbutton(). inside it, assign your ref to a variable, and then call the focus() method on the ref. focusoneditbutton() { const editbuttonref = this.$refs.editbutton; editbuttonref.focus(); } next, add a call to this.focusoneditbutton() at the end of the itemedited() and editcancelled() methods: itemedited(newitemname) { this.$emit("item-edited", newitemname); this.isedi...
Command line crash course - Learn web development
or even before publishing your code (with additional tooling that we’ll see later on in the module). once you've installed node, open up the terminal and run the following command to install prettier: npm install --global prettier once the command has finished running, the prettier tool is now available in your terminal, at any location in your file system. running the command without any
arguments, as with many other commands, will offer up usage and help information. try this now: prettier your output should look something like this: usage: prettier [options] [file/glob ...] by default, output is written to stdout. stdin is read if it is piped to prettier and no files are given. … it's always worth at the very least skimming over the usage information, even if it is long. it'll he...
Deploying our app - Learn web development
e. we're going to add the build command to our package.json file as an npm script, so that the command npm run build will trigger the build process. this step isn't necessary, but it is a good best practice to get into the habit of setting up — across all our projects, we can then rely on npm run build to always do the complete build step, without needing to remember the specific build command
arguments for each project. open the package.json file in your project's root directory, and find the scripts property. we'll add a build command that we can run to build our code. add the following line to your project now: "scripts": { ... "build": "parcel build src/index.html" } note: if the scripts property already has a command inside it, put a comma at the end of it. keep the...
Adding a new event
nal event class if you're in case 1 (a simple dom event), you can skip this section. add event messages you need to add event messages which are stored by widgetevent::message. all messages are defined by macro in "messages" section of basicevents.h. define event class name you need to add an event class name in eventclasslist.h. use ns_event_class macro for adding it. the macro takes two
arguments, aprefix and aname. aprefix defines prefix of event class name which should be widget or internal. widget should be used if the event class is dispatched from widget. otherwise, i.e., the event class is just used for internal event class of a dom event class, it should be internal. aname defines its event class specific name and it must end with "event" or "eventbase". the latter is used only f...
Creating JavaScript callbacks in components
ace is "marked" with the function attribute. see it here. the function attribute tells the xpconnect machinery to treat the javascript function as if it was an implementation of the callback interface. note, that since the javascript function is a single method, this magic only works for callback interfaces with a single method, like nsidomeventlistener. the javascript function is passed the same
arguments as defined by the callback method. so we could convert the example above to accept javascript functions in place of the stringparserobserver by making the following changes: [scriptable, function, uuid(...)] interface stringparserobserver : nsisupports { void onword(string word); }; [scriptable, uuid(...)] interface stringparser { void parse(string data); void addobserver(stringparserobse...
Debugging on Windows
al from the drop down list. "executable for debug session:" should show the executable you are debugging. if it is empty or incorrect, use the arrow button and select browse... to locate the executable. command line parameters and environment variables vc++ 6.0: to change or set the command line options, go to project > settings..., debug tab and select general from the drop down list. "program
arguments:" should show the options. some common options would be the url of the file you want the browser to open as soon as it starts, starting the profile manager, or selecting a profile. you can also redirect the console output to a file (by adding "> filename.txt" for example, without the quotes). in vc 7 and 8 this option is called project > properties > debugging > command
arguments. vc 8 also all...
HTTP logging
ne appropriately.) reproduce whatever problem you're trying to debug. quit firefox and look for the generated log.txt log files on your desktop. note: the generated log file uses unix-style line endings. older editors may have problems with this, but if you're using an even reasonably modern mac os x application to view the log, you won't have any problems. start logging using command line
arguments since firefox 61 it's possible to start logging in a bit simpler way than setting environment variables: using command line
arguments. here is an example for the windows platform, on other platforms we accept the same form of the
arguments: if firefox is already running, exit out of it. open a command prompt. on windows xp, you can find the "run..." command in the start menu's "all programs...
Overview of Mozilla embedding APIs
nsmemory::realloc nsmemory::free this helper class provides static accessors to the global nsmemory service. ns_getglobalcomponentmanager this function returns an instance of the component manager service. ns_convertasciitoucs2 this is a helper class which converts an ascii string into a ucs2 string. typically, instances of this class are stack allocated, and wrap ascii
arguments which must be converted into ucs2. do_queryinterface this is a helper class which works in conjunction with nscomptr to perform a simplified call to nsisupports::queryinterface(...) with a typesafe assignment. do_getinterface this function simplfies retrieving interfaces via the nsiinterfacerequestor::getinterface(...) method. using this function, one can use nsisupports instances and sti...
PBackground
n in the content process because it has restricted privileges. instead, these apis must ask the chrome process to do something on their behalf via an ipdl protocol. this has lead to a rather awkward pattern seen in some parts of the gecko codebase, looking something like this (try searching for geckoprocesstype_default in dxr): if (xre_getprocesstype() == geckoprocesstype_default) { dothething(
arguments); } else { mipdlprotocol->senddothething(
arguments); } this can get unwieldy very quickly, so a better solution was needed. pbackground pbackground exists to solve such problems. it connects a designated "background" thread in the chrome process to any other thread in any other process. pbackground allows us to bypass the chrome process's main thread if used from the content process' main...
Assert.jsm
two numbers with the <= operator. undefined lessorequal( lhs, rhs, message ); parameters lhs the left hand side of the operator rhs the right hand side of the operator message short explanation of the expected result setreporter() set a custom assertion report handler function. undefined setreporter( reporterfunc ); parameters reporterfunc reporter handler function.
arguments passed in to this function are: err an error object when the assertion failed or null when it passed message message describing the assertion stack stack trace of the assertion function. report() all of the aforementioned functions must throw an assertionerror when a corresponding condition is not met, with a message that may be undefined if not provided. all assertion metho...
OS.File.Info
roduce the ability to check whether field unixowner appears in os.file.info.prototype, which will make it possible to write faster code. global object os.file.info methods object tomsg(in os.file.info value) os.file.tomsg convert an instance of os.file.info to a form that can be serialized and transmitted between threads or processes. object tomsg( in os.file.info value )
arguments returns an object with the same fields as value but that may be serialized and transmitted between threads or processes. value an instance of os.file.info. instances of os.file.info cross-platform attributes isdir true if the file is a directory, false otherwise. issymlink true if the false is a symbolic link, false otherwise. (as of firefox 38 this is always tru...
Promise
] function onfulfill, [optional] function onreject); promise catch([optional] function onreject); constructor creates a new promise, initially in the pending state, and provides references to the resolving functions that can be used to change its state. new promise(executor); parameters executor this function is invoked immediately with the resolving functions as its two
arguments: executor(resolve, reject); the constructor will not return until the executor has completed. the resolving functions can be used at any time, before or after the executor has completed, to control the final state of the promise. if the executor throws an exception, its value will be passed to the reject resolving function. resolving functions resolve() fulfills the associated promise ...
SourceMap.jsm
ode.prototype.tostring() return the string representation of this source node. walks over the tree and concatenates all the various snippets together to one string. sourcenode.prototype.tostringwithsourcemap(startofsourcemap) returns the string representation of this tree of source nodes, plus a sourcemapgenerator which contains all the mappings between the generated and original sources. the
arguments are the same as those to new sourcemapgenerator. ...
WebRequest.jsm
specific stage in executing a web request: onbeforerequest onbeforesendheaders onsendheaders onheadersreceived onresponsestarted oncompleted each of these objects defines two functions: addlistener(callback, filter, opt_extrainfospec) removelistener(callback) adding listeners use addlistener to add a listener to a particular event. it takes one mandatory argument and two optional
arguments, as detailed below. name type description callback function the callback argument is a function to be called when the event is triggered. it's passed an object whose structure will vary depending on the event you're listening to: see the event-specific documentation for details. filter object the optional filter argument is used to r...
XPCOMUtils.jsm
a "lazy getter" provides an additional optimization: the value is calculated the first time the getter is called, and is then cached (or memoized), so subsequent accesses return the cached value without recalculating it. this means that you shouldn't use a lazy getter for a property whose value you expect to change, because the getter will not recalculate the value. definelazygetter takes three
arguments: the object to define the property on the name of the property defined the getter function itself, which returns the value and which will be called just once, the first time code tries to access the property. example for this is seen at bottom of this page here. function definelazygetter( aobject, aname, alambda ); parameters aobject the object into which to add the new lazy g...
L10n Checks
up.py install or, if you're on windows: $ hg clone http://hg.mozilla.org/users/akalla_aviary.pl/silme-patched/ $ cd silme-patched/ $ python setup.py install running it mercurial source (source) mode l10n checks gathers the directories to compare from an ini file, usually found in $app/locales/l10n.ini. you pass both the path to the ini file and the parent directory of the localizations as first
arguments, followed by the locale codes of the locales you want to compare. if you want to test the localization for de, run: check-l10n-completeness browser/locales/l10n.ini ../l10n/ de add-ons (xpi) mode l10n checks gathers the locales to compare from the chrome.manifest file inside the xpi file. you pass the path to the xpi file (optionally) followed by the locale codes of the locales you want to compa...
gettext
and plural forms of a string. to take advantage of this functionality, you need to use a different keyword (i.e. different gettext function name) for string which are supposed to support plurals. for instance, in php the default keyword for regular messages is gettext() and _(). for messages with plural support, the default keyword is ngettext(). a definition of a string with plurals takes three
arguments: the singular form of the english string, the plural form of the english string, and the number basing on which the function will return the correct (singular or plural) form of the string. consider the following code snippet: <?php $num = 1; printf(ngettext("%d user likes this.", "%d users like this.", $num), $num); ?> depending on the value of the $num variable, this code will either ...
DMD
sh reporter symbols for your build -- as tryserver builds do -- you can use this script instead: clone the whole repo, edit the paths at the top of resymbolicate_dmd.py and run it.) the simplest way to do this is to just run the dmd.py script on your dmd report while your working directory is $objdir/dist/bin. this will allow the local libraries to be found and used. if you invoke dmd.py without
arguments you will get output appropriate for the mode in which dmd was invoked. "dark matter" mode output for "dark matter" mode, dmd.py's output describes how the live heap blocks are covered by memory reports. this output is broken into multiple sections. "invocation". this tells you how dmd was invoked, i.e. what options were used. "twice-reported stack trace records". this tells you which heap b...
Memory reporting
foobarsizes* asizes) const { asizes->mfoo += ...; asizes->mbar += ...; } note the add prefix that makes this incrementing behaviour clear. obviously, if you increment you have to zero the values at some point. when using a struct, its constructor is the obvious place for this. you could even put the nsmallocsizeoffun in foobarsizes to reduce the number of
arguments. sometimes it's difficult and/or not worth measuring every member of an object of in a foo::sizeofexcludingthis method. this is ok, but it's worth adding a comment explaining this to the method. occasionally you do want to compute sizes analytically instead of using moz_malloc_size_of. in that case, use computedsizeof as the prefix for the function name. it's important that no memory is ...
Profiling with Xperf
xperf is part of the microsoft windows performance toolkit, and has functionality similar to that of shark, oprofile, and (for some things) dtrace/instruments. for stack walking, windows vista or higher is required; i haven't tested it at all on xp. this page applies to xperf version 4.8.7701 or newer. to see your xperf version, either run 'xperf' on a command line with no
arguments, or start 'xperfview' and look at help -> about performance analyzer. (note that it's not the first version number in the about window; that's the windows version.) if you have an older version, you will experience bugs, especially around symbol loading for local builds. installation for all versions, the tools are part of the latest windows 7 sdk (sdk version 7.1). use the web installer to install at least...
Profile Manager
profile in the main window, and hit the "start firefox" button: firefox will be launched with that profile, and profile manager will terminate. the version of firefox which will be launched is indicated in the "firefox version" dropdown in the launch options box: there are several additional launch options available for firefox. these cause firefox to be launched with various command-line
arguments. see command line options for a description of these. launch option command line argument run firefox in offline mode -offline run firefox in safe mode -safe-mode start firefox with a console -console start new instance -no-remote note: it isn't possible to start a second instance of firefox without passing it the -no-remote...
Installing JSHydra
dermonkey spidermonkey is part of the build process, but since jshydra will get the code if required, you do not need to worry about obtaining the right version of spidermonkey. building jshydra jshydra requires, as part of its build process, spidermonkey. by default, the configure script will obtain a known working copy of spidermonkey; it is possible via the --moz-src and --moz-obj configure
arguments to tell jshydra to use existing copies of the source and build. cd $home/jshydra hg clone http://hg.mozilla.org/users/pidgeot18_gmail.com/jshydra/ cd jshydra ./configure make # run jshydra tests make check processing input files jshydra requires the files it processes to be correct js files. converting html, xul, or xbl files into a readable js equivalent is a work in progress, as is account...
L20n Javascript API
function) register a function which will be used to negotiate the locales supported by the context instance. if you don't call this function, l20n will use the built-in intl.prioritizelocales negotiator. ctx.registerlocalenegotiator(function(available, requested, deflocale) { return intl.prioritizelocales(available, requested, deflocale); }); negotiator is a function which takes the following
arguments: available - all locales available to the context instance, requested - locales preferred by the user, deflocale - the default locale to be used as the ultimate fallback, callback - the function to call when the negotiation completes (useful for asynchronous negotiators). it must return an array which is the final fallback chain of locales, or if the negotiation is asynchronous, it must r...
NSPR Poll Method
type of the poll method is print16 poll_method(prfiledesc *fd, print16 in_flags, print16 *out_flags); the purpose of the poll method is to allow a layer to modify that flags that will ultimately be used in the call to the underlying network transport's select (or equivalent) function, and to indicate that a layer is already able to make progress in the manner suggested by the polling flags. the
arguments and return value of the poll method are described below. in_flags [input argument] the in_flags argument specifies the events at the top layer of the i/o layer stack that the caller is interested in. for pr_recv, you should pass pr_poll_read as the in_flags argument to the poll method for pr_send, you should pass pr_poll_write as the in_flags argument to the poll method out_flags [output ...
Interval Timing
ng intervals of fewer than approximately 6 hours. this chapter describes printervaltime and the functions that allow you to use it for timing purposes: interval time type and constants interval functions interval time type and constants all timed functions in nspr require a parameter that depicts the amount of time allowed to elapse before the operation is declared failed. the type of such
arguments is printervaltime. such parameters are common in nspr functions such as those used for i/o operations and operations on condition variables. nspr 2.0 provides interval times that are efficient in terms of performance and storage requirements. conceptually, they are based on free-running counters that increment at a fixed rate without possibility of outside influence (as might be observed if one ...
PLHashComparator
s a function type that compares two values of an unspecified type. it returns a nonzero value if the two values are equal, and 0 if the two values are not equal. plhashcomparator defines the meaning of equality for the unspecified type. for convenience, two comparator functions are provided. pl_comparestrings compare two character strings using strcmp. pl_comparevalues compares the values of the
arguments v1 and v2 numerically. remark the return value of plhashcomparator functions should be of type prbool. see also pl_comparestrings, pl_comparevalues ...
PL_NewHashTable
of entries. allocops a pointer to a plhashallocops structure that must exist throughout the lifetime of the new hash table. allocpriv passed as the first argument (pool). returns the new hash table. description pl_newhashtable creates a new hash table. the table has at least 16 buckets. you can pass a value of 0 as numbuckets to create the default number of buckets in the new table. the
arguments keycompare and valuecompare are functions of type plhashcomparator that the hash table library functions use to compare the keys and the values of entries. the argument allocops points to a plhashallocops structure that must exist throughout the lifetime of the new hash table. the hash table library functions do not make a copy of this structure. when the allocation functions in allocops are inv...
PRBool
boolean value. syntax #include <prtypes.h> typedef enum { pr_false = 0, pr_true = 1 } prbool; description wherever possible, do not use prbool in mozilla c++ code. use standard c++ bool instead. otherwise, use prbool for variables and parameter types. use pr_false and pr_true for clarity of target type in assignments and actual
arguments. use if (bool), while (!bool), (bool) ? x : y, and so on to test boolean values, just as you would c int-valued conditions. ...
PRThreadState
nclude <prthread.h> typedef enum prthreadstate { pr_joinable_thread, pr_unjoinable_thread } prthreadstate; enumerators pr_unjoinable_thread thread termination happens implicitly when the thread returns from the root function. the time of release of the resources assigned to the thread cannot be determined in advance. threads created with a pr_unjoinable_thread state cannot be used as
arguments to pr_jointhread. pr_joinable_thread joinable thread references remain valid after they have returned from their root function until pr_jointhread is called. this approach facilitates management of the process' critical resources. description a thread is a critical resource and must be managed. the lifetime of a thread extends from the time it is created to the time it returns from its root...
PR_Assert
syntax #include <prlog.h> void pr_assert ( const char *s, const char *file, printn ln); parameters the function has these parameters: s a string to be displayed in the log. file the file name of the compilation unit containing this function call. ln the line number within the specified file of this function call. returns nothing description this function displays data in the log. normally an application would not call this function directly; use pr_assert instead. ...
PR_LOG
le values are: pr_log_none = 0 pr_log_always = 1 pr_log_error = 2 pr_log_warning = 3 pr_log_debug = 4 pr_log_notice = pr_log_debug pr_log_warn = pr_log_warning pr_log_min = pr_log_debug pr_log_max = pr_log_debug _args a variable length argument list, as if to printf. returns nothing description this macro formats the specified
arguments and writes the output to the log file, if logging is enabled for the specified module and level. for a description of formatting and format strings, see "formatted printing". for an example of using conditional logging, see use example. this macro compiles to nothing if compile-time options are not specified to enable logging. ...
sample2
_false; prbool sigverify = pr_false; const char *headerfilename = null; const char *encryptedfilename = null; const char *infilename = null; const char *outfilename = null; char *certreqfilename = null; char *certfilename = null; const char *noisefilename = null; pk11slotinfo *slot = null; char * progname = strrchr(argv[0], '/'); progname = progname ? ...
nss tech note1
of the two decoders, before outlining their differences. the main non-streaming apis for these two decoders have an identical prototype : secstatus sec_asn1decodeitem(prarenapool *pool, void *dest, const sec_asn1template *t, secitem *item); secstatus sec_quickderdecodeitem(prarenapool* arena, void* dest, const sec_asn1template* templateentry, secitem* src); here is a description of the
arguments : secitem* src† is a structure containing a pointer to the binary data to be decoded, as well as its size. const sec_asn1template* templateentry is a pointer to one or more decoder templates. the number of required templates is determined by the type of the first template.when multiple templates are required, the pointer must point to a null-terminated array of templates. the syntax of ...
nss tech note8
vate header file. there was no api function by which client programs could set these values. however since nss was delivered as archive libraries, client programs merely declared these two variables for themselves, and then were able to alter those variables directly. for server programs, the function for initializing the server session cache would set these two variables according to two of the
arguments to that function. so, ssl protocol code that wanted to cache a sid would do these steps, whether for client or for server: for ssl2: sid->lastaccesstime = sid->creationtime = ssl_time(); sid->expirationtime = sid->creationtime + ssl_sid_timeout; (*ss->sec.cache)(sid); for ssl3: sid->lastaccesstime = sid->creationtime = ssl_time(); sid->expirationtime = sid->creationtime + ss...
Python binding for NSS
la.org/security/python-nss/releases/pynss_release_0_12_0/src/ change log major new enhancement is additon of pkcs12 support and algorithmid's. setup.py build enhancements now searches for the nss and nspr header files rather than hardcoding their location. this makes building friendlier on other systems (i.e. debian) now takes optional command line
arguments, -d or --debug will turn on debug options during the build. fix reference counting bug in pk11_password_callback() which contributed to nss not being able to shutdown due to resources still in use. add utf-8 support to ssl.config_server_session_id_cache() added unit tests for cipher, digest, client_server. all unittests now run, added test/run_tests to invoke full...
FC_Finalize
preserved); parameters fc_finalize has one parameter: preserved must be null description fc_finalize shuts down the nss cryptographic module in the fips mode of operation. if the library is not initialized, it does nothing. the preserved argument is not used and must be null. return value fc_finalize always returns ckr_ok. fc_finalize should check the preserved argument and return ckr_
arguments_bad if preserved is not null. fc_finalize should return ckr_cryptoki_not_initialized if the library is not initialized. examples #include <assert.h> ck_function_list_ptr pfunctionlist; ck_rv crv; crv = fc_getfunctionlist(&pfunctionlist); assert(crv == ckr_ok); ... /* invoke fc_finalize as pfunctionlist->c_finalize */ crv = pfunctionlist->c_finalize(null); see also fc_initialize, nsc_i...
FC_GetInfo
ydescription: description of the library, "nss internal crypto services", padded with spaces to 32 characters and not null-terminated. libraryversion: pkcs #11 library version number, for example, 3.11 (major=0x03, minor=0x0b). a user may call fc_getinfo without logging into the token (to assume the nss user role). return value fc_getinfo always returns ckr_ok. fc_getinfo should return ckr_
arguments_bad if pinfo is null. fc_getinfo should return ckr_cryptoki_not_initialized if the library is not initialized. examples note the use of the %.32s format string to print the manufacturerid and librarydescription members of the ck_info structure. #include <assert.h> #include <stdio.h> ck_function_list_ptr pfunctionlist; ck_rv crv; ck_info info; crv = fc_getfunctionlist(&pfunctionlist); asser...
FC_GetTokenInfo
r, 0.0 (major=0x00, minor=0x00). a user may call fc_gettokeninfo without logging into the token (to assume the nss user role). return value ckr_ok token information was successfully copied. ckr_cryptoki_not_initialized the pkcs #11 module library is not initialized. ckr_slot_id_invalid the specified slot number is out of the defined range of values. fc_gettokeninfo should return ckr_
arguments_bad if pinfo is null. examples note the use of the %.32s format string to print the label and manufacturerid members of the ck_token_info structure. see also fc_getslotinfo, nsc_gettokeninfo ...
FC_Initialize
ptographic services' dbslotdescription='psm private keys' fipsslotdescription='psm internal fips-140-1 cryptographic services' fipstokendescription='psm fips-140-1 user private key services' minps=0" see pkcs #11 module specs for complete documentation of the library parameters string. return value fc_initialize returns the following return codes. ckr_ok: library initialization succeeded. ckr_
arguments_bad pinitargs is null. pinitargs->libraryparameters is null. only some of the lock functions were provided by the application. ckr_cant_lock: the ckf_os_locking_ok flag is not set in pinitargs->flags. the nss cryptographic module always uses os locking and doesn't know how to use the lock functions provided by the application. ckr_cryptoki_already_initialized: the library is al...
NSS functions
ssl functions the public functions listed here are used to configure sockets for communication via the ssl and tls protocols. ...
NSS tools : pk12util
rectory] [-h tokenname] [-p dbprefix] [-r] [-v] [-k slotpasswordfile|-k slotpassword] [-w p12filepasswordfile|-w p12filepassword] description the pkcs #12 utility, pk12util, enables sharing certificates among any server that supports pkcs#12. the tool can import certificates and keys from pkcs#12 files into security databases, export certificates, and list certificates and keys. options and
arguments options -i p12file import keys and certificates from a pkcs#12 file into a security database. -l p12file list the keys and certificates in pkcs#12 file. -o p12file export keys and certificates from the security database to a pkcs#12 file.
arguments -c keycipher specify the key encryption algorithm. -c certcipher specify the key cert (overall package) encryption algorithm. -d [sql...
sslerr.html
ture verification). sec_error_library_failure -8191 security library failure. sec_error_bad_data -8190 security library: received bad data. sec_error_output_len -8189 security library: output length error. sec_error_input_len -8188 security library: input length error. sec_error_invalid_args -8187 security library: invalid
arguments. sec_error_invalid_algorithm -8186 security library: invalid algorithm. sec_error_invalid_ava -8185 security library: invalid ava. sec_error_invalid_time -8184 security library: invalid time. sec_error_bad_der -8183 security library: improperly formatted der-encoded message. sec_error_bad_signature -8182 peer's certificate...
sslfnc.html
ot previously set the cipher preference for this cipher on this socket, the value will be either the process default value or the value inherited from a listen socket or a model socket. ssl_configsecureserver configures a listen socket with the information needed to handshake as an ssl server. ssl_configsecureserver requires the certificate for the server and the server's private key. the
arguments are copied. syntax #include "ssl.h" secstatus ssl_configsecureserver( prfiledesc *fd, certcertificate *cert, seckeyprivatekey *key, sslkeatype keatype); parameters this function has the following parameters: fd a pointer to the file descriptor for the ssl listen socket. cert a pointer to the server's certificate ...
NSS tools : signtool
example, use -e".class" to sign only java class files. note that with netscape signing tool version 1.1 and later this option can appear multiple times on one command line, making it possible to specify multiple file types or classes to include. -f commandfile specifies a text file containing netscape signing tool options and
arguments in keyword=value format. all options and
arguments can be expressed through this file. for more information about the syntax used with this file, see "tips and techniques". -i scriptname specifies the name of an installer script for smartupdate. this script installs files from the jar archive in the local system after smartupdate has val...
Necko Architecture
n nsistreamlistener is told when the uri transaction has "started," when data is available (in the case of reading data), and when it has "stopped." it is up to the nsistreamlistener implementation to decide what to do with these various notifications. the ondataavailable() notification provides a chance for the nsistreamlistener to actually retrieve data that the channel has acquired. one of the
arguments to the ondataavailable() notification is an nsiinputstream (which can be considered the underlying data). streams necko represents data in the form of streams (nsibasestream is the root interface. nsiinputstream is read from. nsioutputstream is written to). streams provide a generic interface to the data and allow for many underlying implementations that permit multiple data sources to be used...
Rhino Debugger
ozilla browser since rhino is not the engine used in such environments. current limitations: no breakpoint menu using the rhino javascript debugger the mozilla rhino javascript engine includes a source-level debugger for debugging javascript scripts. the debugger is itself a java program which you may run as java org.mozilla.javascript.tools.debugger.main [options] [filename.js] [script-
arguments] where the options are the same as the shell. the rhino javascript debugger can debug scripts running in multiple threads and provides facilities to set and clear breakpoints, control execution, view variables, and evaluate arbitrary javascript code in the current scope of an executing script. console window the debugger redirects the system.out, system.in, and system.err streams to an in...
Rhino optimization
bers. local common sub-expressions are collapsed (currently this only happens for property lookup, but in the future more expressions may be optimized). all local variables and parameters are allocated to java vm registers. function call targets are speculatively pre-cached (based on the name used in the source) so that dispatching can be direct, pending runtime confirmation of the actual target.
arguments are passed as object/number pairs to reduce conversion overhead. note some language features (indirect calls to eval, use of the
arguments property of function objects) were previously not supported in higher optimization levels. these features have been removed from the language in ecma, so higher optimization levels are now conformant. future versions may allocate more aggressive optimizat...
Rhino overview
1, b:2}" for example). in version 1.3 and greater these functions are ecma conformant. array constructor array(i) for a number argument i constructs an array with a single element equal to i for version 1.2 only. otherwise the ecma conformant version is used (an array is constructed with no elements but with length property equal to i). string.prototype.substring for version 1.2 only, the two
arguments are not swapped if the first argument is less than the second one. all other versions are ecma compliant. string.prototype.split for version 1.2 only, split performs the perl4 special case when given a single space character as an argument (skips leading whitespace, and splits on whitespace). all other versions split on the space character proper as specified by ecma. security the security fe...
Creating JavaScript jstest reftests
in a given folder, you can add the functionality to the shell.js or broswer.js file in the directory. asserteq asserteq(v1, v2[, message]) checks that v1 and v2 are the same value. if they're not, throw an exception (which will cause the test to fail). reportcompare reportcompare(expected, actual, description) is somewhat like asserteq(actual, expected, description) except that the first two
arguments are swapped, failures are reported via stdout rather than by throwing exceptions, and the matching is fuzzy in an unspecified way. for example, reportcompare sometimes considers numbers to be the same if they are "close enough" to each other, even if the == operator would return false. expected = 3; actual = 1 + 2; reportcompare(expected, actual, '3==1+2'); comparesource comparesource(expec...
64-bit Compatibility
with pointers on amd64 (or em64-t/intel64), it is important to keep in mind an invariant that bits 63-48 must be sign-extended from bit 47. if you use these bits to squirrel away a payload, they must be adjusted before attempting to dereference the pointer. for more information and platform specific details on virtual address widths, see this article on wikipedia. builtins and calls when passing
arguments to lirwriter::inscall(), there are four types: argsize_f - floating point value argsize_i - 32-bit integer argsize_q - 64-bit integer argsize_p - 32-bit integer on 32-bit platforms, 64-bit integer on 64-bit platforms. remember to use argsize_p where appropriate - on pointers or natively sized integers (including jsvals). similarly, when adding types to jsbuiltins.h, remember to use _js_ptr ...
Bytecodes
in the jsscript data structure. within the engine, all bytecode execute within a stack frame -- even global (top-level) and eval code has a stack frame associated with it. a frame on the stack has space for javascript values (the tagged value format) in a few different categories. the space for a single javascript value is called a "slot", so the categories are: argument slots: holds the actual
arguments passed to the current frame. local slots: holds the local variables used by the current code. expression slots: holds the temporary space that you need to calculate expressions on a stack. for example, in (a + b) + c you would push a, then push b, then add, then push c, then add, which requires a maximum depth of two expression slots. there are also some slots reserved for dedicated functional...
Self-hosted builtins in SpiderMonkey
cope won't be run in the scope of the global object. self-hosted code has access to some functionality that's not available to normal js code. most importantly, it's possible to invoke any function within the scope of any object using the syntax callfunction(fun, receiver, ...args) (or callcontentfunction, see below), which causes fun to be called within the scope of receiver with ...args as its
arguments. in contrast to function.prototype.call, this syntax makes it impossible for other code to interfere and gets compiled to bytecode that doesn't have any overhead compared to a normal function invocation. otoh, normal method calls are forbidden in self-hosted code. so instead of receiver.fun(arg1, ..., argn) you have to use callfunction(fun, receiver, arg1, ... argn). this restriction was added b...
JS::Call
rent" object on which the function operates; the object specified here is "this" when the function executes. fun / funobj js::handlefunction / js::handlevalue / js::handleobject pointer to the function to call. should be a native function or jsapi-compiled function. name const char * pointer to the function name to call. args js::handlevaluearray &
arguments to pass to the function. rval js::mutablehandlevalue out parameter. on success, *rval receives the return value from the function call. description js::call calls a specified function, fun, on an object, thisobj. in terms of function execution, the object is treated as this. for more detail, see js_callfunction, js_callfunctionname, and js_callfunctionvalue. see also m...
JS::Construct
name type description cx jscontext * pointer to a js context from which to derive runtime information. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. fun js::handlevalue pointer to the function to call. should be a native function or jsapi-compiled function.. args js::handlevaluearray &
arguments you are passing to the function. rval js::mutablehandlevalue out parameter. on success, *rval receives the newly created object from the constructor call. description js::construct calls a specified function as a constructor, fun. for more detail, see js::call, js_callfunction, js_callfunctionname, and js_callfunctionvalue. see also mxr id search for js::construct js:...
JS::GetFirstArgumentAsTypeHint
convert first argument of @@toprimitive method to jstype. syntax bool js::getfirstargumentastypehint(jscontext* cx, callargs args, jstype *result); name type description cx jscontext * the context in which to define functions. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. fs callargs the
arguments of the function call. behavior jstype * receives the result of conversion. see below. description js::getfirstargumentastypehint converts first argument of @@toprimitive method to jstype. if args.get(0) is one of the strings "string", "number", or "default", set *result to jstype_string, jstype_number, or jstype_void accordingly and return true. otherwise, return false with a type...
JS::GetSelfHostedFunction
on cx jscontext* the context from which to get the function. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. selfhostedname const char* function name in the self-hosted javascript. id js::handle<jsid> a pointer to jsid of the name to assign to the new function. nargs unsigned number of
arguments the function expects. description js::getselfhostedfunction creates a new javascript function implemented in self-hosted javascript. on success, js::getselfhostedfunction returns a pointer to the newly created function. otherwise, it reports an out-of-memory error and returns null. see also mxr id search for js::getselfhostedfunction bug 1140573 ...
JS::Handle
dress() const returns a pointer to ptr. const t &get() const returns ptr. operator const t&() const t operator->() const bool operator!=(const t &other) const compares ptr and other. bool operator==(const t &other) const description js::handle<t> is a const reference to a js::rooted<t>. functions which take gc things or values as
arguments and need to root those
arguments should generally use handles for those
arguments and avoid any explicit rooting. this has two benefits. first, when several such functions call each other then redundant rooting of multiple copies of the gc thing can be avoided. second, if the caller does not pass a rooted value a compile error will be generated, which is quicker and easier to fix than when relyin...
JSAutoByteString
he string to take ownership. if jsautobytestring instance is initialized with jsautobytestring bytes; style, it does not own any string. you can call some methods to take ownership of other string. note that the js_encodestring call in constructor and some encode* methods may fail and get null. so ensure the string is returned by operator!() before using ptr() method. examples use constructor
arguments { jsstring *str = js::tostring(cx, strval); if (!str) return false; jsautobytestring bytes(cx, str); /* calls js_encodestring internally */ if (!bytes) return false; /* ...do something with bytes... */ /* when leaving this scope, the string returned by js_encodestring is freed. */ } use method to encode string { js::rootedstring str(cx, js::tostring(cx, strval)); if...
JSClass.flags
s a last resort.) enable standard ecmascript behavior for setting the prototype of certain objects, such as function objects. if the global object does not have this flag, then scripts may cause nonstandard behavior by replacing standard constructors or prototypes (such as function.prototype.) objects that can end up with the wrong prototype object, if this flag is not present, include:
arguments objects (ecma 262-3 §10.1.8 specifies "the original object prototype"), function objects (ecma 262-3 §13.2 specifies "the original function prototype"), and objects created by many standard constructors (ecma 262-3 §15.4.2.1 and others). mxr id search for jsclass_global_flags jsclass_foreground_finalize objects of this class must be finalized on the main thread. ...
JSErrorFormatString
this article covers features introduced in spidermonkey 17 represent error message and type. syntax typedef struct jserrorformatstring { const char *format; uint16_t argcount; int16_t exntype; } jserrorformatstring; name type description format const char * the error format string in ascii. argcount uint16_t the number of
arguments to expand in the formatted error message. exntype int16_t one of the jsexntype constants. description jserrorformatstring is a struct to represent error message and type, returned by js_reporterrornumber function. see also mxr id search for jserrorformatstring jsexntype js_reporterrornumber bug 684526 ...
JSErrorReport
here that isn't appropriate, the caller should do the right checks itself instead of using this flag. the constant jsreport_error is 0 and can be used to indicate an error report without any of the above flags. errornumber unsigned the error number. ucmessage const char16_t * the default unicode error message. messageargs const char16_t **
arguments for the error message. exntype int16_t one of the jsexntype constants. description jserrorreport describes a single error that occurs in the execution of script. in the event of an error, filename will either contain the name of the external source file or url containing the script (script src=) or null, indicating that a script embedded in the current html page caused the er...
JSExtendedClass.wrappedObject
ain to do this check, wrappers are automatically unwrapped. a wrapper object is strictly equal to the object it wraps, in the sense of === and !==. two wrapper objects that wrap the same object are also strictly equal. object.prototype.eval unwraps. a wrapper object that wraps an array is considered an array for the purpose of array.prototype.concat and array.concat (which treat array
arguments differently from other
arguments, per ecma 262-3 §15.4.4.4). the wrappedobject callback implementation must never fail. if it returns null or obj, then the js engine treats the object as though it were not a wrapper. wrapper objects typically have no prototype, do not allow setting __proto__, and inherit properties from the wrapped object rather than the prototype chain (see jsnewresolveop). ...
JS_DefineFunctions
makes them properties (methods) of a specified object, obj, as if by calling js_definefunction repeatedly. fs is a pointer to the first element of an array of jsfunctionspec records. this array is usually defined as a static global, with each record initialized using js_fs or js_fn. each array element defines a single function: its name, the native c/c++ implementation, the number of javascript
arguments the function expects, and any property attributes. the last element of the array must contain 0 values. (the macro js_fs_end can be used for the last element.) js_definefunctions creates one function for each non-zero element in the array. propertydefinitionbehavior is used to select if properties with jsprop_define_late flag should be defined on the object. normal jsapi consumers probably alway...
JS_DefineObject
w object is up to the caller. on success, js_defineobject returns a pointer to the new object. on error or exception (if the object cannot be created, the property already exists, or the property cannot be created), js_defineobject returns null. this function combines two operations: creating an object and storing it in a property of another object. use js_constructobject, js_constructobjectwith
arguments, or js_newobject to create a new object without storing it in a property of another object. use js_defineproperty or js_defineelement to create a property without creating a new object. see also mxr id search for js_defineobject bug 1127494 ...
JS_DumpNamedRoots
ce for each named root in the given runtime rt. in pseudocode: /* pseudocode explanation of what js_dumpnamedroots does */ void js_dumpnamedroots(jsruntime *rt, dumpfn dump, void *data) { for each (root in rt->namedroots) dump(root.name, root.address, data); } callback syntax dump is a pointer to a function provided by the application. when js_dumpnamedroots calls it, it passes three
arguments: argument type description name const char * the name of the named root. rp void * a pointer to the rooted variable, array element, or field. this is the pointer that the application passed to js_addnamedroot. it points to a variable, array element, or field of type jsval, jsobject *, jsstring *, or jsdouble *. data void * the data argum...
JS_FS
name const char * the javascript name for the function. (or index, if jsprop_index is present in flags) symbol a member name of js::symbolcode the javascript symbol for the function. call jsnative pointer to the c/c++ implementation of the function. info const jsjitinfo * pointer to the jit info. nargs uint16_t the number of
arguments the function expects. flags uint16 the bitwise or of any number of function flags. selfhostedname const char * the function's name in self-hosted javascript code. description use these macros to define an array of jsfunctionspecs to pass to js_definefunctions or js_initclass. js_fn (whose name pays homage to the old jsnative/jsfastnative split) simply adds the ...
JS_GET_CLASS
js_getclass(cx, obj) #else #define js_get_class(cx,obj) js_getclass(obj) #endif parameter type description cx jscontext * any context associated with the runtime in which obj exists. obj jsobject * object to get the class from. note: in spidermonkey versions prior to spidermonkey 1.8.8, js_getclass took both a jscontext* and a jsobject* as
arguments in thread-safe builds, and in non-thread-safe builds it took only a jsobject*. the js_get_class(cx, obj) macro abstracted away this detail. newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe. description js_get_class returns a pointer to the jsclass associated with a specified js object, obj. the application mu...
JS_GetClass
ieves the class associated with an object. syntax const jsclass * js_getclass(jsobject *obj); name type description cx jscontext * any context associated with the runtime in which obj exists. obj jsobject * object to get the class from. in spidermonkey versions prior to spidermonkey 1.8.8, js_getclass took both a jscontext* and a jsobject* as
arguments in thread-safe builds, and in non-thread-safe builds it took only a jsobject*. the js_get_class(cx, obj) macro abstracted away this detail. newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe. description js_getclass returns a pointer to the jsclass associated with a specified js object, obj. the application mus...
JS_GetFunctionArity
get the number of
arguments a function expects. syntax uint16_t js_getfunctionarity(jsfunction *fun); name type description fun jsfunction * a javascript function. description js_getfunctionarity returns the number of formal parameters of a function, fun. this is the same as the function object's arity property, if that property has not been overwritten. specifically, if fun is a native function, the result is the value that was passed to the nargs parameter of js_definefunction. otherwise fun is implemented in javascript, and the result is the number of identifiers in its formal parameter list (see ecma 262-3 §13). note that it is not an error per se to call a javascript function with more or fewer actual
arguments than its arity. see also mxr id ...
JS_InitClass
s for use by other api functions. constructor jsnative the constructor for the class. its scope matches that of the obj argument. if constructor is null, then static_ps and static_fs must also be null. unlike other jsnatives, this function must not call js_this or js_this_object. instead it must create a new object and return it. nargs unsigned number of
arguments for the constructor. ps jspropertyspec * either null or a pointer to the first element of an array of jspropertyspecs, terminated by the null jspropertyspec, which can be written {0, 0, 0, 0, 0}. these properties, if any, are added to the class's new prototype object. all instances of the new class will inherit these properties via the prototype chain. fs jsfunctionspec...
JS_IsConstructing
cting or callreceiver::isconstructing instead. syntax jsbool js_isconstructing(jscontext *cx, jsval *vp); name type description cx jscontext * the cx parameter passed to the jsnative. vp jsval * the vp parameter passed to the jsnative. description js_isconstructing must be called only from a jsnative called from the engine. cx and vp must be the
arguments that the engine passed to that jsnative. js_isconstructing returns js_true if the native was defined with jsfun_constructor (js_initclass automatically sets that flag when defining a constructor) and it was called as a constructor, either from javascript, using the new keyword, or from c/c++ using a jsapi function such as js_constructobject. otherwise it returns js_false. ordinary non-constructor...
JS_New
jscontext * the context in which to create the new object. requires request. in a js_threadsafe build, the caller must be in a request on this jscontext. ctor js::handleobject the constructor function object. args js::handlevaluearray & an array of argument values to pass to the constructor. added in spidermonkey 38 argc unsigned the number of
arguments to pass to the constructor. obsolete since jsapi 32 argv jsval * pointer to the element 0 of an array of argument values to pass to the constructor. if argc is 0, this may be null. obsolete since jsapi 32 description js_new creates a new object as though by using the new operator, as described in ecma 262-3 §11.2.2. js_new(cx, ctor, args) is equivalent to the javascript e...
JS_NewObjectForConstructor
uctor would if invoked with new. this function does not run the code of the constructor function--it just creates the object. if the constructor argument is not an object jsval, this function will assert (in debug builds). if the constructor does not have a prototype property, this function will return null and set an exception on cx. the standard object creation api, js_newobject, takes explicit
arguments for the class, prototype, and parent of the new object. with js_newobjectforconstructor, the prototype and parent are determined by the constructor, and class is still determined by the caller. the prototype is the prototype of the constructor if it is an object, otherwise null. the parent is the constructor's parent. see also mxr id search for js_newobjectforconstructor js_newobject object_to_...
JS_ReportError
be in a request on this jscontext. format const char * format string to convert into an error message using js_vsmprintf. ... ... error message variables to insert into the format string. description js_reporterror is the simplest jsapi function for reporting errors. first it builds an error message from the given sprintf-style format string and any additional
arguments passed after it. the resulting error message is passed to the context's jserrorreporter callback, if any. if the caller is in a jsapi callback, js_reporterror also creates a new javascript error object and sets it to be the pending exception on cx. the callback must then return js_false to cause the exception to be propagated to the calling script. an example is shown in the jsapi phrasebook. for...
JS_ReportErrorNumber
erref void * a pointer to application data. the javascript engine passes this pointer to errorcallback. the meaning of the data is up to the application. errornumber const unsigned an error code. the javascript engine passes this number to errorcallback. the meaning of the error number is up to the application. ... / args ... / const char16_t ** additional
arguments for the error message. these
arguments must be of type char * for js_reporterrornumber or js_reporterrorflagsandnumber, or char16_t * for js_reporterrornumberuc or js_reporterrorflagsandnumberuc. the number of additional
arguments required depends on the error message, which is determined by the errorcallback. callback syntax typedef const jserrorformatstring * (* jserrorcallback)(v...
JS_SET_TRACING_DETAILS
g information about a reference to a traceable thing to prepare for the following call to js_calltracer. when printer is null, arg must be const char * or char * c string naming the reference and index must be either (size_t)-1 indicating that the name alone describes the reference or it must be an index into some array vector that stores the reference. when printer is not null, the arg and index
arguments are available to the callback as the debugprinterarg and debugprintindex fields of trc. the storage for name or callback's
arguments needs to live only until the following call to js_calltracer returns. mxr id search for js_set_tracing_details ...
JS_ValueToObject
efaultvalue method is called with hint=jstype_object.) the resulting object is subject to garbage collection unless the variable *objp is protected by a local root scope, an object property, or the js_addroot function. note that a local root scope is not sufficient to protect the resulting object in some cases involving the valueof method! see also mxr id search for js_valuetoobject js_convert
arguments js_convertvalue js_typeofvalue js_valuetofunction ...
Parser API
r; left: expression; right: expression; } a logical operator expression. interface conditionalexpression <: expression { type: "conditionalexpression"; test: expression; alternate: expression; consequent: expression; } a conditional expression, i.e., a ternary ?/: expression. interface newexpression <: expression { type: "newexpression"; callee: expression;
arguments: [ expression ]; } a new expression. interface callexpression <: expression { type: "callexpression"; callee: expression;
arguments: [ expression ]; } a function or method call expression. interface memberexpression <: expression { type: "memberexpression"; object: expression; property: identifier | expression; computed: boolean; } a member expression. if computed...
SpiderMonkey 1.8.5
js_clearoperationcallback js_clearregexproots js_decompilescript js_destroyscript js_enterlocalrootscope js_executescriptpart js_forgetlocalroot js_getfunctionname js_getoperationlimit js_getscriptobject js_getstringbytes js_getstringchars js_isassigning js_leavelocalrootscope js_leavelocalrootscopewithresult js_newdouble js_newdoublevalue js_newscriptobject js_newstring js_pop
arguments js_push
arguments js_push
argumentsva js_removeroot js_removerootrt js_sealobject js_setbranchcallback js_setcallreturnvalue2 js_setcheckobjectaccesscallback js_setobjectprincipalsfinder js_setoperationlimit js_setprincipalstranscoder api changes operation callback js_setoperationcallback was introduced in js 1.8.0, replacing the branch callback, in anticipation of the addition of the t...
SpiderMonkey 31
ich uninitializes the js engine after all runtimes have been destroyed. js_seticumemoryfunctions is a new function which can be used to set the allocation and deallocation functions used by the icu internationalization library. this is unlikely to be of interest to embedders unless you are doing detailed memory profiling. it must be called before js_init is called. ...
SpiderMonkey 38
50) jsval_is_void (bug 952650) jsval_to_boolean (bug 952650) jsval_to_double (bug 952650) jsval_to_gcthing (bug 952650) jsval_to_int (bug 952650) jsval_to_object (bug 952650) jsval_to_private (bug 952650) jsval_to_string (bug 952650) js_clearnonglobalobject (bug 1043281) js_clonefunctionobject (bug 1089026) js_compilefunction (bug 1089026) js_compileucfunction (bug 1089026) js_convert
arguments (bug 1125784) js_convert
argumentsva (bug 1125784) js_convertstub (bug 1103152) js_defineownproperty (bug 1017323) js_deletepropertystub (bug 1103152) js_doubletoint32 (bug 1112774) js_doubletouint32 (bug 1112774) js_enumeratestub (bug 1103152) js_evaluatescript (bug 1100579) js_evaluateucscript (bug 1100579) js_executescriptversion (bug 1095660) js_getflatstringchars (bug 1037869) js_...
Setting up CDT to work on SpiderMonkey
that. step 1 - preparing a spidermonkey build for cdt to index all code, spidermonkey has to be built with debug information. the full process of and requisites for doing so are described here. please follow those instructions up until the point of invoking configure. the initial build was in clang, so the modified build commands look like this: mkdir _dbg.obj cd _dbg.obj cc='clang -qunused-
arguments -fcolor-diagnostics' cxx='clang++ -qunused-
arguments -fcolor-diagnostics' \ ../configure --enable-debug --disable-optimize --enable-debug-symbols note: if you want to use ccache, you can enable it by adding --with-ccache to the
arguments list. due to a bug in cdt, you have to make a small change to cdt's build configuration as explained in step 3 below for that to work, though. step 2 - in...
Web Replay
y result from accessing a recorded lock or atomic. core xpcom and mozglue lock classes and mozilla::atomic atomics are recorded by default, but many locks and atomics don't actually need to be recorded in order to correctly replay. recording for a lock or atomic can be turned off by specifying recordreplay::behavior::dontpreserve in either the lock's contructor argument or the atomic's template
arguments. interactions with the middleman process when recording or replaying an execution, there is an extra content process involved, the middleman process as described above. the presence of the middleman requires special handling in ipc internals and some graphics code. additionally, ipc channels used to communicate with middleman processes can also communicate with the recording process child of ...
compare-locales
ave python 2.7 or 3.5+ installed on your machine. the easiest way is to just run $ pip install -u compare-locales running it compare-locales gathers the directories to compare from a toml file, usually found in $app/locales/l10n.toml. the details of the configuration file are described in the l10n-config docs. you pass the path to the toml file and the parent dir of the localizations as first
arguments, followed by the locale codes of the locales you want to compare. if you want to test the localization for de, run $ compare-locales browser/locales/l10n.toml ./l10n/ de to check mobile, replace the previous line with: $ compare-locales mobile/android/locales/l10n.toml ./l10n/ zh-tw to check mail, suite, calendar that lives on comm-central, you can either rely on the check-out of mozilla w...
Using RAII classes in Mozilla
te: moz_decl_use_guard_object_notifier }; moz_guard_object_notifier_param is added to the end of the constructor's parameter list. moz_guard_object_notifier_init is added as a statement in the constructor. moz_decl_use_guard_object_notifier is added where private members should be declared. however, there are some variations for special cases: first, if the constructor (otherwise) takes no
arguments, then you have to use the moz_guard_object_notifier_only_param macro instead. (this is needed because the macro adds a parameter only when debug is defined, and in this case, it can't add the leading comma.) class moz_raii nsautoscriptblocker { public: explicit nsautoscriptblocker(moz_guard_object_notifier_only_param) { moz_guard_object_notifier_init; nscontentutils::addscriptblocker()...
Redis Tips
value per each command executed. awesome. note that if one of your commands crashes, the others still all execute! (try this by breaking one of the set statements by leaving out the value argument.) you'll get one return value for each operation that didn't crash. this sounds terrifying, but it's not actually such a big deal in practice. commands will only crash if you feed them the wrong
arguments or wrong number of
arguments. and you'll probably find problems like that long before you go into production. optimistic locking your transactions are atomic once they start, but of course you can't guarantee that you'll get there first. the redis command watch lets you name keys you're worried about; it causes your next transaction to be immediately aborted if any of the watched keys has b...
Using XPCOM Utilities to Make Things Easier
fragments which may or may not be null terminated)[nulls-in-strings]. all string classes in xpcom derive from one of two abstract classes[other-string-classes]: nsastring and nsacstring. the former handles double byte characters, and the latter tends to be used in more general circumstances, but both of these classes define the functionality of a string. you can see these classes being passed as
arguments in many of the xpcom interfaces we'll look at in the following chapters. using strings explaining how all the string classes work is outside the scope of this book, but we can show you how to use strings in the weblock component. the first thing to note is that the string classes themselves are not frozen, which means that you should not link against them when you can avoid it. linking the ful...
How to build a binary XPCOM component using Visual Studio
inking against xpcomglue_s.lib create an xpcom component a full tutorial of xpcom is beyond the scope of this posting. check out the resources at the end of the tutorial for more information on the world of xpcom. ok then, on with the basic, oversimplified example. your xpcom component is made up of 3 parts: component interface described using idl. the interface defines the methods, including
arguments and return types, of the component. component implementation using c++. the implementation is where the methods actually do the work. component factory module, also in c++. the factory is in charge of creating instances of the implementations. let’s specify a simple interface: #include "nsisupports.idl" [scriptable, uuid(263ed1ba-5cc1-11db-9673-00e08161165f)] interface ispecialthing : nsis...
Components.utils.evalInSandbox
for instance: var x = components.utils.evalinsandbox( "let x = 1;", sandbox, "1.8", // "latest" is recognized as a special case "http://foo.com/mycode.js", 25 ); the above will execute code using javascript 1.8. any exceptions raised by the evaluated code will show as originating from t...
xpcshell
avascript, straight to mozilla. js> 5+7 12 js> print("hello, world!") hello, world! js> see also howto for common problems in writing xpcshell scripts, e.g., doing async network calls or using js modules. pretty much all mozilla programs use xpcom components via xpconnect. read xpconnect:using components to get started with that. see the xpcshell reference for information on command line
arguments and extension functions. learn how to write xpcshell-based unit tests. read xpcshell:profiling for information on how to profile scripts. ...
IAccessibleEditableText
only text object can support the copy capability so this interface is not limited to editable objects. the substrings used with this interface are specified as follows: if startoffset is less than endoffset, the substring starts with the character at startoffset and ends with the character just before endoffset. if endoffset is lower than startoffset, the result is the same as a call with the two
arguments exchanged. the whole text can be defined by passing the indices zero and iaccessibletext.ncharacters(). if both indices have the same value, an empty string is defined. refer to the @ref _specialoffsets "special offsets for use in the iaccessibletext and iaccessibleeditabletext methods" for information about a special offset constant that can be used in iaccessibleeditabletext methods. method ove...
IAccessibleText
t the last character of the selection(). return value e_invalidarg if bad [in] passed. s_ok. text() returns the substring between the two given indices. the substring starts with the character at startoffset (inclusive) and up to the character at endoffset (exclusive), if startoffset is less or equal endoffste. if endoffset is lower than startoffset, the result is the same as a call with the two
arguments being exchanged. the whole text can be requested by passing the indices zero and ncharacters(). if both indices have the same value, an empty string is returned. [propget] hresult text( [in] long startoffset, [in] long endoffset, [out] bstr text ); parameters startoffset index of the first character to include in the returned string. the valid range is 0..length. endoffset index of the la...
mozIThirdPartyUtil
s notification callbacks. then: if the parent is the same as the bottommost window, and the channel has the load_document_uri flag set, return false. this represents the case where a toplevel load is occurring and the window's uri has not yet been updated. (we have already checked that auri is not foreign with respect to the channel uri.) otherwise, return the result of isthirdpartywindow() with
arguments of the channel's bottommost window and the channel uri, respectively. therefore, both the channel's uri and each level in the window hierarchy associated with the channel is tested. for example, if auri is "http://mail.google.com/", achannel has a uri of "http://google.com/", and its parent is the topmost content window with a uri of "http://mozilla.com", the result will be true. boolean isthi...
nsIAppShellService
aappshell a widget "appshell" (event processor) to associate with the new window. return value returns the newly created window. destroyhiddenwindow() destroys a hidden window. void destroyhiddenwindow(); parameters none. doprofilestartup() obsolete since gecko 1.8 (firefox 1.5 / thunderbird 1.5 / seamonkey 1.0) starts up the profile manager with the given
arguments. void doprofilestartup( in nsicmdlineservice acmdlineservice, in boolean caninteract ); parameters acmdlineservice the
arguments given to the program. caninteract if false and ui is needed, will fail. ensure1window() obsolete since gecko 1.8 (firefox 1.5 / thunderbird 1.5 / seamonkey 1.0) ensures that at least one window exists after creating the startup ...
nsIAppStartup
dow(s) opened. return value true if a window was opened. destroyhiddenwindow() destroys the hidden window. this will have no effect if the hidden window has not yet been created. void destroyhiddenwindow(); parameters none. doprofilestartup() obsolete since gecko 1.9.1 (firefox 3.5 / thunderbird 3.0 / seamonkey 2.0) starts up the profile manager with the given
arguments. void doprofilestartup( in nsicmdlineservice acmdlineservice, in boolean caninteract ); parameters acmdlineservice the
arguments given to the program. caninteract if false and ui is needed, will fail. ensure1window() obsolete since gecko 1.9.1 (firefox 3.5 / thunderbird 3.0 / seamonkey 2.0) ensures that at least one window exists after creating the startu...
nsICommandLineRunner
string process and combine the help text provided by each command-line handler. read only. methods init() called with the argc/argv combination passed to main. it assumes a native character set. on windows the character set is utf-8, not the native codepage. void init( in long argc, in nscharptrarray argv, in nsifile workingdir, in unsigned long state ); parameters argc the number of
arguments being passed. argv an array storing pointers to the
arguments workingdir directory where the command will run. this is used to resolve file and uri paths. state the type of command line being processed. this is an nsicommandline state flag. run() processes the command-line handlers in the proper order, and calls nsicommandlinehandler.handle() on each. void run(); parameters none. exceptions thr...
nsICookieManager
te type description enumerator nsisimpleenumerator called to enumerate through each cookie in the cookie list. the objects enumerated over are of type nsicookie. read only. methods remove() this method is called to remove an individual cookie from the cookie list, specified by host, name, and path. if the cookie cannot be found, no exception is thrown. typically, the
arguments to this method will be obtained directly from the desired nsicookie object. void remove( in autf8string ahost, in acstring aname, in autf8string apath, in boolean ablocked, in jsval aoriginattributes ); parameters ahost the host or domain for which the cookie was set. see nsicookiemanager2.add() for a description of acceptable host strings. if the target cookie is a domain cookie...
nsIDOMParser
ser in gecko 1.9. (this section is only relevant to firefox extensions--not to web content.) to create a document, the parser needs to specify a principal (see security check basics), a base uri (see document.baseuriobject), and a documenturi. these values are automatically determined as defined below, but if you work with domparser from privileged code, you can override the defaults by providing
arguments to the domparser constructor or calling parser.init(). usually you don't need to do that. if you come across a situation when these matter, feel free to ask questions in mozilla.dev.tech.dom and update this documentation to mention these cases. when a domparser is instantiated by calling new domparser(), it inherits the calling code's principal (except that for chrome callers the principal is se...
nsIDOMWindowInternal
reference it from failing completely. add-ons should be updated to use nsidomwindow instead. it provides many of the common functions used in javascript such as alert() or open(). note: because most of nsidomwindowinternal's functions and attributes are well documented in window, those articles are linked to rather than re-documented. however, they are not guaranteed to document all available
arguments (i.e. see window.prompt). method overview firefox 3.5 note the prompt() and find() methods changed in firefox 3.5 to make all their parameters optional; in previous versions, all parameters were required. void alert(in domstring text) boolean confirm(in domstring text) domstring prompt([optional] in domstring amessage, [optional] in domstring ainitial, [option...
nsIDragService
e was started. atransferables an array of transferables to be dragged. aregion a region containing rectangles for cursor feedback, in window coordinates. aactiontype specified which of copy/move/link are allowed. invokedragsessionwithimage() starts a modal drag session using an image. a custom image may be specified using the aimage argument. if this is supplied, the aimagex and aimagey
arguments specify the offset within the image where the cursor would be positioned. that is, when the image is drawn, it is offset up and left the amount so that the cursor appears at that location within the image. if aimage is null, aimagex and aimagey are not used and the image is instead determined from the source node adomnode, and the offset calculated so that the initial location for the image appea...
nsIHttpChannelInternal
ontains the response's major version number. minor on return, contains the response's minor version number. httpupgrade() allows for the use of http to bootstrap another protocol via the rfc 2616 upgrade request header in conjunction with a 101 level response. the nsihttpupgradelistener will have its nsihttpupgradelistener.ontransportavailable() method invoked if a matching 101 is processed. the
arguments to nsihttpupgradelistener.ontransportavailable() provide to the new protocol the low level transport streams that are no longer used by http. the onstartrequest and onstoprequest events are still delivered and the listener gets full control over the socket if and when nsihttpupgradelistener.ontransportavailable() is delivered. void httpupgrade( in acstring aprotocolname, in nsihttpupgradelist...
nsIHttpServer
onents.interfaces.nsihttpserver); return { get objectname () { return "webserver"; }, /** * @param integer|string port port or "host:port" * @param object opt optional options. ...
nsIJetpack
particular message. note: multiple callbacks may be registered for the same message; they will all be triggered. void registerreceiver( in astring amessagename, in jsval areceiver ); parameters amessagename the name of the message from the jetpack process on which the callback is triggered. areceiver a javascript function. the first argument passed to it is the name of the message, and all
arguments following it are either json-serializable types or handles. if the message was sent synchronously from the jetpack process via callmessage(), then the return value of this function is passed back to the jetpack process. unregisterreceiver() this unregisters a callback previously registered with registerreceiver() void unregisterreceiver( in astring amessagename, in jsval areceiver ); parame...
Component; nsIPrefBranch
n which this branch is based, such as "browser.startup." read only. constants constant value description pref_invalid 0 long pref_string 32 long data type. pref_int 64 long data type. pref_bool 128 long data type. methods addobserver() adds a preference change observer. on preference changes, the following
arguments will be passed to nsiobserver.observe(): asubject - the nsiprefbranch object (this). atopic - the string defined by ns_prefbranch_prefchange_topic_id adata - the name of the preference which has changed, relative to the "root" of the asubject branch. asubject.get*pref(adata) will get the new value of the modified preference. for example, if your observer is registered with addobserver("bar.",...
nsIPrefBranch2
in gecko 13 this interface was merged into the nsiprefbranch interface. method overview void addobserver(in string adomain, in nsiobserver aobserver, in boolean aholdweak); void removeobserver(in string adomain, in nsiobserver aobserver); methods addobserver() add a preference change observer. on preference changes, the following
arguments will be passed to nsiobserver.observe(): asubject - the nsiprefbranch object (this). atopic - the string defined by ns_prefbranch_prefchange_topic_id adata - the name of the preference which has changed, relative to the "root" of the asubject branch. asubject.get*pref(adata) will get the new value of the modified preference. for example, if your observer is registered with addobserver("bar.", ...) on a branch with root "...
nsIProcess2
ver, [optional] in boolean holdweak); methods runasync() asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running. void runasync( [array, size_is(count)] in string args, in unsigned long count, in nsiobserver observer, optional in boolean holdweak optional ); parameters args an array of
arguments to pass into the process, using the native character set. this array must have count entries. count the number of
arguments passed in the args array. observer optional an observer that will be notified when the process exits. the observer will receive this nsiprocess2 instance as the subject and "process-finished" or "process-failed" as the topic. the observer will be ...
nsIPrompt
e is hidden by the getinterface though which it is obtained. inherits from: nsisupports last changed in gecko 1.8 (firefox 1.5 / thunderbird 1.5 / seamonkey 1.0) note: this interface is identical to nsipromptservice but without the parent nsidomwindow parameter. to avoid redundancy, all methods here link to nsipromptservice. if you are using this interface, you must remove the nsidomwindow
arguments from those methods. normally you would use the prompt service as it is more flexible, but sometimes a callback will request an nsiprompt via nsiinterfacerequestor.getinterface(). to get an instance, call the nsiwindowwatcher.getnewprompter(). method overview void alert(in wstring dialogtitle, in wstring text); void alertcheck(in wstring dialogtitle, in wstring text,...
nsIServiceManager
); boolean isserviceinstantiated(in nscidref aclass, in nsiidref aiid); boolean isserviceinstantiatedbycontractid(in string acontractid, in nsiidref aiid); methods getservice() this method returns a reference to a particular xpcom service given the classid of the service. unlike createinstance, this will always return the same object each time it is called with the same
arguments. void getservice( in nscidref aclass, in nsiidref aiid, [iid_is(aiid),retval] out nsqiresult result ); parameters aclass the classid of the service that is being requested. aiid the interface type to be returned. result the resulting interface pointer. exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered. getservicebycontr...
nsITextInputProcessor
constants. if this is not specified, the value is assumed as 0. return value when there is no composition which was created by the instance and if compositionstart is consumed by web contents, i.e., failed to start new composition, this returns false. otherwise, returns true. how to create keyboardevent instance for nsitextinputprocessor this section describes how to create keyboardevent for
arguments of some methods of nsitextinputprocessor. you should/can specify following attribute values at creating a keyboardevent instance. other attributes are always ignored. especially, please note that modifier key states such as shiftkey are also ignored because each instance of nsitextinputprocessor manages modifier state which is modified when keydown() or keyup() is called with modifier key event.
nsIWindowMediator
var {cc: classes, ci: interfaces} = components; var windowlistener = { onopenwindow: function (awindow) { // wait for the window to finish loading let domwindow = awindow.queryinterface(ci.nsiinterfacerequestor).getinterface(ci.nsidomwindowinternal || ci.nsidomwindow); domwindow.addeventlistener("load", function () { domwindow.removeeventlistener("load",
arguments.callee, false); //this removes this load function from the window //window has now loaded now do stuff to it //as example this will add a function to listen to tab select and will fire alert in that window if (domwindow.gbrowser && domwindow.gbrowser.tabcontainer) { domwindow.gbrowser.tabcontainer.addeventlistener('tabselect', function () { ...
XPCOM
lemented in c, c++, and javascript, and can be used from c, c++, and javascript. that means you can call javascript methods from c++ and vice versa. for more information on the workings of xpcom look elsewhere.how to pass an xpcom object to a new windowif you want to be able to call functions within an xpcom object from a xul window's code, you can do so if you pass the xpcom object as one of the
arguments to the window creation method.interfacing with the xpcom cycle collectorthis is a quick overview of the cycle collector introduced into xpcom for firefox 3, including a description of the steps involved in modifying an existing c++ class to participate in xpcom cycle collection. if you have a class that you think is involved in a cyclical-ownership leak, this page is for you.introduction to xpcom...
XPIDL Syntax
")") ")" functionality not used in xpidl the libidl parser we use is more powerful than xpidl itself can understand. the following is a list of potential features which are parseable but may not result in expected code: struct, union, and enumerated types array declarators (appears to be supported in xpidl_header.c but not xpidl_typelib.c) exception declarations module declarations variable
arguments (that makes the abnf get more wonky) sequence types max-length strings fixed-point numbers "any" and "long double" types. pyxpidl syntax idlfile = *(cdata / include / interface / typedef / native) typedef = "typedef" identifer identifier ";" native = [attributes] "native" identifier "(" nativeid ")" interface = [attributes] "interface" identifier" [ifacebase] [ifacebody] ";" ifacebase ...
Mail composition back end
the createandsendmessage method will create an rfc822 message and send it all in one operation as well as providing the ability to save disk files for later use. the mode of delivery can also be specified for the "send later", "drafts" and "templates" operations. (note: this method could easily be broken in to a few different calls. currently, this method does several functions depending on the
arguments passed in, but this could easily lead to confusion. this is something that very well may change as time allows). ns_imethod createandsendmessage( nsieditorshell *aeditor, - the editor object for the mail compose operation. if this is not null, the body will be extracted from this object and any embedded objects or links will be sent as part of the message...
Library
exceptions thrown ctypes ctype functiontype abi typeerror the return type was specified as an array. alternative syntax another use for ctypes.declare is to get non-function/non-methods from libraries. the syntax for this is seen in firefox codebase here: //github.com/realityripple/uxp/blob/master/js/src/ctypes/library.cpp?offset=0#271 this shows that we can also supply only two
arguments to the declare function. the first being the same as in the above example, name, which is the name of the symbol to export. and in place of the abi argument, we will pass in the type of this export. for example, from the objective-c library we can export the symbol which holds the address to an external block. this would be done like this: var objc = ctypes.open(ctypes.libraryname('objc')); obj...
Initialization and Destruction - Plugins
e plug-in was invoked, either np_embed or np_full. np_embed means that the instance was created by an embed and shares the browser window with other content. np_full means that the instance was created by a separate file and is the primary content in the window. the next three parameters pass parameters from the embed element that called the plug-in. the argc parameter is the number of html
arguments in the element. it determines the number of attributes in the arrays specified by the argn and argv parameters. the
arguments in the embed element are name-value pairs made up of the attribute name (for example, align) and its value (for example, top). the argn array contains the attribute names; the argv array contains the attribute values. the browser ignores any nonstandard attributes in an ...
Examine, modify, and watch variables - Firefox Developer Tools
ebugger by visiting about:config and setting the "devtools.debugger.new-debugger-frontend" preference to false. to see the docs for the old debugger, please visit debugger (before firefox 52). examine variables when the code has stopped at a breakpoint, you can examine its state in the variables pane of the debugger: variables are grouped by scope: in function scope you'll see the built-in
arguments and this variables as well as local variables defined by the function like user and greeting. similarly, in global scope you'll see global variables you've defined, like greetme, as well as built-in globals like localstorage and console. each object can be expanded, using a disclosure triangle, to show its properties. pointing your cursor at a variable's name displays a tooltip that provides ad...
Debugger - Firefox Developer Tools
is the source code of the offending line. offset the index of the character within linetext at which the error occurred. warning present and true if this is a warning; absent otherwise. strict present and true if this error or warning is due to the strict option (not to be confused with es strict mode) exception present and true if an exception will be thrown; absent otherwise.
arguments an array of strings, representing the
arguments substituted into the error message. this method’s return value is ignored. onnewglobalobject(global) a new global object,global, has been created. this handler method should return a resumption value specifying how the debuggee’s execution should proceed. however, note that a { return:value } resumption value is treated like undefi...
Debugging Firefox Desktop - Firefox Developer Tools
boxes" and "enable remote debugging" settings checked in the developer tools settings. you only need to do this once: the setting values persist across restarts. start the debugger server next, you need to start the debugger server in the debuggee. run the debuggee from the command line, passing it the --start-debugger-server option: /path/to/firefox --start-debugger-server passed with no
arguments, --start-debugger-server makes the debugger server listen on port 6000. to use a different port, pass the desired port number: /path/to/firefox --start-debugger-server 1234 note: in windows, the start-debugger-server call will only have one dash: firefox.exe -start-debugger-server 1234 note: by default, and for security reasons, the devtools.debugger.force-local option is set. if you want to...
The JavaScript input interpreter - Firefox Developer Tools
e ways to select an iframe using cd(): you can pass the iframe dom element: var frame = document.getelementbyid("frame1"); cd(frame); you can pass a css selector that matches the iframe: cd("#frame1"); you can pass the iframe's global window object: var frame = document.getelementbyid("frame1"); cd(frame.contentwindow); to switch the context back to the top-level window, call cd() with no
arguments: cd(); for example, suppose we have a document that embeds an iframe: <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <iframe id="frame1" src="static/frame/my-frame1.html"></iframe> </body> </html> the iframe defines a new function: <!doctype html> <html> <head> <meta charset="utf-8"> <script> function whoareyou() { return "i'm fram...
AnimationEvent() - Web APIs
ent() constructor returns a newly created animationevent, representing an event in relation with an animation. syntax animationevent = new animationevent(type, {animationname: apropertyname, elapsedtime : afloat, pseudoelement: apseudoelementname}); parameters the animationevent() constructor also inherits
arguments from event(). type a domstring representing the name of the type of the animationevent. it is case-sensitive and can be: 'animationstart', 'animationend', or 'animationiteration'. animationname optional a domstring containing the value of the animation-name css property associated with the transition. it defaults to "". elapsedtime optional a float giving the amount of time the animation ...
Using the Beacon API - Web APIs
server. beacon requests use http post and do not require a response. beacon requests are guaranteed to be initiated before the page unloads. this document contains examples of the beacon interfaces. see beacon api for an overview. navigator.sendbeacon() the beacon api's navigator.sendbeacon() method sends a beacon request to the server in the global browsing context. the method takes two
arguments: the url and the data to send. the data argument is optional and its type may be an arraybufferview, blob, domstring, or formdata. if the browser successfully queues the request for delivery, the method returns true and returns false otherwise. the following example specifies a handler for the load and beforeunload events. the handler calls sendbeacon() with the current url. window.onload = wi...
CSSStyleDeclaration.item() - Web APIs
syntax var propertyname = style.item(index); parameters index is the index of the node to be fetched. the index is zero-based. return value propertyname is a domstring that is the name of the css property at the specified index. ...
CSS Painting API - Web APIs
t using the registerpaint() function, tell the document to include the worklet using the paintworklet addmodule() method, then include the image we created using the css paint() function. ...
CanvasRenderingContext2D.createImageData() - Web APIs
gedata object. a negative value flips the rectangle around the horizontal axis. imagedata an existing imagedata object from which to copy the width and height. the image itself is not copied. return value a new imagedata object with the specified width and height. the new object is filled with transparent black pixels. errors thrown indexsizeerror thrown if either of the width or height
arguments is zero. examples creating a blank imagedata object this snippet creates a blank imagedata object using the createimagedata() method. html <canvas id="canvas"></canvas> javascript the generated object is 100 pixels wide and 50 pixels tall, making 5,000 pixels in all. each pixel within an imagedata object consists of four array values, so the object's data property has a length of 4 × 5...
CanvasRenderingContext2D.filter - Web APIs
a css <percentage>. adjusts the contrast of the drawing. a value of 0% will create a drawing that is completely black. a value of 100% leaves the drawing unchanged. drop-shadow() applies a drop shadow effect to the drawing. a drop shadow is effectively a blurred, offset version of the drawing's alpha mask drawn in a particular color, composited below the drawing. this function takes up to five
arguments: <offset-x>: see <length> for possible units. specifies the horizontal distance of the shadow. <offset-y>: see <length> for possible units. specifies the vertical distance of the shadow. <blur-radius>: the larger this value, the bigger the blur, so the shadow becomes bigger and lighter. negative values are not allowed. <color>: see <color> values for possible keywords and notations. ...
CanvasRenderingContext2D.putImageData() - Web APIs
. dirtyy optional vertical position (y coordinate) of the top-left corner from which the image data will be extracted. defaults to 0. dirtywidth optional width of the rectangle to be painted. defaults to the width of the image data. dirtyheight optional height of the rectangle to be painted. defaults to the height of the image data. errors thrown notsupportederror thrown if any of the
arguments is infinite. invalidstateerror thrown if the imagedata object's data has been detached. examples understanding putimagedata to understand what this algorithm does under the hood, here is an implementation on top of canvasrenderingcontext2d.fillrect(). html <canvas id="canvas"></canvas> javascript var canvas = document.getelementbyid('canvas'); var ctx = canvas.getcontext('2d'); functi...
CanvasRenderingContext2D.transform() - Web APIs
this lets you scale, rotate, translate (move), and skew the context. note: see also the settransform() method, which resets the current transform to the identity matrix and then invokes transform(). syntax void ctx.transform(a, b, c, d, e, f); the transformation matrix is described by: [acebdf001]\left[ \begin{array}{ccc} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{array} \right] parameters a (m11) horizontal scaling. a value of 1 results in no scaling. b (m12) vertical skewing. ...
CanvasRenderingContext2D - Web APIs
ians. canvasrenderingcontext2d.scale() adds a scaling transformation to the canvas units by x horizontally and by y vertically. canvasrenderingcontext2d.translate() adds a translation transformation by moving the canvas and its origin x horzontally and y vertically on the grid. canvasrenderingcontext2d.transform() multiplies the current transformation matrix with the matrix described by its
arguments. canvasrenderingcontext2d.settransform() resets the current transform to the identity matrix, and then invokes the transform() method with the same
arguments. canvasrenderingcontext2d.resettransform() resets the current transform by the identity matrix. compositing canvasrenderingcontext2d.globalalpha alpha value that is applied to shapes and images before they are composited onto the...
Drawing shapes with canvas - Web APIs
result looks like this: screenshotlive sample if you'd like to see the connecting lines, you can remove the lines that call moveto(). note: to learn more about the arc() function, see the arcs section below. lines for drawing straight lines, use the lineto() method. lineto(x, y) draws a line from the current drawing position to the position specified by x and y. this method takes two
arguments, x and y, which are the coordinates of the line's end point. the starting point is dependent on previously drawn paths, where the end point of the previous path is the starting point for the following, etc. the starting point can also be changed by using the moveto() method. the example below draws two triangles, one filled and one outlined. <html> <body onload="draw();"> <canvas id="canva...
Using channel messaging - Web APIs
by creating a new message channel by using the messagechannel() constructor. when the iframe has loaded, we register an onclick handler for our button and an onmessage handler for messagechannel.port1. finally we transfer messagechannel.port2 to the iframe using the window.postmessage method. let's explore how the iframe.contentwindow.postmessage line works in a bit more detail. it takes three
arguments: the message being sent. for this initial port transfering this message could be an empty string but in this example it is set to 'init'. the origin the message is to be sent to. * means "any origin". an object, the ownership of which is transferred to the receiving browsing context. in this case, we are transferring messagechannel.port2 to the iframe, so it can be used to communicate with t...
Channel Messaging API - Web APIs
or. once created, the two ports of the channel can be accessed through the messagechannel.port1 and messagechannel.port2 properties (which both return messageport objects.) the app that created the channel uses port1, and the app at the other end of the port uses port2 — you send a message to port2, and transfer the port over to the other browsing context using window.postmessage along with two
arguments (the message to send, and the object to transfer ownership of, in this case the port itself.) when these transferable objects are transferred, they are 'neutered' on the previous context — the one they previously belonged to. for instance a port, when is sent, cannot be used anymore by the original context. the other browsing context can listen for the message using messageport.onmessage, and...
ChildNode.before() - Web APIs
argitem : document.createtextnode(string(argitem))); }); this.parentnode.insertbefore(docfrag, this); } }); }); })([element.prototype, characterdata.prototype, documenttype.prototyp...
DOMTokenList.forEach() - Web APIs
currentindex the index of the current element being processed in the array. listobj the array that foreach() is being applied to. ...
DataTransfer.addElement() - Web APIs
the datatransfer.addelement() method sets the drag source to the given element. this element will be the element to which drag and dragend events are fired, and not the defaut target (the node that was dragged). note: this method is gecko-specific. syntax void datatransfer.addelement(el);
arguments el the element to set as the drag source. return value void example this example shows the use of the addelement() method function change_drag_node(event, node) { var dt = event.datatransfer; dt.addelement(node); } specifications this method is not defined in any web standard. ...
DataTransfer.clearData() - Web APIs
this method does not remove files from the drag operation, so it's possible for there still to be an entry with the type "files" left in the object's datatransfer.types list if there are any files included in the drag. ...
DataTransfer.mozClearDataAt() - Web APIs
if the format is not found, then this method has no effect. if the last format for the item is removed, the entire item is removed, reducing mozitemcount by one. removing the last format for a particular index removes that item entirely, shifting the remaining items down and changing their indices. note: this method is gecko-specific. syntax void datatransfer.mozcleardataat([type], index);
arguments type a string representing the type of the drag data to remove from the drag data object. index a unsigned long representing the index of the data to remove. return value void example this example shows the use of the mozcleardataat() method in a dragend event handler. function dragend_handler(event) { var dt = event.datatransfer; // remove a text/html item dt.mozcleardataa...
DataTransfer.mozGetDataAt() - Web APIs
the datatransfer.mozgetdataat() method is used to retrieve an item in the drag event's data transfer object, based on a given format and index. this method returns null if the specified item does not exist or if the index is not in the range from zero to the number of items minus one. note: this method is gecko-specific. syntax nsivariant datatransfer.mozgetdataat([type], index);
arguments type a string representing the type of the drag data to retrieve from the drag data object. index a unsigned long representing the index of the data to retrieve. return value nsivariant the data item requested. if the specified item does not exist, null is returned. example this example shows the use of the mozgetdataat() method in a drop event handler. function drop_handler(event) { va...
DataTransfer.mozSetDataAt() - Web APIs
the most specific format added first and the least specific format added last. if data of the given format already exists, it is replaced in the same position as the old data. the data should be either a string, a boolean or number type (which will be converted into a string) or an nsisupports. note: this method is gecko-specific. syntax void datatransfer.mozsetdataat([type], data, index);
arguments type a string representing the type of the drag data to add to the drag data object. data a nsivariant representing the data to add to the drag data object. index a unsigned long representing the index of the data to add. return value void example this example shows the use of the mozsetdataat() method in a dragstart handler. function dragstart_handler(event) { var dt = event...
DataTransfer.mozTypesAt() - Web APIs
the datatransfer.moztypesat() method returns a list of the format types that are stored for an item at the specified index. if the index is not in the range from 0 to the number of items minus one, an empty string list is returned. note: this method is gecko-specific. syntax nsivariant datatransfer.moztypesat(index);
arguments index a unsigned long that is the index of the data for which to retrieve the types. return value nsivariant a list of data formats (which are strings). if the index is not in the range from 0 to the number of items minus one, an empty string list is returned. example this example shows the use of the moztypesat() method in a drop event handler. function drop_handler(event) { var dt = event.datatransfer; var count = dt.mozitemcount; output("items:...
DataTransfer.setData() - Web APIs
is added at the end of the drag data store, such that the last item in the types list will be the new type. if data for the given type already exists, the existing data is replaced in the same position. that is, the order of the types list is not changed when replacing data of the same type. example data types are text/plain and text/uri-list. syntax void datatransfer.setdata(format, data);
arguments format a domstring representing the type of the drag data to add to the drag object. data a domstring representing the data to add to the drag object. return value void example this example shows the use of the datatransfer object's getdata(), setdata() and cleardata() methods. <!doctype html> <html lang=en> <title>examples of datatransfer's setdata(), getdata() and cleardata()</ti...
DataTransfer.setDragImage() - Web APIs
should appear relative to the mouse pointer. these coordinates define the offset into the image where the mouse cursor should be. for instance, to display the image so that the pointer is at its center, use values that are half the width and height of the image. this method must be called in the dragstart event handler. syntax void datatransfer.setdragimage(img | element, xoffset, yoffset);
arguments img | element an image element element to use for the drag feedback image. if element is an img element, then set the drag data store bitmap to the element's image (at its intrinsic size); otherwise, set the drag data store bitmap to an image generated from the given element (the exact mechanism for doing so is not currently specified). xoffset a long indicating the horizontal offset withi...
Document.open() - Web APIs
type specified the mime type of the data you are writing (e.g. text/html) and replace if set (i.e. a string of "replace") specified that the history entry for the new document would replace the current history entry of the document being written to. this form is now obsolete; it won't throw an error, but instead just forwards to document.open() (i.e. is the equivalent of just running it with no
arguments). the history-replacement behavior now always happens. specifications specification status comment html living standardthe definition of 'document.open()' in that specification. living standard document object model (dom) level 2 html specificationthe definition of 'document.open()' in that specification. obsolete ...
Events and the DOM - Web APIs
ation in the examples chapter for a more detailed example of how events move through the dom. registering event listeners there are 3 ways to register event handlers for a dom element. eventtarget.addeventlistener // assuming mybutton is a button element mybutton.addeventlistener('click', greet, false) function greet(event){ // print and have a look at the event object // always print
arguments in case of overlooking any other
arguments console.log('greet:',
arguments) alert('hello world') } this is the method you should use in modern web pages. note: internet explorer 6–8 didn't support this method, offering a similar eventtarget.attachevent api instead. for cross-browser compatibility, use one of the many javascript libraries available. more details can be found on the...
Traversing an HTML table with JavaScript and DOM Interfaces - Web APIs
body object (first item of the document object). create all the elements. finally, append each child according to the table structure (as in the above figure). the following source code is a commented version for the sample1.html. at the end of the start function, there is a new line of code. the table's border property was set using another dom method, setattribute(). setattribute() has two
arguments: the attribute name and the attribute value. you can set any attribute of any element using the setattribute method. <head> <title>sample code - traversing an html table with javascript and dom interfaces</title> <script> function start() { // get the reference for the body var mybody = document.getelementsbytagname("body")[0]; // creates <table> and <tbody> element...
DragEvent() - Web APIs
used to create a synthetic dragevent object. although this interface has a constructor, it is not possible to create a useful datatransfer object from script, since datatransfer objects have a processing and security model that is coordinated by the browser during drag-and-drops. this interface inherits properties from mouseevent and event. syntax event = new dragevent(type, drageventinit);
arguments type is a domstring representing the name of the event (see dragevent event types). drageventinitoptional is a drageventinit dictionary, having the following fields: "datatransfer", optional and defaults to "null". the type is datatransfer. the drageventinit dictionary inherits from the mouseeventinit dictionary. specifications specification status comment ...
Element.getElementsByTagName() - Web APIs
the element.getelementsbytagname() method returns a live htmlcollection of elements with the given tag name. all descendants of the specified element are searched, but not the element itself. the returned list is live, which means it updates itself with the dom tree automatically. therefore, there is no need to call element.getelementsbytagname() with the same element and
arguments repeatedly if the dom changes in between calls. when called on an html element in an html document, getelementsbytagname lower-cases the argument before searching for it. this is undesirable when trying to match camel-cased svg elements (such as <lineargradient>) in an html document. instead, use element.getelementsbytagnamens(), which preserves the capitalization of the tag name. element.getelementsbytagname is simil...
Element.msZoomTo() - Web APIs
implementations and the behavior may change in the future. the mszoomto method scrolls and/or zooms an element to its specified coordinate with animation. zoomed elements can expose their zoom level through mscontentzoom (ie. scrolltop/left). the zoom level can be reset with mszoomto. this proprietary method is specific to internet explorer and microsoft edge. syntax element.mszoomto(
arguments); parameters args[in] type: mszoomtooptions contentx[in]: the x-coordinate of the content that is the target of the scroll/zoom. if no value is specified, defaults to the current centerpoint of visible content, horizontally. contenty[in]: the y-coordinate of the content that is the target of the scroll/zoom. if no value is specified, defaults to the current centerpoint of visible content, v...
EventTarget.removeEventListener() - Web APIs
o use the same values used for the call to addeventlistener() when calling removeeventlistener(). notes if an eventlistener is removed from an eventtarget while it is processing an event, it will not be triggered by the current actions. an eventlistener will not be invoked for the event it was registered for after being removed. however, it can be reattached. calling removeeventlistener() with
arguments that do not identify any currently registered eventlistener on the eventtarget has no effect. example this example shows how to add a mouseover-based event listener that removes a click-based event listener. const body = document.queryselector('body') const clicktarget = document.getelementbyid('click-target') const mouseovertarget = document.getelementbyid('mouse-over-target') let toggle = f...
Using Fetch - Web APIs
similarly, redirect() returns a response resulting in a redirect to a specified url. these are also only relevant to service workers. body both requests and responses may contain body data. a body is an instance of any of the follow...
FileError - Web APIs
objects are passed to error callbacks. the objects have a code that shows the type of error that occurred. best practices most people don't read the page on errors and exceptions unless they're stumped. so the following are a few tips that could help you avoid some pitfalls. error callbacks are not optional for your sanity although error callbacks are optional, you should include them in the
arguments of the methods for the sake of the sanity of your users. a web app could fail for various reasons, so you don't want to spend the rest of your day guessing what's going on and going through maddening troubleshooting. don't run your app from file:// for security reasons, browsers do not allow you to run your app from file://. in fact, many of the powerful storage apis (such as file system, blobb...
FileHandle API - Web APIs
ting a filehandle instance requires an indexeddb database. var idbreq = indexeddb.open("myfilestoragedatabase"); idbreq.onsuccess = function(){ var db = this.result; var buildhandle = db.mozcreatefilehandle("test.txt", "plain/text"); buildhandle.onsuccess = function(){ var myfilehandle = this.result; console.log('handle', myfilehandle); }; }; mozcreatefilehandle() takes two
arguments: a name and an optional type. both of these are just descriptive and are not used by the database. however, they are important for the filehandle object as it can generate file objects which inherit their own name and type from those values. that said, as the name does not match any real filename it can be an empty string, for example, and it doesn't even have to be unique. note: the above code...
Geolocation API - Web APIs
ample, gps). the developer can now access this location information in a couple of different ways: geolocation.getcurrentposition(): retrieves the device's current location. geolocation.watchposition(): registers a handler function that will be called automatically each time the position of the device changes, returning the updated location. in both cases, the method call takes up to three
arguments: a mandatory success callback: if the location retrieval is successful, the callback executes with a geolocationposition object as its only parameter, providing access to the location data. an optional error callback: if the location retrieval is unsuccessful, the callback executes with a geolocationpositionerror object as its only parameter, providing access information on what went wrong. ...
HTMLCanvasElement.toBlob() - Web APIs
with the resulting blob object as a single argument. mimetype optional a domstring indicating the image format. the default type is image/png. qualityargument optional a number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp. if this argument is anything else, the default values 0.92 and 0.80 are used for image/jpeg and image/webp respectively. other
arguments are ignored. return value none. exceptions securityerror the canvas's bitmap is not origin clean; at least some of its contents come from secure examples getting a file representing the canvas once you have drawn content into a canvas, you can convert it into a file of any supported image format. the code snippet below, for example, takes the image in the <canvas> element whose id is ...
HTMLCanvasElement.toDataURL() - Web APIs
ptions); parameters type optional a domstring indicating the image format. the default format type is image/png. encoderoptions optional a number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp. if this argument is anything else, the default value for image quality is used. the default value is 0.92. other
arguments are ignored. return value a domstring containing the requested data uri. exceptions securityerror the canvas's bitmap is not origin clean; at least some of its contents have or may have been loaded from a site other than the one from which the document itself was loaded. examples given this <canvas> element: <canvas id="canvas" width="5" height="5"></canvas> you can get a data-url o...
HTMLCollection - Web APIs
note: this interface is called htmlcollection for historical reasons (before the modern dom, collections implementing this interface could only have html elements as their items). an htmlcollection in the html dom is live; it is automatically updated when the underlying document is changed. properties htmlcollection.length read only returns the number of items in the collection. methods htmlcollection.item() returns the specific node at the given zero-based index into the list. ...
HTMLKeygenElement - Web APIs
(if any). this is the empty string if the control is not a candidate for constraint validation (willvalidate is false), or it satisfies its constraints. validity read only is a validitystate representing the validity states that this element is in. willvalidate is a boolean that is always false because keygen objects are never candidates for constraint validation. methods name &
arguments return description checkvalidity() boolean always returns true because keygen objects are never candidates for constraint validation. setcustomvalidity(in domstring error) void sets a custom validity message for the element. if this message is not the empty string, then the element is suffering from a custom validity error, and does not validate. ...
HTMLTextAreaElement - Web APIs
eight: 100px; } html <form> <fieldset> <legend>your comments</legend> <p><textarea class="noscrollbars" onkeyup="autogrow(this);"></textarea></p> <p><input type="submit" value="send" /></p> </fieldset> </form> insert html tags example insert some html tags or smiles or any custom text in a textarea. ...
IDBCursor - Web APIs
eturns the idbrequest that was used to obtain the cursor. methods idbcursor.advance() sets the number of times a cursor should move its position forward. idbcursor.continue() advances the cursor to the next position along its direction, to the item whose key matches the optional key parameter. idbcursor.continueprimarykey() sets the cursor to the given index key and primary key given as
arguments. idbcursor.delete() returns an idbrequest object, and, in a separate thread, deletes the record at the cursor's position, without changing the cursor's position. this can be used to delete specific records. idbcursor.update() returns an idbrequest object, and, in a separate thread, updates the value at the current position of the cursor in the object store. this can be used to update speci...
IDBObjectStore.count() - Web APIs
note: this feature is available in web workers. syntax var request = objectstore.count(); var request = objectstore.count(query); parameters query optional a key or idbkeyrange object that specifies a range of records you want to count. ...
IDBObjectStore - Web APIs
ding new records to an object store. idbobjectstore.clear() creates and immediately returns an idbrequest object, and clears this object store in a separate thread. this is for deleting all current records out of an object store. idbobjectstore.count() returns an idbrequest object, and, in a separate thread, returns the total number of records that match the provided key or idbkeyrange. if no
arguments are provided, it returns the total number of records in the store. idbobjectstore.createindex() creates a new index during a version upgrade, returning a new idbindex object in the connected database. idbobjectstore.delete() returns an idbrequest object, and, in a separate thread, deletes the store object selected by the specified key. this is for deleting individual records out of an object ...
KeyboardEvent.initKeyEvent() - Web APIs
getelementbyid('blah').dispatchevent(event); specification this implementation of keyboard events is based on the key events spec in the early versions of dom 2 events, later removed from that spec. ...
KeyboardLayoutMap.forEach() - Web APIs
the foreach() method of the keyboardlayoutmap interface executes a provided function once for each element of the map. syntax keyboardlayoutmap.foreach(function callback(currentvalue[, index[, array]]) { //your iterator }[, thisarg]); parameters callback the function to execute for each element, taking three
arguments: currentvalue the value of the current element being processed. index optional the index of the current element being processed. array optional the keyboardlayoutmap that foreach() is being called on. thisarg optional value to use as this (i.e the reference object) when executing callback. return value undefined. specifications specification status comment keyboard mapthe definition of 'foreach()' in that speci...
MediaKeyStatusMap.forEach() - Web APIs
the foreach property of the mediakeystatusmap interface calls callback once for each key-value pair in the status map, in insertion order. if an argument is present it will be passed to the callback. syntax mediakeystatusmap.foreach(callback[, thisarg]) parameters callback function to execute for each element, taking three
arguments: currentvalue the current element being processed in the array. index the index of the current element being processed in the array. array which array foreach() is being applied to. thisarg optional value used as this when executing callback. returns undefined. specifications specification status comment encrypted media extensions recommendation initial definition. browser compatibility the compat...
MediaStreamTrackEvent() - Web APIs
the mediastreamtrackevent() constructor returns a newly created mediastreamtrackevent object, which represents an event announcing that a mediastreamtrack has been added to or removed from a mediastream. syntax var trackevent = new mediastreamtrackevent(type, {track: amediastreamtrack}); parameters the mediastreamtrackevent() constructor also inherits
arguments from event(). type a domstring representing the name of the type of the mediastreamtrackevent. it is case-sensitive and can be "addtrack" or "removetrack". track a mediastreamtrack object representing the track which was added to or removed from the stream. return value a new mediastreamtrackevent, initialized based on the provided options. specifications specification status comment media capture and...
MouseEvent.initMouseEvent() - Web APIs
ent. sets the value of mouseevent.metakey. button the event's mouse button. relatedtarget the event's related eventtarget. only used with some event types (e.g., mouseover and mouseout). in other cases, pass null. ...
Node.appendChild() - Web APIs
clonenode() method can be used to make a copy of the node before appending it under the new parent. note that the copies made with clonenode will not be automatically kept in sync. if the given child is a documentfragment, the entire contents of the documentfragment are moved into the child list of the specified parent node. newer api avaliable! the parentnode.append() method supports multiple
arguments and appending strings. syntax element.appendchild(achild) parameters achild the node to append to the given parent node (commonly an element). return value the returned value is the appended child (achild), except when achild is a documentfragment, in which case the empty documentfragment is returned. notes chaining may not work as expected, due to appendchild() returning the child e...
Node.setUserData() - Web APIs
userkey is used as the key by which one may subsequently obtain the stored data. more than one key can be set for a given node. handler is a callback which will be called any time the node is being cloned, imported, renamed, as well as if deleted or adopted; a function can be used or an object implementing the handle method (part of the userdatahandler interface). the handler will be passed five
arguments: an operation type integer (e.g., 1 to indicate a clone operation), the user key, the data on the node, the source node (null if being deleted), the destination node (the newly created node or null if none).if no handler is desired, one must specify null. userdata is the object to associate to userkey on somenode. if null, any previously registered object and userdatahandler associated to userke...
NodeList.item() - Web APIs
a value of null is returned if the index is out of range, and a typeerror is thrown if no argument is provided. syntax nodeitem = nodelist.item(index) nodelist is a nodelist. this is usually obtained from another dom property or method, such as childnodes. index is the index of the node to be fetched. the index is zero-based. nodeitem is the indexth node in the nodelist returned by the item method. ...
Notification.icon - Web APIs
rs. the icon read-only property of the notification interface contains the url of an icon to be displayed as part of the notification, as specified in the icon option of the notification() constructor. syntax var icon = notification.icon; value a usvstring. examples in our to-do list app (view the app running live), we use the notification() constructor to fire a notification, passing it
arguments to specify the body, icon and title we want. var notification = new notification('to do list', { body: text, icon: img }); specifications specification status comment notifications apithe definition of 'icon' in that specification. living standard living standard ...
OfflineAudioContext.OfflineAudioContext() - Web APIs
samplerate the sample-rate of the linear audio data in sample-frames per second. all user agents are required to support a range of 22050hz to 96000hz, and may support a wider range than that. the most commonly-used rate is 44100hz, which is the sample rate used by cd audio. it is important to note that, whereas you can create a new audiocontext using the new audiocontext() constructor with no
arguments, the offlineaudiocontext() constructor requires three
arguments, since it needs to create an audiobuffer. this works in exactly the same way as when you create a new audiobuffer with the audiocontext.createbuffer() method. for more detail, read audio buffers: frames, samples and channels from our basic concepts guide. return value a new offlineaudiocontext object whose associated audiobuffer is...
OffscreenCanvas.convertToBlob() - Web APIs
object, for example: const blob = offscreencanvas.converttoblob({ type: "image/jpeg", quality: 0.95 }); options: type: a domstring indicating the image format. the default type is image/png. quality: a number between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. if this argument is anything else, the default value for image quality is used. other
arguments are ignored. return value a promise returning a blob object representing the image contained in the canvas. examples var offscreen = new offscreencanvas(256, 256); var gl = offscreen.getcontext("webgl"); // ... some drawing using the gl context ... offscreen.converttoblob().then(function(blob) { console.log(blob); }); // blob { size: 334, type: "image/png" } specifications current...
OffscreenCanvas.convertToBlob() - Web APIs
object, for example: const blob = offscreencanvas.converttoblob({ type: "image/jpeg", quality: 0.95 }); options: type: a domstring indicating the image format. the default type is image/png. quality: a number between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. if this argument is anything else, the default value for image quality is used. other
arguments are ignored. return value a promise returning a blob object representing the image contained in the canvas. examples var offscreen = new offscreencanvas(256, 256); var gl = offscreen.getcontext("webgl"); // ... some drawing using the gl context ... offscreen.converttoblob().then(function(blob) { console.log(blob); }); // blob { size: 334, type: "image/png" } specifications ...
OffscreenCanvas.convertToBlob() - Web APIs
object, for example: const blob = offscreencanvas.converttoblob({ type: "image/jpeg", quality: 0.95 }); options: type: a domstring indicating the image format. the default type is image/png. quality: a number between 0 and 1 indicating image quality if the type option is image/jpeg or image/webp. if this argument is anything else, the default value for image quality is used. other
arguments are ignored. return value a promise returning a blob object representing the image contained in the canvas. examples var offscreen = new offscreencanvas(256, 256); var gl = offscreen.getcontext("webgl"); // ... some drawing using the gl context ... offscreen.converttoblob().then(function(blob) { console.log(blob); }); // blob { size: 334, type: "image/png" } specifications current...
PaintWorklet.registerPaint - Web APIs
the paintworklet.registerpaint() method of the paintworklet interface registers a class programmatically generate an image where a css property expects a file. syntax registerpaint(name, class); parameters name the name of the worklet class to register. class a reference to the class that implements the worklet. return value undefined exceptions typeerror thrown when one of the
arguments is invalid or missing. invalidmodificationerror thrown when the a worklet already exists with the specified name. examples the following shows registering an example worklet module. this should be in a separate js file. note that registerpaint() is called without a reference to paintworklet. the file itself is loaded through css.paintworklet.addmodule() (documented here on the parent class o...
ParentNode.append() - Web APIs
argitem : document.createtextnode(string(argitem))); }); this.appendchild(docfrag); } }); }); })([element.prototype, document.prototype, documentfragment.prototype]); specification...
ParentNode.prepend() - Web APIs
argitem : document.createtextnode(string(argitem))); }); this.insertbefore(docfrag, this.firstchild); } }); }); })([element.prototype, document.prototype, documentfragment.prototype...
PaymentRequest.onshippingaddresschange - Web APIs
triggered by a user-agent controlled interaction. if the address stored by the user agent changes at any time during a payment process, the event is triggered. to make sure an updated address is included when sending payment information to the server, you should add event listeners for a paymentrequest object after instantiation, but before the call to show(). // initialization of paymentrequest
arguments are excerpted for clarity. var payment = new paymentrequest(supportedinstruments, details, options); request.addeventlistener('shippingaddresschange', function(evt) { evt.updatewith(new promise(function(resolve) { updatedetails(details, request.shippingaddress, resolve); })); }); payment.show().then(function(paymentresponse) { // processing of paymentresponse exerpted for the same of ...
PaymentRequest.onshippingoptionchange - Web APIs
s triggered by a user-agent controlled interaction. if the option stored by the user agent changes at any time during a payment process, the event is triggered. to make sure an updated option is included when sending payment information to the server, you should add event listeners for a paymentrequest object after instantiation, but before the call to show(). // initialization of paymentrequest
arguments are excerpted for clarity. var request = new paymentrequest(supportedinstruments, details, options); // when user selects a shipping address request.addeventlistener('shippingaddresschange', e => { e.updatewith(((details, addr) => { var shippingoption = { id: '', label: '', amount: { currency: 'usd', value: '0.00' }, selected: true }; // shipping to us is su...
PaymentRequest.shippingAddress - Web APIs
can trigger this by setting paymentoptions.requestshipping to true when calling the paymentrequest constructor. in the example below, the cost of shipping varies by geography. when the paymentrequest.onshippingaddresschange is called, updatedetails() is called to update the details of the paymentrequest, using shippingaddress to set the correct shipping cost. // initialization of paymentrequest
arguments are excerpted for the sake of // brevity. var payment = new paymentrequest(supportedinstruments, details, options); payment.addeventlistener('shippingaddresschange', function(evt) { evt.updatewith(new promise(function(resolve) { updatedetails(details, request.shippingaddress, resolve); })); }); payment.show().then(function(paymentresponse) { // processing of paymentresponse exerpt...
PaymentRequest.show() - Web APIs
ction is complete. the developer then uses the information in the paymentresponse object to format and send payment data to the server. you should send the payment information to the server asynchronously so that the final call to paymentresponse.complete() can indicate the success or failure of the payment. button.onclick = async function handlepurchase() { // initialization of paymentrequest
arguments are excerpted for the sake of // brevity. const payment = new paymentrequest(methods, details, options); try { const response = await payment.show(); // process response here, including sending payment instrument // (e.g., credit card) information to the server. // paymentresponse.methodname contains the selected payment method // paymentresponse.details contains a payme...
PaymentResponse.complete() - Web APIs
has already completed, or complete() was called while a request to retry the payment is pending. you can't treat a payment as complete after requesting that the payment be tried again. examples the following example sends payment information to a secure server using the fetch api. it calls complete() with an answer appropriate to the status in the response. // initialization of paymentrequest
arguments are excerpted for the // sake of brevity. var payment = new paymentrequest(supportedinstruments, details, options); payment.show().then(function(paymentresponse) { var fetchoptions = { method: 'post', credentials: include, body: json.stringify(paymentresponse) }; var serverpaymentrequest = new request('secure/payment/endpoint'); fetch(serverpaymentrequest, fetchoptions).the...
PaymentResponse.shippingAddress - Web APIs
can trigger this by setting paymentoptions.requestshipping to true when calling the paymentrequest constructor. in the example below, the cost of shipping varies by geography. when the paymentrequest.onshippingaddresschange is called, updatedetails() is called to update the details of the paymentrequest, using shippingaddress to set the correct shipping cost. // initialization of paymentrequest
arguments are excerpted for brevity. var payment = new paymentrequest(supportedinstruments, details, options); request.addeventlistener('shippingaddresschange', function(evt) { evt.updatewith(new promise(function(resolve) { updatedetails(details, request.shippingaddress, resolve); })); }); payment.show().then(function(paymentresponse) { // processing of paymentresponse exerpted for the same of...
PaymentResponse.shippingOption - Web APIs
nt when the requestshipping option is set to true in the paymentoptions object passed to the paymentrequest constructor. syntax var shippingoption = paymentrequest.shippingoption; example in the example below, the paymentrequest.onshippingaoptionchange event is called. it calls updatedetails() to toggle the shipping method between "standard" and "express". // initialization of paymentrequest
arguments are excerpted for brevity. var payment = new paymentrequest(supportedinstruments, details, options); request.addeventlistener('shippingoptionchange', function(evt) { evt.updatewith(new promise(function(resolve, reject) { updatedetails(details, request.shippingoption, resolve, reject); })); }); payment.show().then(function(paymentresponse) { // processing of paymentresponse exerpted fo...
performance.clearResourceTimings() - Web APIs
sourcetimings() method removes all performance entries with an entrytype of "resource" from the browser's performance data buffer and sets the size of the performance data buffer to zero. to set the size of the browser's performance data buffer, use the performance.setresourcetimingbuffersize() method. note: this feature is available in web workers. syntax performance.clearresourcetimings();
arguments void return value none this method has no return value. example function load_resource() { var image = new image(); image.src = "https://developer.mozilla.org/static/img/opengraph-logo.png"; } function clear_performance_timings() { if (performance === undefined) { log("browser does not support web performance"); return; } // create a resource timing performance en...
performance.getEntriesByName() - Web APIs
the getentriesbyname() method returns a list of performanceentry objects for the given name and type. the list's members (entries) can be created by making performance marks or measures (for example by calling the mark() method) at explicit points in time. note: this feature is available in web workers. syntax entries = window.performance.getentriesbyname(name, type);
arguments name the name of the entry to retrieve. type optional the type of entry to retrieve such as "mark". the valid entry types are listed in performanceentry.entrytype. return value entries a list of performanceentry objects that have the specified name and type. if the type argument is not specified, only the name will be used to determine the entries to return. the items will be in chronological order based on...
performance.getEntriesByType() - Web APIs
the getentriesbytype() method returns a list of performanceentry objects for a given type. the list's members (entries) can be created by making performance marks or measures (for example by calling the mark() method) at explicit points in time. note: this feature is available in web workers. syntax entries = window.performance.getentriesbytype(type);
arguments type the type of entry to retrieve such as "mark". the valid entry types are listed in performanceentry.entrytype. return value entries a list of performanceentry objects that have the specified type. the items will be in chronological order based on the entries' starttime. if no objects have the specified type, or no argument is provided, an empty list is returned. example function useperformanceentrymethods() { log(...
performance.mark() - Web APIs
creates a timestamp in the browser's performance entry buffer with the given name. the application defined timestamp can be retrieved by one of the performance interface's getentries*() methods (getentries(), getentriesbyname() or getentriesbytype()). the mark()'s stores its data internally as performanceentry. note: this feature is available in web workers. syntax performance.mark(name);
arguments name a domstring representing the name of the mark. if the name given to this method already exists in the performancetiming interface, syntaxerror is thrown. return value void example the following example shows how to use mark() to create and retrieve performancemark entries. // create a bunch of marks. performance.mark("squirrel"); performance.mark("squirrel"); performance.mark(...
performance.measure() - Web APIs
- set to the start mark timestamp. duration - set to a domhighrestimestamp that is the duration of the measure (typically, the end mark timestamp minus the start mark timestamp). note: this feature is available in web workers. syntax performance.measure(name); performance.measure(name, startmark); performance.measure(name, startmark, endmark); performance.measure(name, undefined, endmark);
arguments name a domstring representing the name of the measure. startmark optional a domstring representing the name of the measure's starting mark. may also be the name of a performancetiming property. if it is omitted, then the start time will be the navigation start time. endmark optional a domstring representing the name of the measure's ending mark. may also be the name of a performancetiming...
performance.setResourceTimingBufferSize() - Web APIs
the setresourcetimingbuffersize() method sets the browser's resource timing buffer size to the specified number of "resource" performance entry type objects. a browser's recommended resource timing buffer size is at least 150 performance entry objects. note: this feature is available in web workers. syntax performance.setresourcetimingbuffersize(maxsize);
arguments maxsize a number representing the maximum number of performance entry objects the browser should hold in its performance entry buffer. return value none this method has no return value. example function setresourcetimingbuffersize(maxsize) { if (performance === undefined) { log("browser does not support web performance"); return; } var supported = typeof performance.setresourcetimingbuffersize == "functi...
performance.toJSON() - Web APIs
the tojson() method of the performance interface is a standard serializer: it returns a json representation of the performance object's properties. note: this feature is available in web workers. syntax myperf = performance.tojson()
arguments none return value myperf a json object that is the serialization of the performance object. example var js; js = window.performance.tojson(); console.log("json = " + json.stringify(js)); specifications specification status comment high resolution time level 2the definition of 'tojson() serializer' in that specification. recommendation defines tojson(). ...
PerformanceEntry.toJSON() - Web APIs
example the following example shows the use of the tojson() method. function run_performanceentry() { log("performanceentry support ..."); if (performance.mark === undefined) { log("... ...
PerformanceNavigationTiming.toJSON() - Web APIs
the tojson() method is a serializer - it returns a json representation of the performancenavigationtiming object. syntax json = resourceperfentry.tojson();
arguments none return value json a json object that is the serialization of the performancenavigationtiming object as a map with entries from the closest inherited interface and with entries for each of the serializable attributes. example // get a resource performance entry var perfentries = performance.getentriesbytype("navigation"); var entry = perfentries[0]; // get the json and log it var json = entry.tojson(); var s = json.stringify(json); console.log("performancenavigationtiming.tojson() = " + s); specifications specification status comment navigation timing level 2the definition of...
PerformanceResourceTiming.toJSON() - Web APIs
the tojson() method is a serializer that returns a json representation of the performanceresourcetiming object. syntax json = resourceperfentry.tojson();
arguments none return value json a json object that is the serialization of the performanceresourcetiming object as a map with entries from the closest inherited interface and with entries for each of the serializable attributes. example // get a resource performance entry var perfentries = performance.getentriesbytype("resource"); var entry = perfentries[0]; // get the json and log it var json = entry.tojson(); var s = json.stringify(json); console.log("performanceentry.tojson = " + s); specifications specification status comment resource timing level 2the definition of 'tojson' in that specification...
PointerEvent.PointerEvent() - Web APIs
pointereventinitoptional is a pointereventinit dictionary, having the following fields: pointerid — optional and defaulting to 0, of type long, that sets the value of the instance's pointerevent.pointerid. width — optional and defaulting to 1, of type double, that sets the value of the instance's pointerevent.width. ...
SVGLength - Web APIs
o be updated automatically to reflect this setting. exceptions on setting: a domexception with code syntax_err is raised if the assigned string cannot be parsed as a valid <length>. a domexception with code no_modification_allowed_err is raised when the length corresponds to a read only attribute or when the object itself is read only. methods name &
arguments return description newvaluespecifiedunits(in unsigned short unittype, in float valueinspecifiedunits) void reset the value as a number with an associated unittype, thereby replacing the values for all of the attributes on the object. exceptions: a domexception with code not_supported_err is raised if unittype is svg_lengthtype_unknown or not a valid u...
SVGLengthList - Web APIs
properties readonly unsigned long numberofitems readonly unsigned long length normative document svg 1.1 (2nd edition) properties name type description numberofitems unsigned long the number of items in the list. length unsigned long the number of items in the list. methods name &
arguments return description clear() void clears all existing current items from the list, with the result being an empty list. exceptions: a domexception with code no_modification_allowed_err is raised when the list corresponds to a read only attribute or when the object itself is read only. initialize(in svglength newitem) svglength cle...
SVGNumberList - Web APIs
operties readonly unsigned long numberofitems readonly unsigned long length normative document svg 1.1 (2nd edition) properties name type description numberofitems unsigned long the number of items in the list. length unsigned long the number of items in the list. methods name &
arguments return description clear() void clears all existing current items from the list, with the result being an empty list. exceptions: a domexception with code no_modification_allowed_err is raised when the list corresponds to a read only attribute or when the object itself is read only. initialize(in svgnumber newitem) svgnumber ...
SVGPointList - Web APIs
normative document svg 1.1 (2nd edition) properties name type description numberofitems unsigned long the number of items in the list. methods name &
arguments return description clear() void clears all existing current items from the list, with the result being an empty list. exceptions: a domexception with code no_modification_allowed_err is raised when the list corresponds to a read only attribute or when the object itself is read o...
SVGStringList - Web APIs
g numberofitems readonly unsigned long length normative document svg 1.1 (2nd edition) properties name type description numberofitems unsigned long the number of items in the list. length unsigned long a mirror of the value in numberofitems, for consistency with other interfaces. methods name &
arguments return description clear() void clears all existing current items from the list, with the result being an empty list. exceptions: a domexception with code no_modification_allowed_err is raised when the list corresponds to a read only attribute or when the object itself is read only. initialize(in domstring newitem) domstring ...
SVGStylable - Web APIs
tring classname readonly cssstyledeclaration style normative document svg 1.1 (2nd edition) properties name type description classname svganimatedstring corresponds to attribute class on the given element. style cssstyledeclaration corresponds to attribute style on the given element. methods name &
arguments return description getpresentationattribute(in domstring name) cssvalue returns the base (i.e., static) value of a given presentation attribute as an object of type cssvalue. the returned object is live; changes to the objects represent immediate changes to the objects to which the cssvalue is attached. browser compatibility the compatibility table on this page is...
SVGTransform - Web APIs
0, c=0, e=0 and f=0). for svg_transform_skewx and svg_transform_skewy, a, b, c and d represent the matrix which will result in the given skew (e=0 and f=0). for svg_transform_rotate, a, b, c, d, e and f together represent the matrix which will result in the given rotation. when the rotation is around the center point (0, 0), e and f will be zero. methods name &
arguments return description setmatrix(in svgmatrix matrix) void sets the transform type to svg_transform_matrix, with parameter matrix defining the new transformation. note that the values from the parameter matrix are copied. exceptions: a domexception with code no_modification_allowed_err is raised when attempting to modify a read only attribute or when the ...
SVGTransformList - Web APIs
operties readonly unsigned long numberofitems readonly unsigned long length normative document svg 1.1 (2nd edition) properties name type description numberofitems unsigned long the number of items in the list. length unsigned long the number of items in the list. methods name &
arguments return description clear() void clears all existing current items from the list, with the result being an empty list. exceptions: a domexception with code no_modification_allowed_err is raised when the list corresponds to a read only attribute or when the object itself is read only. initialize(in svgtransform newitem) svgtransform...
StylePropertyMapReadOnly.forEach() - Web APIs
the stylepropertymapreadonly.foreach() method executes a provided function once for each element of stylepropertymapreadonly. syntax stylepropertymapreadonly.foreach(function callback(currentvalue[, index[, array]]) { //your code }[, thisarg]); parameters callback the function to execute for each element, taking three
arguments: currentvalue the value of the current element being processed. indexoptional the index of the current element being processed. arrayoptional the stylepropertymapreadonly thatforeach() is being called on. thisarg optional value to use as this (i.e the reference object) when executing callback. return value undefined. example // tbd specifications specification status comment css typed om level 1the definiti...
SubtleCrypto.decrypt() - Web APIs
it returns a promise which will be fulfilled with the decrypted data (also known as "plaintext"). syntax const result = crypto.subtle.decrypt(algorithm, key, data); parameters algorithm is an object specifying the algorithm to be used, and any extra parameters as required. the values given for the extra parameters must match those passed into the corresponding encrypt() call. to use rsa-oaep, pass an rsaoaepparams object. to use aes-ctr, pass an aesctrparams object. ...
SubtleCrypto.deriveBits() - Web APIs
it returns a promise which will be fulfilled with an arraybuffer containing the derived bits. this method is very similar to subtlecrypto.derivekey(), except that derivekey() returns a cryptokey object rather than an arraybuffer. essentially derivekey() is composed of derivebits() followed by importkey(). this function supports the same derivation algorithms as derivekey(): ecdh, hkdf, and pbkdf2. ...
SubtleCrypto.deriveKey() - Web APIs
it returns a promise which will be fulfilled with a cryptokey object representing the new key. it's worth noting that the three key derivation algorithms you can use have quite different characteristics and are appropriate in quite different situations. see supported algorithms for some more detail on this. ...
SubtleCrypto.digest() - Web APIs
the digest() method of the subtlecrypto interface generates a digest of the given data. a digest is a short fixed-length value derived from some variable-length input. cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value. it takes as its
arguments an identifier for the digest algorithm to use and the data to digest. it returns a promise which will be fulfilled with the digest. syntax const digest = crypto.subtle.digest(algorithm, data); parameters algorithm is a domstring defining the hash function to use. supported values are: sha-1 (but don't use this in cryptographic applications) sha-256 sha-384 sha-512. data is an arraybuffer or arraybufferview containing the data ...
SubtleCrypto.encrypt() - Web APIs
it returns a promise which will be fulfilled with the encrypted data (also known as "ciphertext"). syntax const result = crypto.subtle.encrypt(algorithm, key, data); parameters algorithm is an object specifying the algorithm to be used and any extra parameters if required: to use rsa-oaep, pass an rsaoaepparams object. to use aes-ctr, pass an aesctrparams object. to use aes-cbc, pass an aescbcparams object. to use aes-gcm, pass an aesgcmparams object. ...
SubtleCrypto.sign() - Web APIs
it returns a promise which will be fulfilled with the signature. you can use the corresponding subtlecrypto.verify() method to verify the signature. syntax const signature = crypto.subtle.sign(algorithm, key, data); parameters algorithm is a string or object that specifies the signature algorithm to use and its parameters: to use rsassa-pkcs1-v1_5, pass the string "rsassa-pkcs1-v1_5" or an object of the form { "name": "rsassa-pkcs1-v1_5" }. to use rsa-pss, pass an rsapssparams object. ...
SubtleCrypto.verify() - Web APIs
it returns a promise which will be fulfilled with a boolean value indicating whether the signature is valid. syntax const result = crypto.subtle.verify(algorithm, key, signature, data); parameters algorithm is a domstring or object defining the algorithm to use, and for some algorithm choices, some extra parameters. the values given for the extra parameters must match those passed into the corresponding sign() call. ...
Touch() - Web APIs
"target", required, of type eventtarget, the item at which the touch point started when it was first placed on the surface. "clientx", optional and defaulting to 0, of type double, that is the horizontal position of the touch on the client window of user's screen, excluding any scroll offset. ...
TransitionEvent() - Web APIs
the transitionevent() constructor returns a newly created transitionevent, representing an event in relation with an transition. syntax transitionevent = new transitionevent(type, {propertyname: apropertyname, elapsedtime : afloat, pseudoelement: apseudoelementname});
arguments the transitionevent() constructor also inherits
arguments from event(). type is a domstring representing the name of the type of the transitionevent. it is case-sensitive and can only be: 'transitionend'. propertyname optional is a domstring containing the value of the property-name css property associated with the transition. it defaults to "". elapsedtime optional is float giving the amount of time the animation h...
TreeWalker - Web APIs
is a boolean indicating, when discarding an entityreference its whole sub-tree must be discarded at the same time. treewalker.currentnode is the node on which the treewalker is currently pointing at. methods this interface doesn't inherit any method. note: in the context of a treewalker, a node is visible if it exists in the logical view determined by the whattoshow and filter parameter
arguments. (whether or not the node is visible on the screen is irrelevant.) treewalker.parentnode() moves the current node to the first visible ancestor node in the document order, and returns the found node. it also moves the current node to this one. if no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed. t...
URL.searchParams - Web APIs
note: this feature is available in web workers. syntax const urlsearchparams = url.searchparams value a urlsearchparams object. examples if the url of your page is https://example.com/?name=jonathan%20smith&age=18 you could parse out the name and age parameters using: let params = (new url(document.location)).searchparams; let name = params.get('name'); // is the string "jonathan smith". ...
Using the User Timing API - Web APIs
if (i == 0) log("= getentriesbyname('measure-2', 'measure')", 1); log("... " + entries[i].name, 1); } } removing performance measures the performance.clearmeasures() method is used to remove measures from the browser's performance timeline. if the method is called with a specific measure name, all measures with that name will be removed from the timeline. if the method is called with no
arguments, all performance entries with a type of "measure" will be removed from the timeline. the following examples shows both uses of this method. function clear_measures(obj) { if (performance.clearmeasures === undefined) { log("clear mearsures: performance.clearmeasures not supported", 1); return; } log("clear measures", 1); if (typeof obj == "string") { log("... cleared '" + obj...
Clearing with colors - Web APIs
eaking those "dials" and "switches" you can modify the internal state of the webgl machine, which in turn changes how input (in this case, a clear command) translates into output (in this case, all pixels are set to green). finally, we note that color in webgl is usually in rgba format, that is four numerical components for red, green, blue and alpha (opacity). therefore, clearcolor() takes four
arguments. <p>a very simple webgl program that shows some color.</p> <!-- text within a canvas element is displayed only if canvas is not supported. --> <canvas>your browser does not seem to support html5 canvas.</canvas> body { text-align : center; } canvas { display : block; width : 280px; height : 210px; margin : auto; padding : 0; border : none; background-color : black; } ...
Establishing a connection: The WebRTC perfect negotiation pattern - Web APIs
a local description and send it using the signaling channel to the remote peer. let makingoffer = false; pc.onnegotiationneeded = async () => { try { makingoffer = true; await pc.setlocaldescription(); signaler.send({ description: pc.localdescription }); } catch(err) { console.error(err); } finally { makingoffer = false; } }; note that setlocaldescription() without
arguments automatically creates and sets the appropriate description based on the current signalingstate. the set description is either an answer to the most recent offer from the remote peer or a freshly-created offer if there's no negotiation underway. here, it will be always be an offer, because the negotiationneeded event is only fired in stable state. we set a boolean variable, makingoffer to true to...
window.location - Web APIs
is reloaded with the modified search string). example #6: using bookmarks without changing the hash property: <!doctype html> <html> <head> <meta charset="utf-8"/> <title>mdn example</title> <script> function shownode (onode) { document.documentelement.scrolltop = onode.offsettop; document.documentelement.scrollleft = onode.offsetleft; } function showbookmark (sbookmark, busehash) { if (
arguments.length === 1 || busehash) { location.hash = sbookmark; return; } var obookmark = document.queryselector(sbookmark); if (obookmark) { shownode(obookmark); } } </script> <style> span.intlink { cursor: pointer; color: #0000ff; text-decoration: underline; } </style> </head> <body> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. nullam ultrices dolor ac dolor imperdiet ull...
window.postMessage() - Web APIs
host (also known as the "same-origin policy"). window.postmessage() provides a controlled mechanism to securely circumvent this restriction (if used properly). broadly, one window may obtain a reference to another (e.g., via targetwindow = window.opener), and then dispatch a messageevent on it with targetwindow.postmessage(). the receiving window is then free to handle this event as needed. the
arguments passed to window.postmessage() (i.e., the “message”) are exposed to the receiving window through the event object. syntax targetwindow.postmessage(message, targetorigin, [transfer]); targetwindow a reference to the window that will receive the message. methods for obtaining such a reference include: window.open (to spawn a new window and then reference it), window.opener (to refer...
Window - Web APIs
ed in any browser.) deprecated properties window.content and window._content read only returns a reference to the content element in the current window. since firefox 57 (initially nightly-only), both versions are only available from chrome (privileged) code, and not available to the web anymore. window.defaultstatus gets/sets the status bar text for the given window. window.dialog
arguments read only gets the
arguments passed to the window (if it's a dialog box) at the time window.showmodaldialog() was called. this is an nsiarray. window.directories synonym of window.personalbar window.globalstorage multiple storage objects that were used for storing data across multiple pages. window.mozanimationstarttime the time in milliseconds since epoch at which the current...
Implementing a Microsoft Active Accessibility (MSAA) Server - Accessibility
ject_focus. when a potential accessibility-related event occurs within mozilla, it is typically listened for by nsdocaccessible or nsrootaccessible. the event listeners on these classes call firetoolkitevent(), which is implemented for every accessible. eventually, the event ends up at nsdocaccessiblewrap::firetoolkitevent() which calls notifywinevent from the win32 api. notifywinevent is passed
arguments for the window the event occurred in, and the id of the child within that window. accessibility aids use the win32 call setwineventhook() to register as a listener for these events. creating a unique child id for every object within a window can be difficult, see the problem and solution for no unique child id for object in window. the assistive technology chooses which events it is interested i...
:not() - CSS: Cascading Style Sheets
<ident-token> ] <attr-modifier>? ']'where <attr-matcher> = [ '~' | | | '^' | '$' | '*' ]? '='<attr-modifier> = i | s description there are several unusual effects and outcomes when using :not() that you should keep in mind when using it: the :not pseudo-class may not be nested, which means that :not(:not(...)) is invalid. since pseudo-elements are not simple selectors, they are not valid
arguments to :not(); thus, selectors like :not(p::before) will not work. useless selectors can be written using this pseudo-class. for example, :not(*) matches any element which is not an element, which is obviously nonsense, so the accompanying rule will never be applied. this pseudo-class can increase the specificity of a rule. for example, #foo:not(#bar) will match the same element as the simpler #foo...
:where() - CSS: Cascading Style Sheets
the :where() css pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list. the difference between :where() and :is() is that :where() always has 0 specificity, whereas :is() takes on the specificity of the most specific selector in its
arguments. examples comparing :where() and :is() this example shows how :where() works, and also illustrates the difference between :where() and :is(). take the following html: <article> <h2>:is()-styled links</h2> <section class="is-styling"> <p>here is my main content. this <a href="https://mozilla.org">contains a link</a>. </section> <aside class="is-styling"> <p>here is my aside content. this <a href="https://developer.mozilla.org">also contains...
Selector list - CSS: Cascading Style Sheets
that the following aren't equivalent: h1 { font-family: sans-serif } h2:maybe-unsupported { font-family: sans-serif } h3 { font-family: sans-serif } h1, h2:maybe-unsupported, h3 { font-family: sans-serif } this is because a single unsupported selector in a selector list invalidates the whole rule. a way to remedy this us to use the :is() selector, which simply ignores invalid selectors in its
arguments, but at the cost of all selectors having the same specificity, because of how :is() calculates specificity. h1 { font-family: sans-serif } h2:maybe-unsupported { font-family: sans-serif } h3 { font-family: sans-serif } :is(h1, h2:maybe-unsupported, h3) { font-family: sans-serif } specifications specification status comment selectors level 4the definition of 'select...
calc() - CSS: Cascading Style Sheets
send us a pull request. syntax /* property: calc(expression) */ width: calc(100% - 80px); the calc() function takes a single expression as its parameter, with the expression's result used as the value. the expression can be any simple expression combining the following operators, using standard operator precedence rules: + addition. - subtraction. * multiplication. at least one of the
arguments must be a <number>. / division. the right-hand side must be a <number>. the operands in the expression may be any <length> syntax value. you can use different units for each value in your expression, if you wish. you may also use parentheses to establish computation order when needed. notes the + and - operators must be surrounded by whitespace. for instance, calc(50% -8px) will be parsed...
clamp() - CSS: Cascading Style Sheets
id argument type (like <length>), or nested min() and max() functions. as math expressions, so you can use addition, subtraction, multiplication and division without using the calc() function itself. you may also use parentheses to establish computation order when needed. you can use different units for each value in your expressions, and different units in any math function making up any of the
arguments. notes math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables may be treated as if auto had been specified. it is permitted to nest max() and min() functions as expression values, in which case the inner ones are treated as simple parentheses. the expressions are f...
min() - CSS: Cascading Style Sheets
e addition ( + ), subtraction ( - ), multiplication ( * ) and division ( / ) operators, using standard operator precedence rules. make sure to put a space on each side of the + and - operands. the operands in the expression may be any <length> syntax value. you can (and often need to) combine min() and max() values, or use min() within a clamp() or calc() function. you can provide more than two
arguments, if you have multiple constraints to apply. formal syntax min( <calc-sum># )where <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]*where <calc-product> = <calc-value> [ '*' <calc-value> | '/' <number> ]*where <calc-value> = <number> | <dimension> | <percentage> | ( <calc-sum> ) accessibility concerns when using min() to set a maximum font size, ensure that the font can still be...
repeating-linear-gradient() - CSS: Cascading Style Sheets
the function's result is an object of the <gradient> data type, which is a special kind of <image>. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
set:intersection() - EXSLT
xslt/xpath reference: xslt elements, exslt functions, xpath functions, xpath axes set:intersection() returns the intersection of two node-sets. in other words, it returns a node-set containing all the nodes that exits in both nodeset1 and nodeset2. syntax set:intersection(nodeset1, nodeset2)
arguments nodeset1 the first node-set. nodeset2 the second node-set. returns a node-set containing the nodes that existed in both nodeset1 and in nodeset2. specifications exslt - set:intersection ...
Overview of events and handlers - Developer guides
ts emitted in response to user input or browser activity. modern web browsers follow the event pattern using a standardized approach. browsers use as the data structure for the properties of the event, an object derived from the eventprototype object. browsers use as the registration method for the function which will handle those data structures a method called addeventlistener which expects as
arguments a string event type name and the handler function. finally, browsers define a large number of objects as event emitters and define a wide variety of event types generated by the objects. button event handler demo for example, browser <button> elements are intended to emit events named 'click' in response to a mouse click or, when displayed in touch sensitive surfaces, to a finger tap. we could ...
DASH Adaptive Streaming for HTML 5 Video - HTML: Hypertext Markup Language
the -adaptation_sets argument assigns them into adaptation sets; for example, this creates one set (0) that contains the streams 0, 1, 2 and 3 (the videos), and another set (1) that contains only stream 4, the audio stream. put the manifest and the associated video files on your web server or cdn. da...
<script>: The Script element - HTML: Hypertext Markup Language
er compatibility for notes on browser support. see also async scripts for asm.js. crossorigin normal script elements pass minimal information to the window.onerror for scripts which do not pass the standard cors checks. to allow error logging for sites which use a separate domain for static media, use this attribute. see cors settings attributes for a more descriptive explanation of its valid
arguments. defer this boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed, but before firing domcontentloaded. scripts with the defer attribute will prevent the domcontentloaded event from firing until the script has loaded and finished evaluating. this attribute must not be used if the src attribute is absent (i.e. for inli...
Content-Disposition - HTTP
t should be downloaded; most browsers presenting a 'save as' dialog, prefilled with the value of the filename parameters if present). content-disposition: inline content-disposition: attachment content-disposition: attachment; filename="filename.jpg" as a header for a multipart body the first parameter in the http context is always form-data. additional parameters are case-insensitive and have
arguments that use quoted-string syntax after the '=' sign. multiple parameters are separated by a semi-colon (';'). content-disposition: form-data content-disposition: form-data; name="fieldname" content-disposition: form-data; name="fieldname"; filename="filename.jpg" directives name is followed by a string containing the name of the html field in the form that the content of this subpart refers to...
CSP: base-uri - HTTP
use the value in the <base> element. csp version 2 directive type document directive default-src fallback no. not setting this allows any url. syntax one or more sources can be allowed for the base-uri policy: content-security-policy: base-uri <source>; content-security-policy: base-uri <source> <source>; sources while this directive uses the same
arguments as other csp directives, some of them don’t make sense for `<base>`, such as the keywords 'unsafe-inline' and 'strict-dynamic' <source> can be one of the following: <host-source> internet hosts by name or ip address, as well as an optional url scheme and/or port number. the site's address may include an optional leading wildcard (the asterisk character, '*'), and you may use a wildcard (a...
CSS Houdini
frameworks needed. <script> css.paintworklet.addmodule('csscomponent.js'); </script> this added module contains registerpaint() functions, which register completely configurable worklets. the css paint() function parameters include the name of the worklet, along with optional parameters. the worklet also has access to the element's custom properties: they don't need to be passed as function
arguments. li { background-image: paint(mycomponent, stroke, 10px); --highlights: blue; --lowlights: green; } note: with great power comes great responsibility! with houdini you could invent your own masonry, grid, or regions implementation, but doing so is not necessarily the best idea. the css working group does a lot of work to ensure every feature is performant, handles all edge cases, and ...
Grammar and types - JavaScript
erals floating-point literals numeric literals object literals regexp literals string literals array literals an array literal is a list of zero or more expressions, each of which represents an array element, enclosed in square brackets ([]). when you create an array using an array literal, it is initialized with the specified values as its elements, and its length is set to the number of
arguments specified. the following example creates the coffees array with three elements and a length of three: let coffees = ['french roast', 'colombian', 'kona']; note : an array literal is a type of object initializer. see using object initializers. if an array is created using a literal in a top-level script, javascript interprets the array each time it evaluates the expression containing the ar...
Loops and iteration - JavaScript
efore, it is better to use a traditional for loop with a numeric index when iterating over arrays, because the for...in statement iterates over user-defined properties in addition to the array elements, if you modify the array object (such as adding custom properties or methods). for...of statement the for...of statement creates a loop iterating over iterable objects (including array, map, set,
arguments object and so on), invoking a custom iteration hook with statements to be executed for the value of each distinct property. for (variable of object) statement the following example shows the difference between a for...of loop and a for...in loop. while for...in iterates over property names, for...of iterates over property values: const arr = [3, 5, 7]; arr.foo = 'hello'; for (let i in arr)...
Meta programming - JavaScript
e as those of the proxy handlers. reflect is not a function object. reflect helps with forwarding default operations from the handler to the target. with reflect.has() for example, you get the in operator as a function: reflect.has(object, 'assign') // true a better apply function in es5, you typically use the function.prototype.apply() method to call a function with a given this value and
arguments provided as an array (or an array-like object). function.prototype.apply.call(math.floor, undefined, [1.75]) with reflect.apply this becomes less verbose and easier to understand: reflect.apply(math.floor, undefined, [1.75]) // 1 reflect.apply(string.fromcharcode, undefined, [104, 101, 108, 108, 111]) // "hello" reflect.apply(regexp.prototype.exec, /ab/, ['confabulation']).index // 4 refle...
JavaScript Guide - JavaScript
basic syntax & comments declarations variable scope variable hoisting data structures and types literals control flow and error handling if...else switch try/catch/throw error objects loops and iteration for while do...while break/continue for..in for..of functions defining functions calling functions function scope closures
arguments & parameters arrow functions expressions and operators assignment & comparisons arithmetic operators bitwise & logical operators conditional (ternary) operator numbers and dates number literals number object math object date object text formatting string literals string object template literals internationalization regular expressions indexed col...
The legacy Iterator protocol - JavaScript
and the iterator protocol. the deprecated firefox-only iterator protocol firefox, prior to version 26 implemented another iterator protocol that is similar to the standard es2015 iterator protocol. an object is an legacy iterator when it implements a next() method with the following semantics, and throws stopiteration at the end of iteration. property value next a zero
arguments function that returns an value. difference between legacy and es2015 iterator protocols the value was returned directly as a return value of calls to next, instead of the value property of a placeholder object iteration termination was expressed by throwing a stopiteration object. simple example with the old protocol function makeiterator(array){ var nextindex = 0; return {...
Warning: String.x is deprecated; use String.prototype.x instead - JavaScript
ercase', 'normalize', 'tolocaleuppercase', 'localecompare', 'match', 'search', 'slice', 'replace', 'split', 'substr', 'concat', 'localecompare' ], methodcount = methods.length, assignstringgeneric = function(methodname) { var method = string.prototype[methodname]; string[methodname] = function(arg1) { return method.apply(arg1, array.prototype.slice.call(
arguments, 1)); }; }; for (i = 0; i < methodcount; i++) { assignstringgeneric(methods[i]); } }()); ...
SyntaxError: missing formal parameter - JavaScript
ting; }; // syntaxerror: missing formal parameter function log({ obj: "value"}) { console.log(arg) }; // syntaxerror: missing formal parameter you will need to use identifiers in function declarations: function square(number) { return number * number; }; function greet(greeting) { return greeting; }; function log(arg) { console.log(arg) }; you can then call these functions with the
arguments you like: square(2); // 4 greet("howdy"); // "howdy" log({obj: "value"}); // object { obj: "value" } ...
getter - JavaScript
hat property actually hold a value, although it is possible to use a getter and a setter in conjunction to create a type of pseudo-property. note the following when working with the get syntax: it can have an identifier which is either a number or a string; it must have exactly zero parameters (see incompatible es5 change: literal getter and setter functions must now have exactly zero or one
arguments for more information); it must not appear in an object literal with another get or with a data entry for the same property ({ get x() { }, get x() { } } and { x: ..., get x() { } } are forbidden). examples defining a getter on new objects in object initializers this will create a pseudo-property latest for object obj, which will return the last array item in log. const obj = { log: ['exam...
setter - JavaScript
ith getters to create a type of pseudo-property. it is not possible to simultaneously have a setter on a property that holds an actual value. note the following when working with the set syntax: it can have an identifier which is either a number or a string; it must have exactly one parameter (see incompatible es5 change: literal getter and setter functions must now have exactly zero or one
arguments for more information); it must not appear in an object literal with another set or with a data entry for the same property. ( { set x(v) { }, set x(v) { } } and { x: ..., set x(v) { } } are forbidden ) examples defining a setter on new objects in object initializers the following example define a pseudo-property current of object language. when current is assigned a value, it updates log ...
Array.prototype.copyWithin() - JavaScript
ar len = o.length >>> 0; // steps 6-8. var relativetarget = target >> 0; var to = relativetarget < 0 ? math.max(len + relativetarget, 0) : math.min(relativetarget, len); // steps 9-11. var relativestart = start >> 0; var from = relativestart < 0 ? math.max(len + relativestart, 0) : math.min(relativestart, len); // steps 12-14. var end =
arguments[2]; var relativeend = end === undefined ? len : end >> 0; var final = relativeend < 0 ? math.max(len + relativeend, 0) : math.min(relativeend, len); // step 15. var count = math.min(final - from, len - to); // steps 16-17. var direction = 1; if (from < to && to < (from + count)) { direction = -1; from += count - 1; to += count - 1; ...
Array.prototype.fill() - JavaScript
in the array will reference that object. polyfill if (!array.prototype.fill) { object.defineproperty(array.prototype, 'fill', { value: function(value) { // steps 1-2. if (this == null) { throw new typeerror('this is null or not defined'); } var o = object(this); // steps 3-5. var len = o.length >>> 0; // steps 6-7. var start =
arguments[1]; var relativestart = start >> 0; // step 8. var k = relativestart < 0 ? math.max(len + relativestart, 0) : math.min(relativestart, len); // steps 9-10. var end =
arguments[2]; var relativeend = end === undefined ? len : end >> 0; // step 11. var finalvalue = relativeend < 0 ? math.max(len + relativeend, 0) : ...
Array.prototype.flatMap() - JavaScript
a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax var new_array = arr.flatmap(function callback(currentvalue[, index[, array]]) { // return element for new_array }[, thisarg]) parameters callback function that produces an element of the new array, taking three
arguments: currentvalue the current element being processed in the array. indexoptional the index of the current element being processed in the array. arrayoptional the array map was called upon. thisargoptional value to use as this when executing callback. return value a new array with each element being the result of the callback function and flattened to a depth of 1. descript...
Array.prototype.includes() - JavaScript
a', -100) // true arr.includes('b', -100) // true arr.includes('c', -100) // true arr.includes('a', -2) // false includes() used as a generic method includes() method is intentionally generic. it does not require this value to be an array object, so it can be applied to other kinds of objects (e.g. array-like objects). the example below illustrates includes() method called on the function's
arguments object. (function() { console.log(array.prototype.includes.call(
arguments, 'a')) // true console.log(array.prototype.includes.call(
arguments, 'd')) // false })('a','b','c') please do not add polyfills on reference articles. for more details and discussion, see https://discourse.mozilla.org/t/mdn-rfc-001-mdn-wiki-pages-shouldnt-be-a-distributor-of-polyfills/24500 specifications ...
Array.prototype.join() - JavaScript
three elements, then joins the array four times: using the default separator, then a comma and a space, then a plus and an empty string. var a = ['wind', 'water', 'fire']; a.join(); // 'wind,water,fire' a.join(', '); // 'wind, water, fire' a.join(' + '); // 'wind + water + fire' a.join(''); // 'windwaterfire' joining an array-like object the following example joins array-like object (
arguments), by calling function.prototype.call on array.prototype.join. function f(a, b, c) { var s = array.prototype.join.call(
arguments); console.log(s); // '1,a,true' } f(1, 'a', true); //expected output: "1,a,true" specifications specification ecmascript (ecma-262)the definition of 'array.prototype.join' in that specification. ...
Array.prototype.push() - JavaScript
where to start inserting the given values. if the length property cannot be converted into a number, the index used is 0. this includes the possibility of length being nonexistent, in which case length will also be created. although strings are native, array-like objects, they are not suitable in applications of this method, as strings are immutable. similarly for the native, array-like object
arguments. examples adding elements to an array the following code creates the sports array containing two elements, then appends two elements to it. the total variable contains the new length of the array. let sports = ['soccer', 'baseball'] let total = sports.push('football', 'swimming') console.log(sports) // ['soccer', 'baseball', 'football', 'swimming'] console.log(total) // 4 merging two ar...
Array.prototype.sort() - JavaScript
to all different elements. note: the ecmascript standard does not guarantee this behavior, thus, not all browsers (e.g. mozilla versions dating back to at least 2003) respect this. if comparefunction(a, b) returns greater than 0, sort b to an index lower than a (i.e. b comes first). comparefunction(a, b) must always return the same value when given a specific pair of elements a and b as its two
arguments. if inconsistent results are returned, then the sort order is undefined. so, the compare function has the following form: function compare(a, b) { if (a is less than b by some ordering criterion) { return -1; } if (a is greater than b by the ordering criterion) { return 1; } // a must be equal to b return 0; } to compare numbers instead of strings, the compare function ca...
Array.prototype.unshift() - JavaScript
esembling arrays. objects which do not contain a length property—reflecting the last in a series of consecutive, zero-based numerical properties—may not behave in any meaningful manner. please note that, if multiple elements are passed as parameters, they're inserted in chunk at the beginning of the object, in the exact same order they were passed as parameters. hence, calling unshift with n
arguments once, or calling it n times with 1 argument (with a loop, for example), don't yield the same results. see example: let arr = [4, 5, 6] arr.unshift(1, 2, 3) console.log(arr); // [1, 2, 3, 4, 5, 6] arr = [4, 5, 6] // resetting the array arr.unshift(1) arr.unshift(2) arr.unshift(3) console.log(arr) // [3, 2, 1, 4, 5, 6] examples using unshift let arr = [1, 2] arr.unshift(0) ...
Array - JavaScript
ctor array() creates a new array object. static properties get array[@@species] the constructor function is used to create derived objects. static methods array.from() creates a new array instance from an array-like or iterable object. array.isarray() returns true if the argument is an array, or false otherwise. array.of() creates a new array instance with a variable number of
arguments, regardless of number or type of the
arguments. instance properties array.prototype.length reflects the number of elements in an array. array.prototype[@@unscopables] a symbol containing property names to exclude from a with binding scope. instance methods array.prototype.concat() returns a new array that is this array joined with other array(s) and/or value(s). array.prototype.cop...
AsyncFunction - JavaScript
nbody a string containing the javascript statements comprising the function definition. description async function objects created with the asyncfunction constructor are parsed when the function is created. this is less efficient than declaring an async function with an async function expression and calling it within your code, because such functions are parsed with the rest of the code. all
arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed. note: async functions created with the asyncfunction constructor do not create closures to their creation contexts; they are always created in the global scope. when running them, they will only be able to access their own local variables an...
BigInt.prototype.toLocaleString() - JavaScript
thod returns a string with a language-sensitive representation of this bigint. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax bigintobj.tolocalestring([locales [, options]]) parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations that ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation-dependent. see the intl.numberformat() constructor for details on these parameters and how to use them. return value a strin...
BigInt64Array - JavaScript
ue of the element size. 8 in the case of a bigint64array. bigint64array.name returns the string value of the constructor name. in the case of the bigint64array type, this is "bigint64array". static methods bigint64array.from() creates a new bigint64array from an array-like or iterable object. see also array.from(). bigint64array.of() creates a new bigint64array with a variable number of
arguments. see also array.of(). instance properties bigint64array.prototype.buffer returns the arraybuffer referenced by the bigint64array. this is fixed at construction time and thus read only. bigint64array.prototype.bytelength returns the length (in bytes) of the bigint64array from the start of its arraybuffer. this is fixed at construction time and thus read only. bigint64array.prototype.byteo...
BigUint64Array - JavaScript
he element size. 8 in the case of a biguint64array. biguint64array.name returns the string value of the constructor name. in the case of the biguint64array type this is "biguint64array". static methods biguint64array.from() creates a new biguint64array from an array-like or iterable object. see also array.from(). biguint64array.of() creates a new biguint64array with a variable number of
arguments. see also array.of(). instance properties biguint64array.prototype.buffer returns the arraybuffer referenced by the biguint64array. this is fixed at construction time and thus read only. biguint64array.prototype.bytelength returns the length (in bytes) of the biguint64array from the start of its arraybuffer. this is fixed at construction time and thus read only. biguint64array.prototype.
Date.UTC() - JavaScript
he expected range, the utc() method updates the other parameters to accommodate the value. for example, if 15 is used for month, the year will be incremented by 1 (year + 1) and 3 will be used for the month. utc() is a static method of date, so it's called as date.utc() rather than as a method of a date instance. examples using date.utc() the following statement creates a date object with the
arguments treated as utc instead of local: let utcdate = new date(date.utc(2018, 11, 1, 0, 0, 0)); specifications specification ecmascript (ecma-262)the definition of 'date.utc' in that specification. ...
Error - JavaScript
thods, but only when they are declared with object.defineproperty(). otherwise, old versions of babel and other transpilers will not correctly handle the following code without additional configuration. some browsers include the customerror constructor in the stack trace when using es2015 classes. ...
Float32Array - JavaScript
ns a number value of the element size. 4 in the case of an float32array. float32array.name returns the string value of the constructor name. in the case of the float32array type: "float32array". static methods float32array.from() creates a new float32array from an array-like or iterable object. see also array.from(). float32array.of() creates a new float32array with a variable number of
arguments. see also array.of(). instance properties float32array.prototype.buffer returns the arraybuffer referenced by the float32array fixed at construction time and thus read only. float32array.prototype.bytelength returns the length (in bytes) of the float32array from the start of its arraybuffer. fixed at construction time and thus read only. float32array.prototype.byteoffset returns the off...
Float64Array - JavaScript
ns a number value of the element size. 8 in the case of an float64array. float64array.name returns the string value of the constructor name. in the case of the float64array type: "float64array". static methods float64array.from() creates a new float64array from an array-like or iterable object. see also array.from(). float64array.of() creates a new float64array with a variable number of
arguments. see also array.of(). instance properties float64array.prototype.buffer returns the arraybuffer referenced by the float64array fixed at construction time and thus read only. float64array.prototype.bytelength returns the length (in bytes) of the float64array from the start of its arraybuffer. fixed at construction time and thus read only. float64array.prototype.byteoffset returns the off...
Function.caller - JavaScript
aller property returns the function that invoked the specified function. it returns null for strict, async function and generator function callers. description if the function f was invoked by the top level code, the value of f.caller is null, otherwise it's the function that called f. it's also null for strict, async function and generator function callers. this property replaces the obsolete
arguments.caller property of the
arguments object. the special property __caller__, which returned the activation object of the caller thus allowing to reconstruct the stack, was removed for security reasons. notes note that in case of recursion, you can't reconstruct the call stack using this property. consider: function f(n) { g(n - 1); } function g(n) { if (n > 0) { f(n); } else { stop(); } } f(2); ...
Function.length - JavaScript
like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. property attributes of function.length writable no enumerable no configurable yes description length is a property of a function object, and indicates how many
arguments the function expects, i.e. the number of formal parameters. this number excludes the rest parameter and only includes parameters before the first one with a default value. by contrast,
arguments.length is local to a function and provides the number of
arguments actually passed to the function. data property of the function constructor the function constructor is itself a function object. its le...
GeneratorFunction - JavaScript
a string containing the javascript statements comprising the function definition. description generator function objects created with the generatorfunction constructor are parsed when the function is created. this is less efficient than declaring a generator function with a function* expression and calling it within your code, because such functions are parsed with the rest of the code. all
arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed. note: generator function created with the generatorfunction constructor do not create closures to their creation contexts; they are always created in the global scope. when running them, they will only be able to access their own local varia...
Int16Array - JavaScript
r_element returns a number value of the element size. 2 in the case of an int16array. int16array.name returns the string value of the constructor name. in the case of the int16array type: "int16array". static methods int16array.from() creates a new int16array from an array-like or iterable object. see also array.from(). int16array.of() creates a new int16array with a variable number of
arguments. see also array.of(). instance properties int16array.prototype.buffer returns the arraybuffer referenced by the int16array fixed at construction time and thus read only. int16array.prototype.bytelength returns the length (in bytes) of the int16array from the start of its arraybuffer. fixed at construction time and thus read only. int16array.prototype.byteoffset returns the offset (in by...
Int32Array - JavaScript
r_element returns a number value of the element size. 4 in the case of an int32array. int32array.name returns the string value of the constructor name. in the case of the int32array type: "int32array". static methods int32array.from() creates a new int32array from an array-like or iterable object. see also array.from(). int32array.of() creates a new int32array with a variable number of
arguments. see also array.of(). instance properties int32array.prototype.buffer returns the arraybuffer referenced by the int32array fixed at construction time and thus read only. int32array.prototype.bytelength returns the length (in bytes) of the int32array from the start of its arraybuffer. fixed at construction time and thus read only. int32array.prototype.byteoffset returns the offset (in by...
Int8Array - JavaScript
bytes_per_element returns a number value of the element size. 1 in the case of an int8array. int8array.name returns the string value of the constructor name. in the case of the int8array type: "int8array". static methods int8array.from() creates a new int8array from an array-like or iterable object. see also array.from(). int8array.of() creates a new int8array with a variable number of
arguments. see also array.of(). instance properties int8array.prototype.buffer returns the arraybuffer referenced by the int8array fixed at construction time and thus read only. int8array.prototype.bytelength returns the length (in bytes) of the int8array from the start of its arraybuffer. fixed at construction time and thus read only. int8array.prototype.byteoffset returns the offset (in bytes) ...
Intl.DateTimeFormat() constructor - JavaScript
the default value for each date-time component property is undefined, but if all component properties are undefined, then year, month, and day are assumed to be "numeric". examples using datetimeformat in basic use without specifying a locale, datetimeformat uses the default locale and default options. ...
Intl - JavaScript
ve time formatting. static methods intl.getcanonicallocales() returns canonical locale names. locale identification and negotiation the internationalization constructors as well as several language sensitive methods of other constructors (listed under see also) use a common pattern for identifying locales and determining the one they will actually use: they all accept locales and options
arguments, and negotiate the requested locale(s) against the locales they support using an algorithm specified in the options.localematcher property. locales argument the locales argument requests that a particular locale (or a locale from a list of them) be considered for use in a given operation. a single locale may be specified by either an intl.locale object or a string that is a unicode bcp 47 loca...
JSON.parse() - JavaScript
value computed by parsing is transformed before being returned. specifically, the computed value and all its properties (beginning with the most nested properties and proceeding to the original value itself) are individually run through the reviver. then it is called, with the object containing the property being processed as this, and with the property name as a string, and the property value as
arguments. if the reviver function returns undefined (or returns no value, for example, if execution falls off the end of the function), the property is deleted from the object. otherwise, the property is redefined to be the return value. if the reviver only transforms some values and not others, be certain to return all untransformed values as-is, otherwise, they will be deleted from the resulting object...
JSON.stringify() - JavaScript
ranteed to be stringified in any particular order. do not rely on ordering of properties within the same object within the stringification. ...
Math.atan2() - JavaScript
e of the point return value the angle in radians (in [-π,π][-\pi, \pi]) between the positive x-axis and the ray from (0,0) to the point (x,y). description the math.atan2() method returns a numeric value between -π and π representing the angle theta of an (x, y) point. this is the counterclockwise angle, measured in radians, between the positive x axis, and the point (x, y). note that the
arguments to this function pass the y-coordinate first and the x-coordinate second. math.atan2() is passed separate x and y
arguments, and math.atan() is passed the ratio of those two
arguments. because atan2() is a static method of math, you always use it as math.atan2(), rather than as a method of a math object you created (math is not a constructor). examples using math.atan2() math.atan2(90, 15)...
Math.imul() - JavaScript
ters. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax var product = math.imul(a, b); parameters a first number. b second number. return value the result of the c-like 32-bit multiplication of the given
arguments. description math.imul() allows for 32-bit integer multiplication with c-like semantics. this feature is useful for projects like emscripten. because imul() is a static method of math, you always use it as math.imul(), rather than as a method of a math object you created (math is not a constructor). if you use normal javascript floating point numbers in imul, you will experience a degrade in pe...
Math.min() - JavaScript
l be selected and returned. return value the smallest of the given numbers. if any one or more of the parameters cannot be converted into a number, nan is returned. the result is infinity if no parameters are provided. description because min() is a static method of math, you always use it as math.min(), rather than as a method of a math object you created (math is not a constructor). if no
arguments are given, the result is infinity. if at least one of
arguments cannot be converted to a number, the result is nan. examples using math.min() this finds the min of x and y and assigns it to z: var x = 10, y = -20; var z = math.min(x, y); clipping a value with math.min() math.min() is often used to clip a value so that it is always less than or equal to a boundary. for instance, this var ...
Object.assign() - JavaScript
t be writable: true, enumerable: false, configurable: true object.defineproperty(object, "assign", { value: function assign(target, varargs) { // .length of function is 2 'use strict'; if (target === null || target === undefined) { throw new typeerror('cannot convert undefined or null to object'); } var to = object(target); for (var index = 1; index <
arguments.length; index++) { var nextsource =
arguments[index]; if (nextsource !== null && nextsource !== undefined) { for (var nextkey in nextsource) { // avoid bugs when hasownproperty is shadowed if (object.prototype.hasownproperty.call(nextsource, nextkey)) { to[nextkey] = nextsource[nextkey]; } } } } ...
Object.defineProperty() - JavaScript
, function, etc). defaults to undefined. writable true if and only if the value associated with the property may be changed with an assignment operator. defaults to false. an accessor descriptor also has the following optional keys: get a function which serves as a getter for the property, or undefined if there is no getter. when the property is accessed, this function is called without
arguments and with this set to the object through which the property is accessed (this may not be the object on which the property is defined due to inheritance). the return value will be used as the value of the property. defaults to undefined. set a function which serves as a setter for the property, or undefined if there is no setter. when the property is assigned, this function is called with one ar...
Object.prototype.toString() - JavaScript
me for big integers let bignum = bigint(20); console.log(bignum.tostring(2)); // expected output is "10100" some common radix are 2 for binary numbers, 8 for octal numbers, 10 for decimal numbers, 16 for hexadecimal numbers. examples overriding the default tostring method you can create a function to be called in place of the default tostring() method. the tostring() method takes no
arguments and should return a string. the tostring() method you create can be any value you want, but it will be most useful if it carries information about the object. the following code defines the dog object type and creates thedog, an object of type dog: function dog(name, breed, color, sex) { this.name = name; this.breed = breed; this.color = color; this.sex = sex; } thedog = new dog('gabby...
Object.prototype.valueOf() - JavaScript
the object itself. you can use valueof within your own code to convert a built-in object into a primitive value. when you create a custom object, you can override object.prototype.valueof() to call a custom method instead of the default object method. overriding valueof for custom objects you can create a function to be called in place of the default valueof method. your function must take no
arguments. suppose you have an object type mynumbertype and you want to create a valueof method for it. the following code assigns a user-defined function to the object's valueof method: mynumbertype.prototype.valueof = function() { return customprimitivevalue; }; with the preceding code in place, any time an object of type mynumbertype is used in a context where it is to be represented as a primitive v...
Promise - JavaScript
romises, they can be chained. not to be confused with: several other languages have mechanisms for lazy evaluation and deferring a computation, which they also call "promises", e.g. scheme. promises in javascript represent processes that are already happening, which can be chained with callback functions. if you are looking to lazily evaluate an expression, consider the arrow function with no
arguments: f = () => expression to create the lazily-evaluated expression, and f() to evaluate. note: a promise is said to be settled if it is either fulfilled or rejected, but not pending. you will also hear the term resolved used with promises — this means that the promise is settled or “locked in” to match the state of another promise. states and fates contains more details about promise termin...
Proxy - JavaScript
static methods proxy.revocable() creates a revocable proxy object. examples basic example in this simple example, the number 37 gets returned as the default value when the property name is not in the ob...
Reflect - JavaScript
s a function. all properties and methods of reflect are static (just like the math object). the reflect object provides the following static functions which have the same names as the proxy handler methods. some of these methods are also the same as corresponding methods on object, although they do have some subtle differences between them. static methods reflect.apply(target, thisargument,
argumentslist) calls a target function with
arguments as specified by the
argumentslist parameter. see also function.prototype.apply(). reflect.construct(target,
argumentslist[, newtarget]) the new operator as a function. equivalent to calling new target(...
argumentslist). also provides the option to specify a different prototype. reflect.defineproperty(target, propertykey, attributes) similar to obje...
RegExp.prototype[@@match]() - JavaScript
cription this method is called internally in string.prototype.match(). for example, the following two examples return same result. 'abc'.match(/a/); /a/[symbol.match]('abc'); this method exists for customizing match behavior within regexp subclasses. examples direct call this method can be used in almost the same way as string.prototype.match(), except the different this and the different
arguments order. let re = /[0-9]+/g; let str = '2016-01-02'; let result = re[symbol.match](str); console.log(result); // ["2016", "01", "02"] using @@match in subclasses subclasses of regexp can override the [@@match]() method to modify the default behavior. class myregexp extends regexp { [symbol.match](str) { let result = regexp.prototype[symbol.match].call(this, str); if (!result) return...
RegExp.prototype[@@matchAll]() - JavaScript
y in string.prototype.matchall(). for example, the following two examples return same result. 'abc'.matchall(/a/); /a/[symbol.matchall]('abc'); this method exists for customizing the behavior of matchall() in regexp subclasses. examples direct call this method can be used in almost the same way as string.prototype.matchall(), except for the different value of this and the different order of
arguments. let re = /[0-9]+/g; let str = '2016-01-02'; let result = re[symbol.matchall](str); console.log(array.from(result, x => x[0])); // ["2016", "01", "02"] using @@matchall in subclasses subclasses of regexp can override the [@@matchall]() method to modify the default behavior. for example, to return an array instead of an iterator: class myregexp extends regexp { [symbol.matchall](str) { ...
RegExp.prototype[@@search]() - JavaScript
this method is called internally in string.prototype.search(). for example, the following two examples return the same result. 'abc'.search(/a/); /a/[symbol.search]('abc'); this method exists for customizing the search behavior in regexp subclasses. examples direct call this method can be used in almost the same way as string.prototype.search(), except the different this and the different
arguments order. var re = /-/g; var str = '2016-01-02'; var result = re[symbol.search](str); console.log(result); // 4 using @@search in subclasses subclass of regexp can override [@@search]() method to modify the behavior. class myregexp extends regexp { constructor(str) { super(str) this.pattern = str; } [symbol.search](str) { return str.indexof(this.pattern); } } var re = new ...
RegExp.prototype[@@split]() - JavaScript
object that has a @@split method, such as a regexp. for example, the following two examples return the same result. 'a-b-c'.split(/-/); /-/[symbol.split]('a-b-c'); this method exists for customizing the behavior of split() in regexp subclass. examples direct call this method can be used in almost the same way as string.prototype.split(), except the different this and the different order of
arguments. let re = /-/g; let str = '2016-01-02'; let result = re[symbol.split](str); console.log(result); // ["2016", "01", "02"] using @@split in subclasses subclasses of regexp can override the [@@split]() method to modify the default behavior. class myregexp extends regexp { [symbol.split](str, limit) { let result = regexp.prototype[symbol.split].call(this, str, limit); return result.ma...
RegExp - JavaScript
regular expression pattern will be changing, or you don't know the pattern and obtain it from another source, such as user input. flags in constructor starting with ecmascript 6, new regexp(/ab+c/, 'i') no longer throws a typeerror ("can't supply flags when constructing one regexp from another") when the first argument is a regexp and the second flags argument is present. a new regexp from the
arguments is created instead. when using the constructor function, the normal string escape rules (preceding special characters with \ when included in a string) are necessary. for example, the following are equivalent: let re = /\w+/ let re = new regexp('\\w+') perl-like regexp properties note that several of the regexp properties have both long and short (perl-like) names. both names always refer t...
String.prototype.slice() - JavaScript
ing is upon us' this example counts backwards from the end of the string by 11 to find the start index and forwards from the start of the string by 16 to find the end index. console.log(str.slice(-11, 16)) // => "is u" here it counts forwards from the start by 11 to find the start index and backwards from the end by 7 to find the end index. console.log(str.slice(11, -7)) // => " is u" these
arguments count backwards from the end by 5 to find the start index and backwards from the end by 1 to find the end index. console.log(str.slice(-5, -1)) // => "n us" specifications specification ecmascript (ecma-262)the definition of 'string.prototype.slice' in that specification. ...
Symbol.iterator - JavaScript
for an object. used by for...of. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. description whenever an object needs to be iterated (such as at the beginning of a for..of loop), its @@iterator method is called with no
arguments, and the returned iterator is used to obtain the values to be iterated. some built-in types have a default iteration behavior, while other types (such as object) do not. the built-in types with a @@iterator method are: array.prototype[@@iterator]() typedarray.prototype[@@iterator]() string.prototype[@@iterator]() map.prototype[@@iterator]() set.prototype[@@iterator]() see also iteration...
TypedArray.prototype.copyWithin() - JavaScript
the end argument is optional and defaults to the length of the array. this method has the same algorithm as array.prototype.copywithin. typedarray is one of the typed array types here. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
TypedArray.prototype.fill() - JavaScript
es and send us a pull request. syntax typedarray.fill(value[, start = 0[, end = this.length]]) parameters value value to fill the typed array with. start optional. start index. defaults to 0. end optional. end index (not included). defaults to this.length. return value the modified array. description the elements interval to fill is [start, end). the fill method takes up to three
arguments value, start and end. the start and end
arguments are optional with default values of 0 and the length of the this object. if start is negative, it is treated as length+start where length is the length of the array. if end is negative, it is treated as length+end. polyfill since there is no global object with the name typedarray, polyfilling must be done on an "as needed" basis. use the follo...
TypedArray.of() - JavaScript
this method is nearly the same as array.of(). the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax typedarray.of(element0[, element1[, ...[, elementn]]]) where typedarray is one of: int8array uint8array uint8clampedarray int16array uint16array int32array uint32array float32array float64array bigint64array biguint64array parameters elementn elements of which to create the typed array. return value a new typedarray instance. ...
TypedArray.prototype.toLocaleString() - JavaScript
by a locale-specific string (such as a comma “,”). this method has the same algorithm as array.prototype.tolocalestring() and, as the typed array elements are numbers, the same algorithm as number.prototype.tolocalestring() applies for each element. typedarray is one of the typed array types here. syntax typedarray.tolocalestring([locales [, options]]); parameters the locales and options
arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. in implementations, which ignore the locales and options
arguments, the locale used and the form of the string returned are entirely implementation dependent. see the intl.numberformat() constructor for details on these parameters and how to use them. return value a st...
TypedArray - JavaScript
s the string value of the constructor name (e.g, "int8array"). get typedarray[@@species] the constructor function used to create derived objects. typedarray.prototype prototype for typedarray objects. static methods typedarray.from() creates a new typedarray from an array-like or iterable object. see also array.from(). typedarray.of() creates a new typedarray with a variable number of
arguments. see also array.of(). instance properties typedarray.prototype.buffer returns the arraybuffer referenced by the typed array. fixed at construction time and thus read only. typedarray.prototype.bytelength returns the length (in bytes) of the typed array. fixed at construction time and thus read only. typedarray.prototype.byteoffset returns the offset (in bytes) of the typed array from th...
Uint16Array - JavaScript
t returns a number value of the element size. 2 in the case of an uint16array. uint16array.name returns the string value of the constructor name. in the case of the uint16array type: "uint16array". static methods uint16array.from() creates a new uint16array from an array-like or iterable object. see also array.from(). uint16array.of() creates a new uint16array with a variable number of
arguments. see also array.of(). instance properties uint16array.prototype.buffer returns the arraybuffer referenced by the uint16array fixed at construction time and thus read only. uint16array.prototype.bytelength returns the length (in bytes) of the uint16array from the start of its arraybuffer. fixed at construction time and thus read only. uint16array.prototype.byteoffset returns the offset (...
Uint32Array - JavaScript
t returns a number value of the element size. 4 in the case of an uint32array. uint32array.name returns the string value of the constructor name. in the case of the uint32array type: "uint32array". static methods uint32array.from() creates a new uint32array from an array-like or iterable object. see also array.from(). uint32array.of() creates a new uint32array with a variable number of
arguments. see also array.of(). instance properties uint32array.prototype.buffer returns the arraybuffer referenced by the uint32array fixed at construction time and thus read only. uint32array.prototype.bytelength returns the length (in bytes) of the uint32array from the start of its arraybuffer. fixed at construction time and thus read only. uint32array.prototype.byteoffset returns the offset (...
Uint8Array - JavaScript
r_element returns a number value of the element size. 1 in the case of an uint8array. uint8array.name returns the string value of the constructor name. in the case of the uint8array type: "uint8array". static methods uint8array.from() creates a new uint8array from an array-like or iterable object. see also array.from(). uint8array.of() creates a new uint8array with a variable number of
arguments. see also array.of(). instance properties uint8array.prototype.buffer returns the arraybuffer referenced by the uint8array fixed at construction time and thus read only. uint8array.prototype.bytelength returns the length (in bytes) of the uint8array. fixed at construction time and thus read only. uint8array.prototype.byteoffset returns the offset (in bytes) of the uint8array from the st...
Uint8ClampedArray - JavaScript
in the case of an uint8clampedarray. uint8clampedarray.name returns the string value of the constructor name. in the case of the uint8clampedarray type: "uint8clampedarray". static methods uint8clampedarray.from() creates a new uint8clampedarray from an array-like or iterable object. see also array.from(). uint8clampedarray.of() creates a new uint8clampedarray from a variable number of
arguments. see also array.of(). instance properties uint8clampedarray.prototype.buffer returns the arraybuffer referenced by the uint8clampedarray fixed at construction time and thus read only. uint8clampedarray.prototype.bytelength returns the length (in bytes) of the uint8clampedarray from the start of its arraybuffer. fixed at construction time and thus read only. uint8clampedarray.prototype.by...
WeakSet.prototype.add() - JavaScript
mples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax ws.add(value); parameters value required. the object to add to the weakset collection. return value the weakset object. examples using add var ws = new weakset(); ws.add(window); // add the window object to the weakset ws.has(window); // true // weakset only takes objects as
arguments ws.add(1); // results in "typeerror: invalid value used in weak set" in chrome // and "typeerror: 1 is not a non-null object" in firefox specifications specification ecmascript (ecma-262)the definition of 'weakset.prototype.add' in that specification. ...
isNaN() - JavaScript
represent overflow conditions. a nan also results from attempted coercion to numeric values of non-numeric values for which no primitive numeric value is available. for example, dividing zero by zero results in a nan — but dividing other numbers by zero does not. confusing special-case behavior since the very earliest versions of the isnan function specification, its behavior for non-numeric
arguments has been confusing. when the argument to the isnan function is not of type number, the value is first coerced to a number. the resulting value is then tested to determine whether it is nan. thus for non-numbers that when coerced to numeric type result in a valid non-nan numeric value (notably the empty string and boolean primitives, which when coerced give numeric values zero or one), the "false"...
parseFloat() - JavaScript
ment are ignored. if the argument’s first character can’t be converted to a number (it’s not any of the above characters), parsefloat returns nan. parsefloat can also parse and return infinity. parsefloat converts bigint syntax to numbers, losing precision. this happens because the trailing n character is discarded. consider number(value) for stricter parsing, which converts to nan for
arguments with invalid characters anywhere. parsefloat will parse non-string objects if they have a tostring or valueof method. the returned value is the same as if parsefloat had been called on the result of those methods. examples parsefloat returning a number the following examples all return 3.14: parsefloat(3.14); parsefloat('3.14'); parsefloat(' 3.14 '); parsefloat('314e-2'); parsefloat('0.031...
Standard built-in objects - JavaScript
e ecmascript core for language-sensitive functionalities. intl intl.collator intl.datetimeformat intl.listformat intl.numberformat intl.pluralrules intl.relativetimeformat intl.locale webassembly webassembly webassembly.module webassembly.instance webassembly.memory webassembly.table webassembly.compileerror webassembly.linkerror webassembly.runtimeerror other
arguments ...
Iteration protocols - JavaScript
s up its prototype chain) must have a property with a @@iterator key which is available via constant symbol.iterator: property value [symbol.iterator] a zero-argument function that returns an object, conforming to the iterator protocol. whenever an object needs to be iterated (such as at the beginning of a for...of loop), its @@iterator method is called with no
arguments, and the returned iterator is used to obtain the values to be iterated. note that when this zero-argument function is called, it is invoked as a method on the iterable object. therefore inside of the function, the this keyword can be used to access the properties of the iterable object, to decide what to provide during the iteration. this function can be an ordinary function, or it can be a gen...
Lexical grammar - JavaScript
is an identifiername without the reserved words. identifiers are used for functiondeclaration, functionexpression, variabledeclaration and so on. identifiernames are used for memberexpression, callexpression and so on. function import() {} // illegal. identifiers with special meanings a few identifiers have a special meaning in some contexts without being keywords of any kind. they include:
arguments get set literals null literal see also null for more information. null boolean literal see also boolean for more information. true false numeric literals the number and bigint types use numeric literals. decimal 1234567890 42 // caution when using with a leading zero: 0888 // 888 parsed as decimal 0777 // parsed as octal, 511 in decimal note that decimal literals can start with a...
Comma operator (,) - JavaScript
ressions, the last of which is returned as the value of the compound expression. usage notes you can use the comma operator when you want to include multiple expressions in a location that requires a single expression. the most common usage of this operator is to supply multiple parameters in a for loop. the comma operator is fully different from the comma within arrays, objects, and function
arguments and parameters. examples if a is a 2-dimensional array with 10 elements on each side, the following code uses the comma operator to increment i and decrement j at once. the following code prints the values of the diagonal elements in the array: for (var i = 0, j = 9; i <= 9; i++, j--) console.log('a[' + i + '][' + j + '] = ' + a[i][j]); note that the comma operators in assignments may appe...
function* expression - JavaScript
://github.com/mdn/interactive-examples and send us a pull request. syntax function* [name]([param1[, param2[, ..., paramn]]]) { statements } parameters name optional the function name. can be omitted, in which case the function is anonymous. the name is only local to the function body. paramn optional the name of an argument to be passed to the function. a function can have up to 255
arguments. statements the statements which comprise the body of the function. description a function* expression is very similar to and has almost the same syntax as a function* statement. the main difference between a function* expression and a function* statement is the function name, which can be omitted in function* expressions to create anonymous generator functions. see also the chapter about fu...
Function expression - JavaScript
e definition isn't. so it's undefined. nothoisted(); // typeerror: nothoisted is not a function var nothoisted = function() { console.log('bar'); }; named function expression if you want to refer to the current function inside the function body, you need to create a named function expression. this name is then local only to the function body (scope). this also avoids using the non-standard
arguments.callee property. let math = { 'factit': function factorial(n) { console.log(n) if (n <= 1) { return 1; } return n * factorial(n - 1); } }; math.factit(3) //3;2;1; the variable the function expression is assigned to will have a name property. the name doesn't change if it's assigned to a different variable. if function name is omitted, it will be the variable name (im...
yield* - JavaScript
r.next()); // {value: 2, done: false} console.log(iterator.next()); // {value: 3, done: false} console.log(iterator.next()); // {value: 4, done: false} console.log(iterator.next()); // {value: 5, done: false} console.log(iterator.next()); // {value: undefined, done: true} other iterable objects besides generator objects, yield* can also yield other kinds of iterables (e.g., arrays, strings, or
arguments objects). function* g3() { yield* [1, 2]; yield* '34'; yield* array.from(
arguments); } const iterator = g3(5, 6); console.log(iterator.next()); // {value: 1, done: false} console.log(iterator.next()); // {value: 2, done: false} console.log(iterator.next()); // {value: "3", done: false} console.log(iterator.next()); // {value: "4", done: false} console.log(iterator.next()); // {value: 5, ...
Expressions and operators - JavaScript
r operators provide access to a property or method of an object (object.property and object["property"]). new the new operator creates an instance of a constructor. new.target in constructors, new.target refers to the constructor that was invoked by new. super the super keyword calls the parent constructor. ...obj spread syntax allows an expression to be expanded in places where multiple
arguments (for function calls) or multiple elements (for array literals) are expected. increment and decrement postfix/prefix increment and postfix/prefix decrement operators. a++ postfix increment operator. a-- postfix decrement operator. ++a prefix increment operator. --a prefix decrement operator. unary operators a unary operation is operation with only one operand. delete the delete...
for await...of - JavaScript
it invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object. like the await operator, the statement can only be used inside an async function. for await...of doesn't work with async iterators that are not async iterables. ...
function* - JavaScript
with yield* function* anothergenerator(i) { yield i + 1; yield i + 2; yield i + 3; } function* generator(i) { yield i; yield* anothergenerator(i); yield i + 10; } var gen = generator(10); console.log(gen.next().value); // 10 console.log(gen.next().value); // 11 console.log(gen.next().value); // 12 console.log(gen.next().value); // 13 console.log(gen.next().value); // 20 passing
arguments into generators function* loggenerator() { console.log(0); console.log(1, yield); console.log(2, yield); console.log(3, yield); } var gen = loggenerator(); // the first call of next executes from the start of the function // until the first yield statement gen.next(); // 0 gen.next('pretzel'); // 1 pretzel gen.next('california'); // 2 california gen.next('mayonnaise'); /...
function declaration - JavaScript
interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax function name([param[, param,[..., param]]]) { [statements] } name the function name. param optional the name of an argument to be passed to the function. maximum number of
arguments varies in different engines. statements optional the statements which comprise the body of the function. description a function created with a function declaration is a function object and has all the properties, methods and behavior of function objects. see function for detailed information on functions. a function can also be created using an expression (see function expression). by d...
Template literals (Template strings) - JavaScript
-collapser') }`; in es2015 with nested template literals: const classes = `header ${ islargescreen() ? '' : `icon-${item.iscollapsed ? 'expander' : 'collapser'}` }`; tagged templates a more advanced form of template literals are tagged templates. tags allow you to parse template literals with a function. the first argument of a tag function contains an array of string values. the remaining
arguments are related to the expressions. the tag function can then perform whatever operations on these
arguments you wish, and return the manipulated string. (alternatively, it can return something completely different, as described in one of the following examples.) the name of the function used for the tag can be whatever you want. let person = 'mike'; let age = 28; function mytag(strings, personex...
Trailing commas - JavaScript
railing commas in object literals are legal as well: var object = { foo: "bar", baz: "qwerty", age: 42, }; trailing commas in functions ecmascript 2017 allows trailing commas in function parameter lists. parameter definitions the following function definition pairs are legal and equivalent to each other. trailing commas don't affect the length property of function declarations or their
arguments object. function f(p) {} function f(p,) {} (p) => {}; (p,) => {}; the trailing comma also works with method definitions for classes or objects: class c { one(a,) {} two(a, b,) {} } var obj = { one(a,) {}, two(a, b,) {}, }; function calls the following function invocation pairs are legal and equivalent to each other. f(p); f(p,); math.max(10, 20); math.max(10, 20,); illegal tr...
<mroot> - MathML
attributes class, id, style provided for use with stylesheets. href used to set a hyperlink to a specified url. mathbackground the background color. you can use #rgb, #rrggbb and html color names. mathcolor the text color and also the color of the root symbol itself. you can use #rgb, #rrggbb and html color names. ...
<mrow> - MathML
when writing a mathml expression, you should group elements within an <mrow> in the same way as they are grouped in the mathematical interpretation of the expression. proper grouping helps the rendering of the expression in several ways: it can improve the display by possibly affecting spacing. it allows for more intelligent line-breaking and indentation. ...