implementing new webapis
Post on 18-Oct-2014
1.776 views
DESCRIPTION
This session gives a rough overview how to implement new WebAPIs in JS and C++.TRANSCRIPT
![Page 1: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/1.jpg)
IMPLEMENTING NEW WEBAPISGregor Wagner (gwagnermozillacom)
Julian Viereck (jviereckmozillacom)
DISCALIMER
bull No API designingstandadization here
bull Talk about making the implementation happen
bull 55rdquo not enough to get you going
bull Reach out to us and do ldquohands-onrdquo hacking
OUTLINEbull General Introduction
bull How To Implement New API
bull JS
bull C++
bull Make your work land
bull QampA
GENERAL INTRODUCTION
GENERAL INTRODUCTIONbull Build on two previous presentations
bull JS David Dahlrsquos ldquoFrom Web Developer to Firefox Hackerrdquo [1]
bull C++ Bobby Holleyrsquos ldquoHacking Geckordquo [2]
bull [1] httppeoplemozillacom~ddahlpagesHackingFirefoxtemplatehtml
bull [2] httppeoplemozillacom~bholleyhacking-gecko-fosdem2012hacking-geckohtml
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 2: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/2.jpg)
DISCALIMER
bull No API designingstandadization here
bull Talk about making the implementation happen
bull 55rdquo not enough to get you going
bull Reach out to us and do ldquohands-onrdquo hacking
OUTLINEbull General Introduction
bull How To Implement New API
bull JS
bull C++
bull Make your work land
bull QampA
GENERAL INTRODUCTION
GENERAL INTRODUCTIONbull Build on two previous presentations
bull JS David Dahlrsquos ldquoFrom Web Developer to Firefox Hackerrdquo [1]
bull C++ Bobby Holleyrsquos ldquoHacking Geckordquo [2]
bull [1] httppeoplemozillacom~ddahlpagesHackingFirefoxtemplatehtml
bull [2] httppeoplemozillacom~bholleyhacking-gecko-fosdem2012hacking-geckohtml
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 3: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/3.jpg)
OUTLINEbull General Introduction
bull How To Implement New API
bull JS
bull C++
bull Make your work land
bull QampA
GENERAL INTRODUCTION
GENERAL INTRODUCTIONbull Build on two previous presentations
bull JS David Dahlrsquos ldquoFrom Web Developer to Firefox Hackerrdquo [1]
bull C++ Bobby Holleyrsquos ldquoHacking Geckordquo [2]
bull [1] httppeoplemozillacom~ddahlpagesHackingFirefoxtemplatehtml
bull [2] httppeoplemozillacom~bholleyhacking-gecko-fosdem2012hacking-geckohtml
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 4: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/4.jpg)
GENERAL INTRODUCTION
GENERAL INTRODUCTIONbull Build on two previous presentations
bull JS David Dahlrsquos ldquoFrom Web Developer to Firefox Hackerrdquo [1]
bull C++ Bobby Holleyrsquos ldquoHacking Geckordquo [2]
bull [1] httppeoplemozillacom~ddahlpagesHackingFirefoxtemplatehtml
bull [2] httppeoplemozillacom~bholleyhacking-gecko-fosdem2012hacking-geckohtml
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 5: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/5.jpg)
GENERAL INTRODUCTIONbull Build on two previous presentations
bull JS David Dahlrsquos ldquoFrom Web Developer to Firefox Hackerrdquo [1]
bull C++ Bobby Holleyrsquos ldquoHacking Geckordquo [2]
bull [1] httppeoplemozillacom~ddahlpagesHackingFirefoxtemplatehtml
bull [2] httppeoplemozillacom~bholleyhacking-gecko-fosdem2012hacking-geckohtml
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 6: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/6.jpg)
GENERAL INTRODUCTION
bull Need to build Firefox
bull Run build
bull LinuxWindows objdirdistbinfirefox
bullOSX objdirdistAppNameappContentsMacOSfirefox
bulloptions -ProfileManager -no-remote
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 7: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/7.jpg)
GENERAL INTRODUCTION
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 8: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/8.jpg)
GENERAL INTRODUCTION
bull Donrsquot get lost in the details
bull Ask for an implementation outline
bull There is documentation overview
bull Uumlber-Weapon Ask for help
bull IRC httpswikimozillaorgIRC developers
bull Mailing list httpslistsmozillaorglistinfo dev-webapi
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 9: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/9.jpg)
FRIENDLY PEOPLE TO PING ON IRC
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 10: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/10.jpg)
khuey (Kyle Huey)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 11: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/11.jpg)
ehsan (Ehsan Akhgari)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 12: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/12.jpg)
bholley (Bobby Holley)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 13: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/13.jpg)
jdm (Josh Matthews)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 14: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/14.jpg)
dholbert (Daniel Holbert)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 15: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/15.jpg)
Ms2ger ()
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 16: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/16.jpg)
GENERAL INTRODUCTION
bull whenever you do communication
bull try to be precise
bull give reasoning to your arguments
bull get only short answer - donrsquot take it wrong people are really busy
bull dump whatever you have (crashbackpatch)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 17: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/17.jpg)
GENERAL INTRODUCTION
bull donrsquot be afraid to ping people
bull might get hint to ping someone else
bull tell people youre new to hacking JSGecko
bull lookask for bugs that do similar things you try to solve
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 18: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/18.jpg)
HTTPSMXRMOZILLAORG
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 19: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/19.jpg)
FIREFOX OS WEBAPI
Telephony
VibratorContacts
Settings
Battery
PowerIdle
Bluetooth
many more to come
Browser
Webapps
httpswikimozillaorgWebAPI
Wifi
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 20: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/20.jpg)
INTERFACE + IMPLEMENTATION
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 21: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/21.jpg)
IT ALL STARTS WITH AN INTERFACEXPIDL VS WEBIDL
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 22: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/22.jpg)
XPIDL VS WEBIDL
interface EventTarget void addEventListener(DOMString type EventListener listener optional boolean capture = false optional boolean wantsUntrusted = null) void removeEventListener(DOMString type EventListener listener optional boolean capture = false) boolean dispatchEvent(Event event)
[scriptable builtinclass uuid(5a8294df-ffe4-48e5-803f-f57bebc29289)]interface nsIDOMScreen nsIDOMEventTarget readonly attribute long top readonly attribute DOMString mozOrientation [implicit_jscontext] attribute jsval onmozorientationchange
boolean mozLockOrientation(in DOMString orientation) void mozUnlockOrientation()
httpsdevelopermozillaorgen-USdocsMozillaWebIDL_bindingshttpsdevelopermozillaorgen-USdocsXPIDL
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 23: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/23.jpg)
MAPPING JS VS C++
bull Read other APIs
bull Interfaces are defined in dominterfaces
bull Implementations mostly in dom content
bull c++ implementations use common inheritance
bull JS implementations use manifest file
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 24: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/24.jpg)
TIME TO FILE A BUGBugzilla DOMDevice Interfaces
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 25: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/25.jpg)
HOW TO IMPLEMENT JS
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 26: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/26.jpg)
WHY IN JSbull Prototyping
bull Lower entry point
bull WebDevs know JS
bull Also better for understanding
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 27: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/27.jpg)
INTERFACE EXAMPLE
[scriptable uuid(da0f7040-388b-11e1-b86c-0800200c9444)]interface nsIDOMHelloWorld nsISupports void sayHello(in DOMString aName)
httpsbugzillamozillaorgshow_bugcgiid=674720
For example dominterfaceshelloworldnsIHelloWorldidl
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 28: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/28.jpg)
HELLOWORLDMANIFEST
component f5181640-89e8-11e1-b0c4-0800200c9444 HelloWorldjscontract mozillaorghelloWorld1 f5181640-89e8-11e1-b0c4-0800200c9444category JavaScript-navigator-property mozHelloWorld mozillaorghelloWorld1
For example domhelloworldHelloWorldmanifest
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 29: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/29.jpg)
HELLOWORLDJS
Text
const Cc = Componentsclassesconst Ci = Componentsinterfacesconst Cu = Componentsutils
Cuimport(resourcegremodulesXPCOMUtilsjsm)
function HelloWorld()
HelloWorldprototype =
init function init(aWindow)
sayHello function sayHello(aName) dump(Hello + aName + n)
classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) QueryInterface XPCOMUtilsgenerateQI([ComponentsinterfacesnsIDOMHelloWorld])
classInfo XPCOMUtilsgenerateCI(classID ComponentsID(d88af7e0-a45f-11e1-b3dd-0800200c9444) contractID mozillaorghelloWorld1 classDescription HelloWorld interfaces [ComponentsinterfacesnsIDOMHelloWorld CinsIDOMGlobalPropertyInitializer] flags CinsIClassInfoDOM_OBJECT)
const NSGetFactory = XPCOMUtilsgenerateNSGetFactory([HelloWorld])
For example domhelloworldHelloWorldjs
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 30: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/30.jpg)
BOILERPLATE
bull Makefiles
bull Manifest
bull Packaging
bull Module Loading
bull Access Permission
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 31: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/31.jpg)
EXPOSEDPROPS
let foo = new Foo()
Fooprototype = __exposedProps__ name rw
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 32: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/32.jpg)
FIREFOX OS PROCESS MODELbull Parent - Child Processes
bull Only one parent
bull Browser is in parent content pages are children
bull Nested process structure not possible (yet)
bull Parent is trusted
bull Child can be compromised
bull Security critical code has to run in parent
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 33: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/33.jpg)
SYSTEM MESSAGE MANAGERbull Use for child-parent communication
bull Child
bull Parent
childProcessMessageManagersendAsyncMessage(message-name foo 2)
var response = sendSyncMessage(message-name foo 1)
receiveMessage function(aMessage) switch (aMessagename) [] parentProcessMessageManagersendAsynMessage(ldquoreturn-message-namerdquo [])
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 34: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/34.jpg)
DOMREQUESTS
var pending = navigatormozAppsinstall(manifestUrl)pendingonsuccess = function () Save the App object that is returned var appRecord = thisresult alert(Installation successful)pendingonerror = function () Display the name of the error alert(Install failed error + thiserrorname)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 35: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/35.jpg)
PERMISSIONS
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 36: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/36.jpg)
HOW TO IMPLEMENT C++
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 37: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/37.jpg)
MAPPING JSC++
bull IDL files rarr JS amp C++
bull JS ctxlineWidth C++ ctxGetLineWidth(float width)
bull Need to implement C++ class for interface
bull NS_IMETHODIMP returns NS_ltstatusgt
bull Expose object nsDOMClassInfocppnsDOMClassInfoClassesh
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 38: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/38.jpg)
INTERFACES
Attribute
PrintStateCallback
canvasmozPrintCallback =
function(obj) var ctx = objcontext ctxfillRect(0 0 100 100) objdone()
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 39: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/39.jpg)
INTERFACES[scriptable uuid(a7062fca-41c6-4520-b777-3bb30fd77273)]interface nsIDOMHTMLCanvasElement nsIDOMHTMLElement []
A Mozilla-only callback that is called during the printing process attribute nsIPrintCallback mozPrintCallback
Attrib
ute
Callb
ack
[scriptable function uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a66)]interface nsIPrintCallback nsISupports void render(in nsIDOMMozCanvasPrintState ctx)
[scriptable builtinclass uuid(8d5fb8a0-7782-11e1-b0c4-0800200c9a67)]interface nsIDOMMozCanvasPrintState nsISupports A canvas rendering context readonly attribute nsISupports context
To be called when rendering to the context is done void done()
PrintS
tate
Taken frombug 745025
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 40: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/40.jpg)
class nsHTMLCanvasPrintState public nsIDOMMozCanvasPrintStatepublic nsHTMLCanvasPrintState(nsHTMLCanvasElement aCanvas nsICanvasRenderingContextInternal aContext nsITimerCallback aCallback) mIsDone(false) mPendingNotify(false) mCanvas(aCanvas) mContext(aContext) mCallback(aCallback)
NS_IMETHOD GetContext(nsISupports aContext) NS_ADDREF(aContext = mContext) return NS_OK
NS_IMETHOD Done() [] return NS_OK
[]
Taken frombug 745025
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 41: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/41.jpg)
MEMORY MANAGEMENTbull C++ doesnrsquot have a garbage collector (
bull In Gecko Reference counting amp cycle collector
bull Reference counting
bull nsCOMPtr (for interfaces) nsREFPtr
bull use getter_AddRefs
bull NS_IF_ADDREF amp NS_IF_RELEASE
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 42: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/42.jpg)
MEMORY MANAGEMENT
bull Reference counting doesnrsquot work always
bull Make use of Geckorsquos cycle collector
bull Better cycle then maybe leak
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 43: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/43.jpg)
DEBUGGING
bull Make sure to have a debug build
bull Enable logging (example)
bull Watch for assertion in logs
bull Insert printfs
bull There is documentation how to use debugger
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 44: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/44.jpg)
OVERVIEW OF SOME TREES
bull Frame Tree Frames on page
bull Content Tree Content going with frames
bull View Tree Connecting views
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 45: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/45.jpg)
MAKE YOUR WORK LAND
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 46: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/46.jpg)
TESTS TESTS TESTS
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 47: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/47.jpg)
bull Reftests
bull Crashtests
bull XPCShell Tests
bull Mochitests
bull JS tests
bull Compiled code tests -(
bull Marionette tests
DIFFERENT TYPE OF TESTS
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 48: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/48.jpg)
MOCHITEST
Text
bullpathtoobjdir $ TEST_PATH=domcontactstests make mochitest-plain
bullpathtoobjdir $ TEST_PATH=domcontactsteststest_contactshtml make mochitest-plain
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 49: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/49.jpg)
TIME FOR REVIEWbull Make sure the patch is formatted according to the guidelines
bull 8 lines of context
bull correct committer info (name + email)
bull correct checking message
bull When uploading a new version
bull address all review comments
bull obsolete the old patch
bull run tests again
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 50: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/50.jpg)
REVIEWbull Make sure your patch is clean
bull Patch should be green on try-push
bull WIP State whatrsquos workingwhat notwhatrsquos next
bull Review might take some time (~1 week)
bull If longer ping person switch review person
bull Except r- donrsquot worry
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 51: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/51.jpg)
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
![Page 52: Implementing new WebAPIs](https://reader035.vdocuments.net/reader035/viewer/2022070300/54433388b1af9f410a8b48d5/html5/thumbnails/52.jpg)
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver