One or more computer-readable storage media comprising instructions stored thereon that, responsive to execution by a computing device , cause the computing device to: enforce a first set of content handling policies for a first portion of application code of an application that is permitted to invoke code elements of the computing device , wherein the first portion of application code is a local compartment, and enforce a second set of content handling policies for a second portion of application code of the application that is not permitted to invoke the code elements, wherein the second portion of application code is a remote compartment; and determine whether to apply the first set of content handling policies or the second set of content handling policies to content based on which portion of the application is requesting the content, wherein content of the local compartment and content of the remote compartment is identified using a uniform resource identifier, URI, that is specific to the respective compartment, wherein the first set of content handling policies specifies that if the content includes untrusted content and the first portion of application code of the application is requesting that the untrusted content be passed to one of the code elements, the untrusted content is to be inspected to determine whether the untrusted content is safe before the untrusted content may be passed to the one of the code elements, and wherein the first set of content handling policies specifies that content retrieved from the local compartment of the computing device is encoded using a specific character encoding format or the content will be prevented from being parsed. enforce a first set of content handling policies for a first portion of application code of an application that is permitted to invoke code elements of the computing device , wherein the first portion of application code is a local compartment, and enforce a second set of content handling policies for a second portion of application code of the application that is not permitted to invoke the code elements, wherein the second portion of application code is a remote compartment; and determine whether to apply the first set of content handling policies or the second set of content handling policies to content based on which portion of the application is requesting the content, wherein content of the local compartment and content of the remote compartment is identified using a uniform resource identifier, URI, that is specific to the respective compartment, wherein the first set of content handling policies specifies that if the content includes untrusted content and the first portion of application code of the application is requesting that the untrusted content be passed to one of the code elements, the untrusted content is to be inspected to determine whether the untrusted content is safe before the untrusted content may be passed to the one of the code elements, and wherein the first set of content handling policies specifies that content retrieved from the local compartment of the computing device is encoded using a specific character encoding format or the content will be prevented from being parsed. <EOS>