+ /**
+ * The load context of the window bound to this buffer.
+ */
+ get loadContext() sanitizer.getContext(this.win),
+
+ /**
+ * Content preference methods.
+ */
+ prefs: Class.Memoize(function ()
+ let (self = this) ({
+ /**
+ * Returns a promise for the given preference name.
+ *
+ * @param {string} pref The name of the preference to return.
+ * @returns {Promise<*>}
+ */
+ get: promises.withCallbacks(function get([resolve, reject], pref) {
+ let val = services.contentPrefs.getCachedByDomainAndName(
+ self.uri.spec, pref, self.loadContext);
+
+ let found = false;
+ if (val)
+ resolve(val.value);
+ else
+ services.contentPrefs.getByDomainAndName(
+ self.uri.spec, pref, self.loadContext,
+ { handleCompletion: () => {
+ if (!found)
+ resolve(undefined);
+ },
+ handleResult: (pref) => {
+ found = true;
+ resolve(pref.value);
+ },
+ handleError: reject });
+ }),
+
+ /**
+ * Sets a content preference for the given buffer.
+ *
+ * @param {string} pref The preference to set.
+ * @param {string} value The value to store.
+ */
+ set: promises.withCallbacks(function set([resolve, reject], pref, value) {
+ services.contentPrefs.set(
+ self.uri.spec, pref, value, self.loadContext,
+ { handleCompletion: () => {},
+ handleResult: resolve,
+ handleError: reject });
+ }),
+
+ /**
+ * Clear a content preference for the given buffer.
+ *
+ * @param {string} pref The preference to clear.
+ */
+ clear: promises.withCallbacks(function clear([resolve, reject], pref) {
+ services.contentPrefs.removeByDomainAndName(
+ self.uri.spec, pref, self.loadContext,
+ { handleCompletion: () => {},
+ handleResult: resolve,
+ handleError: reject });
+ })
+ })),
+