Implementing New Web
-
Upload
julian-viereck -
Category
Technology
-
view
637 -
download
0
description
Transcript of Implementing New Web
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Q amp A
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver
THINGS TO HACK ON
bull Implement vwvhvminvmax
bull dirname DOM attribute on form controls
bull Implement FileSaver