public void SetOnhashchangeAttribute(JsVal aOnhashchange, IntPtr jsContext) { throw new NotImplementedException(); }
public void IsString_OnNumberJsVal_RetrunsFalse() { JsVal numberJsVal = SpiderMonkeyTests.CreateNumberJsVal(23); Assert.IsFalse(numberJsVal.IsString); }
public void PostMessage(JsVal message, nsAStringBase targetOrigin, IntPtr jsContext) { throw new NotImplementedException(); }
public void ToString_OnBoolJsVal_ReturnsNumberContentsConvertedToAString() { JsVal stringJsVal = SpiderMonkeyTests.CreateBoolJsVal(false); Assert.AreEqual("false", stringJsVal.ToString()); }
public void Type_OnNumberJsVal_ReturnsNumberType() { JsVal numberJsVal = SpiderMonkeyTests.CreateNumberJsVal(23); Assert.AreEqual(JSType.JSTYPE_NUMBER, numberJsVal.Type); }
public void SetConsoleAttribute(JsVal aConsole, IntPtr jsContext) { throw new NotImplementedException(); }
public void ToString_OnStringJsVal_ReturnsStringContents() { JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world"); Assert.AreEqual("hello world", stringJsVal.ToString()); }
public static extern JSFunction JS_ValueToFunction(JSContext cx, JsVal v);
public static extern JSFunction JS_ValueToConstructor(JSContext cx, JsVal v);
public static extern Boolean JS_ConvertValue(JSContext cx, JsVal v, JSType type, ref JsVal vp);
public static extern Boolean JS_ValueToObject(JSContext cx, JsVal v, ref JSObject objp);
public int RequestAnimationFrame(JsVal aCallback, IntPtr jsContext) { throw new NotImplementedException(); }
public IEnumerable <KeyValuePair <string, Action <IntPtr> > > EntryPoints() { yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EncodeString", (c) => SpiderMonkey.JS_EncodeString(IntPtr.Zero, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_TypeOfValue", (c) => SpiderMonkey.JS_TypeOfValue(IntPtr.Zero, default(JsVal)))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ValueToString", (c) => SpiderMonkey.JS_ValueToString(IntPtr.Zero, default(JsVal)))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ValueToObject", (c) => SpiderMonkey.JS_ValueToObject(IntPtr.Zero, default(JsVal)))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewStringCopyN", (c) => SpiderMonkey.JS_NewStringCopyN(c, "", 0))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetGlobalForObject", (c) => SpiderMonkey.JS_GetGlobalForObject(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("GetGlobalForObjectCrossCompartment", (c) => SpiderMonkey.GetGlobalForObjectCrossCompartment(IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SaveFrameChain", (c) => SpiderMonkey.JS_SaveFrameChain(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewObject", (c) => SpiderMonkey.JS_NewObject(c, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetParent", (c) => SpiderMonkey.JS_GetParent(IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("CurrentGlobalOrNull", (c) => SpiderMonkey.CurrentGlobalOrNull(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewContext", (c) => SpiderMonkey.JS_NewContext(IntPtr.Zero, 0))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetRuntime", (c) => SpiderMonkey.JS_GetRuntime(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetContextPrivate", (c) => SpiderMonkey.JS_GetContextPrivate(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextPrivate", (c) => SpiderMonkey.JS_SetContextPrivate(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("DefaultObjectForContextOrNull", (c) => SpiderMonkey.DefaultObjectForContextOrNull(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_BeginRequest", (c) => SpiderMonkey.JS_BeginRequest(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EndRequest", (c) => SpiderMonkey.JS_EndRequest(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EvaluateScript", (c) => { var jsVal = new JsVal(); SpiderMonkey.JS_EvaluateScript(c, IntPtr.Zero, "", 0, "", 0, ref jsVal); })); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClassObject", (c) => SpiderMonkey.JS_GetClassObject(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClass", (c) => SpiderMonkey.JS_GetClass(IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ContextIterator", (c) => { var pt = IntPtr.Zero; SpiderMonkey.JS_ContextIterator(IntPtr.Zero, ref pt); })); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextCallback", (c) => SpiderMonkey.JS_SetContextCallback(IntPtr.Zero, null))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EnterCompartment", (c) => SpiderMonkey.JS_EnterCompartment(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_LeaveCompartment", (c) => SpiderMonkey.JS_LeaveCompartment(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_Free", (c) => SpiderMonkey.JS_Free(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_WrapObject", (c) => SpiderMonkey.JS_WrapObject(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("IsObjectInContextCompartment", (c) => SpiderMonkey.IsObjectInContextCompartment(IntPtr.Zero, c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_DestroyRuntime", (c) => SpiderMonkey.JS_DestroyRuntime(IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_HasProperty", (c) => SpiderMonkey.JS_HasProperty(c, IntPtr.Zero, ""))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetProperty", (c) => SpiderMonkey.JS_GetProperty(c, IntPtr.Zero, ""))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_CallFunctionName", (c) => SpiderMonkey.JS_CallFunctionName(c, IntPtr.Zero, "", new JsVal[0]))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetCompartmentPrincipals", (c) => SpiderMonkey.JS_SetCompartmentPrincipals(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetCompartmentPrincipals", (c) => SpiderMonkey.JS_GetCompartmentPrincipals(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetTrustedPrincipals", (c) => SpiderMonkey.JS_SetTrustedPrincipals(IntPtr.Zero, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetPendingException", (c) => SpiderMonkey.JS_GetPendingException(c))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetErrorReporter", (c) => SpiderMonkey.JS_SetErrorReporter(c, (cx, message, report) => {}))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EncodeStringUTF8", (c) => SpiderMonkey.JS_EncodeStringToUTF8(c, IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetStringLength", (c) => SpiderMonkey.JS_GetStringLength(IntPtr.Zero))); yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetStringEncodingLength", (c) => SpiderMonkey.JS_GetStringEncodingLength(c, IntPtr.Zero))); }
public void SetOpenerAttribute(JsVal aOpener, IntPtr jsContext) { throw new NotImplementedException(); }
public void SetOnpageshowAttribute(JsVal aOnpageshow, IntPtr jsContext) { throw new NotImplementedException(); }
public static extern JSString JS_ValueToSource(JSContext cx, JsVal v);
public void SetOndeviceorientationAttribute(JsVal aOndeviceorientation, IntPtr jsContext) { throw new NotImplementedException(); }
public static extern Boolean JS_ValueToNumber(JSContext cx, JsVal v, ref Double dp);
private static GeckoElement CreateHtmlElementFromDom(AutoJSContext autoContext, JsVal jsValue, int elementIndex) { var elementIndexString = elementIndex.ToString(CultureInfo.InvariantCulture); var firstNativeDom = SpiderMonkey.JS_GetProperty(autoContext.ContextPointer, jsValue.AsPtr, elementIndexString).ToComObject(autoContext.ContextPointer); var element = Xpcom.QueryInterface <nsIDOMHTMLElement>(firstNativeDom); if (element == null) { return(null); } return(GeckoHtmlElement.Create(element)); }
public static extern Boolean JS_ValueToInt32(JSContext cx, JsVal v, ref Int32 ip);
public void ToString_OnNumberJsVal_ReturnsNumberContentsConvertedToAString() { JsVal stringJsVal = SpiderMonkeyTests.CreateNumberJsVal(23); Assert.AreEqual("23", stringJsVal.ToString()); }
public static extern Boolean JS_ValueToUint16(JSContext cx, JsVal v, ref UInt16 ip);
public void Type_OnStringJsVal_RetrunsStringType() { JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world"); Assert.AreEqual(JSType.JSTYPE_STRING, stringJsVal.Type); }
public static extern Boolean JS_ValueToBoolean(JSContext cx, JsVal v, ref Boolean bp);
public void IsString_OnStringJsVal_RetrunsTrue() { JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world"); Assert.IsTrue(stringJsVal.IsString); }
public static extern JSType JS_TypeOfValue(JSContext cx, JsVal v);
public void SetOnuserproximityAttribute(JsVal aOnuserproximity, IntPtr jsContext) { throw new NotImplementedException(); }
public static extern Boolean JS_StrictlyEqual(JSContext cx, JsVal v1, JsVal v2, ref Boolean equal);
public void SetOnbeforeprintAttribute(JsVal aOnbeforeprint, IntPtr jsContext) { throw new NotImplementedException(); }
public static extern Boolean JS_SameValue(JSContext cx, JsVal v1, JsVal v2, ref Boolean same);
public void SetOnpopstateAttribute(JsVal aOnpopstate, IntPtr jsContext) { throw new NotImplementedException(); }
public static extern Boolean JS_WrapValue(JSContext cx, ref JsVal vp);
public void SetOnunloadAttribute(JsVal aOnunload, IntPtr jsContext) { throw new NotImplementedException(); }
public void JS_TypeOfValue() { if (Xpcom.IsLinux && IntPtr.Size == 8) { Assert.Ignore("unsafe test:seg faults on 64bit Linux"); } using (AutoJSContext cx = new AutoJSContext(AutoJSContext.SafeJSContext)) { Assert.AreEqual(JSType.JSTYPE_NUMBER, SpiderMonkey.JS_TypeOfValue(cx.ContextPointer, JsVal.FromPtr(0))); Assert.AreEqual(JSType.JSTYPE_NUMBER, SpiderMonkey.JS_TypeOfValue(cx.ContextPointer, JsVal.FromPtr(0xffff0000ffffffff))); Assert.AreEqual(JSType.JSTYPE_XML, SpiderMonkey.JS_TypeOfValue(cx.ContextPointer, JsVal.FromPtr(0xffffffffffffffff))); } }
public void SetOnmouseleaveAttribute(JsVal aOnmouseleave, IntPtr jsContext) { throw new NotImplementedException(); }
private static List <JsVal> ConvertTypes(object[] paramObjects, AutoJSContext context, out DisposablCollection toDispose) { List <IDisposable> list = new List <IDisposable>(); toDispose = new DisposablCollection(list); var collection = new List <JsVal>(); if (paramObjects == null) { return(collection); } foreach (var p in paramObjects) { JsVal val; if (p is nsAString || p is nsACString || p is nsAUTF8String || p is String) { val = SpiderMonkey.StringToJsVal(context.ContextPointer, p.ToString()); } else if (p is nsISupports) { // This returns a [xpconnect wrapped nsISupports] - why may or may not be good enought - if not could try and access the objects wrappedJSObject property? // val = SpiderMonkey.JS_CallFunctionName(context.ContextPointer, jsObject, "valueOf"); // Replaced CallFunctionName 'valueOf' method with 'managed convert' (for speed reasons) var jso = context.ConvertCOMObjectToJSObject((nsISupports)p, false); list.Add(jso); val = JsVal.FromPtr(jso.JSObject); } else if (p is bool) { val = CreateBoolJsVal(context, (bool)p); } else if (p is double) { val = JsVal.FromDouble((double)p); } else if (p is int) { val = JsVal.FromDouble(Convert.ToDouble(p)); } else if (p is WebIDLUnionBase) { WebIDLUnionBase b = (WebIDLUnionBase)p; if (b.IsNull()) { SpiderMonkey.JS_ExecuteScript(context.ContextPointer, "null", out val); } else if (b.IsComObject()) { var item = ((WebIDLUnionBase)p).ToComObject(); var jso = context.ConvertCOMObjectToJSObject(item, false); list.Add(jso); val = JsVal.FromPtr(jso.JSObject); } else if (b.IsBool()) { val = CreateBoolJsVal(context, b.ToBool()); } else { throw new NotImplementedException("WebIDLUnion are currently only supported for nsISupport and bool types and null's."); } } else { SpiderMonkey.JS_ExecuteScript(context.ContextPointer, (p ?? "null").ToString(), out val); } collection.Add(val); } return(collection); }