mshtml: Added noscript tag handling tests.
[wine] / dlls / mshtml / tests / misc.c
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #define COBJMACROS
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "initguid.h"
28 #include "optary.h"
29
30 static void test_HTMLLoadOptions(void)
31 {
32     IHtmlLoadOptions *loadopts;
33     BYTE buf[100];
34     DWORD size, i, data = 0xdeadbeef;
35     HRESULT hres;
36
37     hres = CoCreateInstance(&CLSID_HTMLLoadOptions, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
38             &IID_IHtmlLoadOptions, (void**)&loadopts);
39     ok(hres == S_OK, "creating HTMLLoadOptions failed: %08x\n", hres);
40     if(FAILED(hres))
41         return;
42
43     for(i=0; i <= HTMLLOADOPTION_FRAMELOAD+3; i++) {
44         size = 0xdeadbeef;
45         memset(buf, 0xdd, sizeof(buf));
46         hres = IHtmlLoadOptions_QueryOption(loadopts, i, NULL, &size);
47         ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
48         ok(size == 0, "size = %d\n", size);
49         ok(buf[0] == 0xdd, "buf changed\n");
50     }
51
52     size = 0xdeadbeef;
53     hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, NULL, &size);
54     ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
55     ok(size == 0, "size = %d\n", size);
56
57     hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, &data, sizeof(data));
58     ok(hres == S_OK, "SetOption failed: %08x\n", hres);
59
60     size = sizeof(data);
61     memset(buf, 0xdd, sizeof(buf));
62     hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size);
63     ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
64     ok(size == sizeof(data), "size = %d\n", size);
65     ok(*(DWORD*)buf == data, "unexpected buf\n");
66
67     size = sizeof(data)-1;
68     memset(buf, 0xdd, sizeof(buf));
69     hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size);
70     ok(hres == E_FAIL, "QueryOption failed: %08x\n", hres);
71     ok(size == sizeof(data) || !size, "size = %d\n", size);
72     ok(buf[0] == 0xdd, "buf changed\n");
73
74     data = 100;
75     hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, &data, 0);
76     ok(hres == S_OK, "SetOption failed: %08x\n", hres);
77
78     size = 0xdeadbeef; 
79     memset(buf, 0xdd, sizeof(buf));
80     hres = IHtmlLoadOptions_QueryOption(loadopts, HTMLLOADOPTION_CODEPAGE, buf, &size);
81     ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
82     ok(size == 0, "size = %d\n", size);
83     ok(buf[0] == 0xdd, "buf changed\n");
84
85     hres = IHtmlLoadOptions_SetOption(loadopts, HTMLLOADOPTION_CODEPAGE, NULL, 0);
86     ok(hres == S_OK, "SetOption failed: %08x\n", hres);
87
88     hres = IHtmlLoadOptions_SetOption(loadopts, 1000, &data, sizeof(data));
89     ok(hres == S_OK, "SetOption failed: %08x\n", hres);
90
91     size = sizeof(data);
92     memset(buf, 0xdd, sizeof(buf));
93     hres = IHtmlLoadOptions_QueryOption(loadopts, 1000, buf, &size);
94     ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
95     ok(size == sizeof(data), "size = %d\n", size);
96     ok(*(DWORD*)buf == data, "unexpected buf\n");
97
98     hres = IHtmlLoadOptions_SetOption(loadopts, 1000, buf, sizeof(buf));
99     ok(hres == S_OK, "SetOption failed: %08x\n", hres);
100
101     size = 0xdeadbeef;
102     hres = IHtmlLoadOptions_QueryOption(loadopts, 1000, buf, &size);
103     ok(hres == S_OK, "QueryOption failed: %08x\n", hres);
104     ok(size == sizeof(buf), "size = %d\n", size);
105
106     IHtmlLoadOptions_Release(loadopts);
107 }
108
109 START_TEST(misc)
110 {
111     CoInitialize(NULL);
112
113     test_HTMLLoadOptions();
114
115     CoUninitialize();
116 }