Section 22 of the Children’s Law Reform Act lays down the law on jurisdiction of a court in cases involving custody issues. Section 22(1) states:
A court shall only exercise its jurisdiction to make an order for custody of or access to a child where,
(a) the child is habitually resident in Ontario at the commencement of the application for the order; or
(b) although the child is not habitually resident in Ontario, the court is satisfied,
(i) that the child is physically present in Ontario at the commencement of the application for the order,
(ii) that substantial evidence concerning the best interests of the child is available in Ontario,
(iii) that no application for custody of or access to the child is pending before an extra-provincial tribunal in another place where the child is habitually resident,
(iv) that no extra-provincial order in respect of custody of or access to the child has been recognized by a court in Ontario,
(v) that the child has a real and substantial connection with Ontario, and
(vi) that, on the balance of convenience, it is appropriate for jurisdiction to be exercised in Ontario. R.S.O. 1990, c. C.12, s. 22 (1).
Section 22 (2) of the Children’s Law Reform Act defines Habitual residence as a place where the child is habitually resident:
(a) with both parents;
(b) where the parents are living separate and apart, with one parent under a separation agreement or with the consent, implied consent or acquiescence of the other or under a court order; or
(c) with a person other than a parent on a permanent basis for a significant period of time.
Section 23 of the Children’s Law Reform Act states an exception to section 22 by stating that a court may assume jurisdiction if:
(a) the child is physically present in Ontario; and
(b) the court is satisfied that the child would, on the balance of probabilities, suffer serious harm if,
(i) the child remains in the custody of the person legally entitled to custody of the child,
(ii) the child is returned to the custody of the person legally entitled to custody of the child, or
(iii) the child is removed from Ontario.
http://www.canlii.org/en/on/laws/stat/rso-1990-c-c12/latest/rso-1990-c-c12.html#sec22subsec1_smooth